blob: 26fb42450cb22b5c8a76a6f25b9ccca367828e10 [file] [log] [blame]
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001/*
2 * Copyright 2004 ATI Technologies Inc., Markham, Ontario
3 * Copyright 2007-8 Advanced Micro Devices, Inc.
4 * Copyright 2008 Red Hat Inc.
5 *
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:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
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.
23 *
24 * Authors: Dave Airlie
25 * Alex Deucher
26 */
27#include "drmP.h"
28#include "radeon_drm.h"
29#include "radeon.h"
30#include "atom.h"
31
32#ifdef CONFIG_PPC_PMAC
33/* not sure which of these are needed */
34#include <asm/machdep.h>
35#include <asm/pmac_feature.h>
36#include <asm/prom.h>
37#include <asm/pci-bridge.h>
38#endif /* CONFIG_PPC_PMAC */
39
40/* from radeon_encoder.c */
41extern uint32_t
42radeon_get_encoder_id(struct drm_device *dev, uint32_t supported_device,
43 uint8_t dac);
44extern void radeon_link_encoder_connector(struct drm_device *dev);
45
46/* from radeon_connector.c */
47extern void
48radeon_add_legacy_connector(struct drm_device *dev,
49 uint32_t connector_id,
50 uint32_t supported_device,
51 int connector_type,
Alex Deucherb75fad02009-11-05 13:16:01 -050052 struct radeon_i2c_bus_rec *i2c_bus,
Alex Deuchereed45b32009-12-04 14:45:27 -050053 uint16_t connector_object_id,
54 struct radeon_hpd *hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +020055
56/* from radeon_legacy_encoder.c */
57extern void
58radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_id,
59 uint32_t supported_device);
60
61/* old legacy ATI BIOS routines */
62
63/* COMBIOS table offsets */
64enum 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 */
112};
113
114enum radeon_combios_ddc {
115 DDC_NONE_DETECTED,
116 DDC_MONID,
117 DDC_DVI,
118 DDC_VGA,
119 DDC_CRT2,
120 DDC_LCD,
121 DDC_GPIO,
122};
123
124enum 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
133};
134
135const 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,
144};
145
146static uint16_t combios_get_table_offset(struct drm_device *dev,
147 enum radeon_combios_table_offset table)
148{
149 struct radeon_device *rdev = dev->dev_private;
150 int rev;
151 uint16_t offset = 0, check_offset;
152
153 switch (table) {
154 /* absolute offset tables */
155 case COMBIOS_ASIC_INIT_1_TABLE:
156 check_offset = RBIOS16(rdev->bios_header_start + 0xc);
157 if (check_offset)
158 offset = check_offset;
159 break;
160 case COMBIOS_BIOS_SUPPORT_TABLE:
161 check_offset = RBIOS16(rdev->bios_header_start + 0x14);
162 if (check_offset)
163 offset = check_offset;
164 break;
165 case COMBIOS_DAC_PROGRAMMING_TABLE:
166 check_offset = RBIOS16(rdev->bios_header_start + 0x2a);
167 if (check_offset)
168 offset = check_offset;
169 break;
170 case COMBIOS_MAX_COLOR_DEPTH_TABLE:
171 check_offset = RBIOS16(rdev->bios_header_start + 0x2c);
172 if (check_offset)
173 offset = check_offset;
174 break;
175 case COMBIOS_CRTC_INFO_TABLE:
176 check_offset = RBIOS16(rdev->bios_header_start + 0x2e);
177 if (check_offset)
178 offset = check_offset;
179 break;
180 case COMBIOS_PLL_INFO_TABLE:
181 check_offset = RBIOS16(rdev->bios_header_start + 0x30);
182 if (check_offset)
183 offset = check_offset;
184 break;
185 case COMBIOS_TV_INFO_TABLE:
186 check_offset = RBIOS16(rdev->bios_header_start + 0x32);
187 if (check_offset)
188 offset = check_offset;
189 break;
190 case COMBIOS_DFP_INFO_TABLE:
191 check_offset = RBIOS16(rdev->bios_header_start + 0x34);
192 if (check_offset)
193 offset = check_offset;
194 break;
195 case COMBIOS_HW_CONFIG_INFO_TABLE:
196 check_offset = RBIOS16(rdev->bios_header_start + 0x36);
197 if (check_offset)
198 offset = check_offset;
199 break;
200 case COMBIOS_MULTIMEDIA_INFO_TABLE:
201 check_offset = RBIOS16(rdev->bios_header_start + 0x38);
202 if (check_offset)
203 offset = check_offset;
204 break;
205 case COMBIOS_TV_STD_PATCH_TABLE:
206 check_offset = RBIOS16(rdev->bios_header_start + 0x3e);
207 if (check_offset)
208 offset = check_offset;
209 break;
210 case COMBIOS_LCD_INFO_TABLE:
211 check_offset = RBIOS16(rdev->bios_header_start + 0x40);
212 if (check_offset)
213 offset = check_offset;
214 break;
215 case COMBIOS_MOBILE_INFO_TABLE:
216 check_offset = RBIOS16(rdev->bios_header_start + 0x42);
217 if (check_offset)
218 offset = check_offset;
219 break;
220 case COMBIOS_PLL_INIT_TABLE:
221 check_offset = RBIOS16(rdev->bios_header_start + 0x46);
222 if (check_offset)
223 offset = check_offset;
224 break;
225 case COMBIOS_MEM_CONFIG_TABLE:
226 check_offset = RBIOS16(rdev->bios_header_start + 0x48);
227 if (check_offset)
228 offset = check_offset;
229 break;
230 case COMBIOS_SAVE_MASK_TABLE:
231 check_offset = RBIOS16(rdev->bios_header_start + 0x4a);
232 if (check_offset)
233 offset = check_offset;
234 break;
235 case COMBIOS_HARDCODED_EDID_TABLE:
236 check_offset = RBIOS16(rdev->bios_header_start + 0x4c);
237 if (check_offset)
238 offset = check_offset;
239 break;
240 case COMBIOS_ASIC_INIT_2_TABLE:
241 check_offset = RBIOS16(rdev->bios_header_start + 0x4e);
242 if (check_offset)
243 offset = check_offset;
244 break;
245 case COMBIOS_CONNECTOR_INFO_TABLE:
246 check_offset = RBIOS16(rdev->bios_header_start + 0x50);
247 if (check_offset)
248 offset = check_offset;
249 break;
250 case COMBIOS_DYN_CLK_1_TABLE:
251 check_offset = RBIOS16(rdev->bios_header_start + 0x52);
252 if (check_offset)
253 offset = check_offset;
254 break;
255 case COMBIOS_RESERVED_MEM_TABLE:
256 check_offset = RBIOS16(rdev->bios_header_start + 0x54);
257 if (check_offset)
258 offset = check_offset;
259 break;
260 case COMBIOS_EXT_TMDS_INFO_TABLE:
261 check_offset = RBIOS16(rdev->bios_header_start + 0x58);
262 if (check_offset)
263 offset = check_offset;
264 break;
265 case COMBIOS_MEM_CLK_INFO_TABLE:
266 check_offset = RBIOS16(rdev->bios_header_start + 0x5a);
267 if (check_offset)
268 offset = check_offset;
269 break;
270 case COMBIOS_EXT_DAC_INFO_TABLE:
271 check_offset = RBIOS16(rdev->bios_header_start + 0x5c);
272 if (check_offset)
273 offset = check_offset;
274 break;
275 case COMBIOS_MISC_INFO_TABLE:
276 check_offset = RBIOS16(rdev->bios_header_start + 0x5e);
277 if (check_offset)
278 offset = check_offset;
279 break;
280 case COMBIOS_CRT_INFO_TABLE:
281 check_offset = RBIOS16(rdev->bios_header_start + 0x60);
282 if (check_offset)
283 offset = check_offset;
284 break;
285 case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE:
286 check_offset = RBIOS16(rdev->bios_header_start + 0x62);
287 if (check_offset)
288 offset = check_offset;
289 break;
290 case COMBIOS_COMPONENT_VIDEO_INFO_TABLE:
291 check_offset = RBIOS16(rdev->bios_header_start + 0x64);
292 if (check_offset)
293 offset = check_offset;
294 break;
295 case COMBIOS_FAN_SPEED_INFO_TABLE:
296 check_offset = RBIOS16(rdev->bios_header_start + 0x66);
297 if (check_offset)
298 offset = check_offset;
299 break;
300 case COMBIOS_OVERDRIVE_INFO_TABLE:
301 check_offset = RBIOS16(rdev->bios_header_start + 0x68);
302 if (check_offset)
303 offset = check_offset;
304 break;
305 case COMBIOS_OEM_INFO_TABLE:
306 check_offset = RBIOS16(rdev->bios_header_start + 0x6a);
307 if (check_offset)
308 offset = check_offset;
309 break;
310 case COMBIOS_DYN_CLK_2_TABLE:
311 check_offset = RBIOS16(rdev->bios_header_start + 0x6c);
312 if (check_offset)
313 offset = check_offset;
314 break;
315 case COMBIOS_POWER_CONNECTOR_INFO_TABLE:
316 check_offset = RBIOS16(rdev->bios_header_start + 0x6e);
317 if (check_offset)
318 offset = check_offset;
319 break;
320 case COMBIOS_I2C_INFO_TABLE:
321 check_offset = RBIOS16(rdev->bios_header_start + 0x70);
322 if (check_offset)
323 offset = check_offset;
324 break;
325 /* relative offset tables */
326 case COMBIOS_ASIC_INIT_3_TABLE: /* offset from misc info */
327 check_offset =
328 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
329 if (check_offset) {
330 rev = RBIOS8(check_offset);
331 if (rev > 0) {
332 check_offset = RBIOS16(check_offset + 0x3);
333 if (check_offset)
334 offset = check_offset;
335 }
336 }
337 break;
338 case COMBIOS_ASIC_INIT_4_TABLE: /* offset from misc info */
339 check_offset =
340 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
341 if (check_offset) {
342 rev = RBIOS8(check_offset);
343 if (rev > 0) {
344 check_offset = RBIOS16(check_offset + 0x5);
345 if (check_offset)
346 offset = check_offset;
347 }
348 }
349 break;
350 case COMBIOS_DETECTED_MEM_TABLE: /* offset from misc info */
351 check_offset =
352 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
353 if (check_offset) {
354 rev = RBIOS8(check_offset);
355 if (rev > 0) {
356 check_offset = RBIOS16(check_offset + 0x7);
357 if (check_offset)
358 offset = check_offset;
359 }
360 }
361 break;
362 case COMBIOS_ASIC_INIT_5_TABLE: /* offset from misc info */
363 check_offset =
364 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
365 if (check_offset) {
366 rev = RBIOS8(check_offset);
367 if (rev == 2) {
368 check_offset = RBIOS16(check_offset + 0x9);
369 if (check_offset)
370 offset = check_offset;
371 }
372 }
373 break;
374 case COMBIOS_RAM_RESET_TABLE: /* offset from mem config */
375 check_offset =
376 combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE);
377 if (check_offset) {
378 while (RBIOS8(check_offset++));
379 check_offset += 2;
380 if (check_offset)
381 offset = check_offset;
382 }
383 break;
384 case COMBIOS_POWERPLAY_INFO_TABLE: /* offset from mobile info */
385 check_offset =
386 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
387 if (check_offset) {
388 check_offset = RBIOS16(check_offset + 0x11);
389 if (check_offset)
390 offset = check_offset;
391 }
392 break;
393 case COMBIOS_GPIO_INFO_TABLE: /* offset from mobile info */
394 check_offset =
395 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
396 if (check_offset) {
397 check_offset = RBIOS16(check_offset + 0x13);
398 if (check_offset)
399 offset = check_offset;
400 }
401 break;
402 case COMBIOS_LCD_DDC_INFO_TABLE: /* offset from mobile info */
403 check_offset =
404 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
405 if (check_offset) {
406 check_offset = RBIOS16(check_offset + 0x15);
407 if (check_offset)
408 offset = check_offset;
409 }
410 break;
411 case COMBIOS_TMDS_POWER_TABLE: /* offset from mobile info */
412 check_offset =
413 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
414 if (check_offset) {
415 check_offset = RBIOS16(check_offset + 0x17);
416 if (check_offset)
417 offset = check_offset;
418 }
419 break;
420 case COMBIOS_TMDS_POWER_ON_TABLE: /* offset from tmds power */
421 check_offset =
422 combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE);
423 if (check_offset) {
424 check_offset = RBIOS16(check_offset + 0x2);
425 if (check_offset)
426 offset = check_offset;
427 }
428 break;
429 case COMBIOS_TMDS_POWER_OFF_TABLE: /* offset from tmds power */
430 check_offset =
431 combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE);
432 if (check_offset) {
433 check_offset = RBIOS16(check_offset + 0x4);
434 if (check_offset)
435 offset = check_offset;
436 }
437 break;
438 default:
439 break;
440 }
441
442 return offset;
443
444}
445
Alex Deucher3c537882010-02-05 04:21:19 -0500446bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev)
447{
448 int edid_info;
449 struct edid *edid;
450 edid_info = combios_get_table_offset(rdev->ddev, COMBIOS_HARDCODED_EDID_TABLE);
451 if (!edid_info)
452 return false;
453
454 edid = kmalloc(EDID_LENGTH * (DRM_MAX_EDID_EXT_NUM + 1),
455 GFP_KERNEL);
456 if (edid == NULL)
457 return false;
458
459 memcpy((unsigned char *)edid,
460 (unsigned char *)(rdev->bios + edid_info), EDID_LENGTH);
461
462 if (!drm_edid_is_valid(edid)) {
463 kfree(edid);
464 return false;
465 }
466
467 rdev->mode_info.bios_hardcoded_edid = edid;
468 return true;
469}
470
471struct edid *
472radeon_combios_get_hardcoded_edid(struct radeon_device *rdev)
473{
474 if (rdev->mode_info.bios_hardcoded_edid)
475 return rdev->mode_info.bios_hardcoded_edid;
476 return NULL;
477}
478
Alex Deucher6a93cb22009-11-23 17:39:28 -0500479static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev,
480 int ddc_line)
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200481{
482 struct radeon_i2c_bus_rec i2c;
483
Alex Deucher6a93cb22009-11-23 17:39:28 -0500484 if (ddc_line == RADEON_GPIOPAD_MASK) {
485 i2c.mask_clk_reg = RADEON_GPIOPAD_MASK;
486 i2c.mask_data_reg = RADEON_GPIOPAD_MASK;
487 i2c.a_clk_reg = RADEON_GPIOPAD_A;
488 i2c.a_data_reg = RADEON_GPIOPAD_A;
489 i2c.en_clk_reg = RADEON_GPIOPAD_EN;
490 i2c.en_data_reg = RADEON_GPIOPAD_EN;
491 i2c.y_clk_reg = RADEON_GPIOPAD_Y;
492 i2c.y_data_reg = RADEON_GPIOPAD_Y;
493 } else if (ddc_line == RADEON_MDGPIO_MASK) {
494 i2c.mask_clk_reg = RADEON_MDGPIO_MASK;
495 i2c.mask_data_reg = RADEON_MDGPIO_MASK;
496 i2c.a_clk_reg = RADEON_MDGPIO_A;
497 i2c.a_data_reg = RADEON_MDGPIO_A;
498 i2c.en_clk_reg = RADEON_MDGPIO_EN;
499 i2c.en_data_reg = RADEON_MDGPIO_EN;
500 i2c.y_clk_reg = RADEON_MDGPIO_Y;
501 i2c.y_data_reg = RADEON_MDGPIO_Y;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200502 } else {
Alex Deucher6a93cb22009-11-23 17:39:28 -0500503 i2c.mask_clk_mask = RADEON_GPIO_EN_1;
504 i2c.mask_data_mask = RADEON_GPIO_EN_0;
505 i2c.a_clk_mask = RADEON_GPIO_A_1;
506 i2c.a_data_mask = RADEON_GPIO_A_0;
507 i2c.en_clk_mask = RADEON_GPIO_EN_1;
508 i2c.en_data_mask = RADEON_GPIO_EN_0;
509 i2c.y_clk_mask = RADEON_GPIO_Y_1;
510 i2c.y_data_mask = RADEON_GPIO_Y_0;
511
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200512 i2c.mask_clk_reg = ddc_line;
513 i2c.mask_data_reg = ddc_line;
514 i2c.a_clk_reg = ddc_line;
515 i2c.a_data_reg = ddc_line;
Alex Deucher9b9fe722009-11-10 15:59:44 -0500516 i2c.en_clk_reg = ddc_line;
517 i2c.en_data_reg = ddc_line;
518 i2c.y_clk_reg = ddc_line;
519 i2c.y_data_reg = ddc_line;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200520 }
521
Alex Deucher40bacf12009-12-23 03:23:21 -0500522 switch (rdev->family) {
523 case CHIP_R100:
524 case CHIP_RV100:
525 case CHIP_RS100:
526 case CHIP_RV200:
527 case CHIP_RS200:
528 case CHIP_RS300:
529 switch (ddc_line) {
530 case RADEON_GPIO_DVI_DDC:
531 /* in theory this should be hw capable,
532 * but it doesn't seem to work
533 */
534 i2c.hw_capable = false;
535 break;
536 default:
537 i2c.hw_capable = false;
538 break;
539 }
540 break;
541 case CHIP_R200:
542 switch (ddc_line) {
543 case RADEON_GPIO_DVI_DDC:
544 case RADEON_GPIO_MONID:
545 i2c.hw_capable = true;
546 break;
547 default:
548 i2c.hw_capable = false;
549 break;
550 }
551 break;
552 case CHIP_RV250:
553 case CHIP_RV280:
554 switch (ddc_line) {
555 case RADEON_GPIO_VGA_DDC:
556 case RADEON_GPIO_DVI_DDC:
557 case RADEON_GPIO_CRT2_DDC:
558 i2c.hw_capable = true;
559 break;
560 default:
561 i2c.hw_capable = false;
562 break;
563 }
564 break;
565 case CHIP_R300:
566 case CHIP_R350:
567 switch (ddc_line) {
568 case RADEON_GPIO_VGA_DDC:
569 case RADEON_GPIO_DVI_DDC:
570 i2c.hw_capable = true;
571 break;
572 default:
573 i2c.hw_capable = false;
574 break;
575 }
576 break;
577 case CHIP_RV350:
578 case CHIP_RV380:
579 case CHIP_RS400:
580 case CHIP_RS480:
Alex Deucher6a93cb22009-11-23 17:39:28 -0500581 switch (ddc_line) {
582 case RADEON_GPIO_VGA_DDC:
583 case RADEON_GPIO_DVI_DDC:
584 i2c.hw_capable = true;
585 break;
586 case RADEON_GPIO_MONID:
587 /* hw i2c on RADEON_GPIO_MONID doesn't seem to work
588 * reliably on some pre-r4xx hardware; not sure why.
589 */
590 i2c.hw_capable = false;
591 break;
592 default:
593 i2c.hw_capable = false;
594 break;
595 }
Alex Deucher40bacf12009-12-23 03:23:21 -0500596 break;
597 default:
598 i2c.hw_capable = false;
599 break;
Alex Deucher6a93cb22009-11-23 17:39:28 -0500600 }
601 i2c.mm_i2c = false;
602 i2c.i2c_id = 0;
Alex Deucherbcc1c2a2010-01-12 17:54:34 -0500603 i2c.hpd_id = 0;
Alex Deucher6a93cb22009-11-23 17:39:28 -0500604
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200605 if (ddc_line)
606 i2c.valid = true;
607 else
608 i2c.valid = false;
609
610 return i2c;
611}
612
613bool radeon_combios_get_clock_info(struct drm_device *dev)
614{
615 struct radeon_device *rdev = dev->dev_private;
616 uint16_t pll_info;
617 struct radeon_pll *p1pll = &rdev->clock.p1pll;
618 struct radeon_pll *p2pll = &rdev->clock.p2pll;
619 struct radeon_pll *spll = &rdev->clock.spll;
620 struct radeon_pll *mpll = &rdev->clock.mpll;
621 int8_t rev;
622 uint16_t sclk, mclk;
623
624 if (rdev->bios == NULL)
Dave Airlie4b30b872009-12-01 09:13:40 +1000625 return false;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200626
627 pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE);
628 if (pll_info) {
629 rev = RBIOS8(pll_info);
630
631 /* pixel clocks */
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
637 if (rev > 9) {
638 p1pll->pll_in_min = RBIOS32(pll_info + 0x36);
639 p1pll->pll_in_max = RBIOS32(pll_info + 0x3a);
640 } else {
641 p1pll->pll_in_min = 40;
642 p1pll->pll_in_max = 500;
643 }
644 *p2pll = *p1pll;
645
646 /* system clock */
647 spll->reference_freq = RBIOS16(pll_info + 0x1a);
648 spll->reference_div = RBIOS16(pll_info + 0x1c);
649 spll->pll_out_min = RBIOS32(pll_info + 0x1e);
650 spll->pll_out_max = RBIOS32(pll_info + 0x22);
651
652 if (rev > 10) {
653 spll->pll_in_min = RBIOS32(pll_info + 0x48);
654 spll->pll_in_max = RBIOS32(pll_info + 0x4c);
655 } else {
656 /* ??? */
657 spll->pll_in_min = 40;
658 spll->pll_in_max = 500;
659 }
660
661 /* memory clock */
662 mpll->reference_freq = RBIOS16(pll_info + 0x26);
663 mpll->reference_div = RBIOS16(pll_info + 0x28);
664 mpll->pll_out_min = RBIOS32(pll_info + 0x2a);
665 mpll->pll_out_max = RBIOS32(pll_info + 0x2e);
666
667 if (rev > 10) {
668 mpll->pll_in_min = RBIOS32(pll_info + 0x5a);
669 mpll->pll_in_max = RBIOS32(pll_info + 0x5e);
670 } else {
671 /* ??? */
672 mpll->pll_in_min = 40;
673 mpll->pll_in_max = 500;
674 }
675
676 /* default sclk/mclk */
677 sclk = RBIOS16(pll_info + 0xa);
678 mclk = RBIOS16(pll_info + 0x8);
679 if (sclk == 0)
680 sclk = 200 * 100;
681 if (mclk == 0)
682 mclk = 200 * 100;
683
684 rdev->clock.default_sclk = sclk;
685 rdev->clock.default_mclk = mclk;
686
687 return true;
688 }
689 return false;
690}
691
Alex Deucher06b64762010-01-05 11:27:29 -0500692bool radeon_combios_sideport_present(struct radeon_device *rdev)
693{
694 struct drm_device *dev = rdev->ddev;
695 u16 igp_info;
696
697 igp_info = combios_get_table_offset(dev, COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE);
698
699 if (igp_info) {
700 if (RBIOS16(igp_info + 0x4))
701 return true;
702 }
703 return false;
704}
705
Alex Deucher246263c2009-12-29 12:09:17 -0500706static const uint32_t default_primarydac_adj[CHIP_LAST] = {
707 0x00000808, /* r100 */
708 0x00000808, /* rv100 */
709 0x00000808, /* rs100 */
710 0x00000808, /* rv200 */
711 0x00000808, /* rs200 */
712 0x00000808, /* r200 */
713 0x00000808, /* rv250 */
714 0x00000000, /* rs300 */
715 0x00000808, /* rv280 */
716 0x00000808, /* r300 */
717 0x00000808, /* r350 */
718 0x00000808, /* rv350 */
719 0x00000808, /* rv380 */
720 0x00000808, /* r420 */
721 0x00000808, /* r423 */
722 0x00000808, /* rv410 */
723 0x00000000, /* rs400 */
724 0x00000000, /* rs480 */
725};
726
727static void radeon_legacy_get_primary_dac_info_from_table(struct radeon_device *rdev,
728 struct radeon_encoder_primary_dac *p_dac)
729{
730 p_dac->ps2_pdac_adj = default_primarydac_adj[rdev->family];
731 return;
732}
733
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200734struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct
735 radeon_encoder
736 *encoder)
737{
738 struct drm_device *dev = encoder->base.dev;
739 struct radeon_device *rdev = dev->dev_private;
740 uint16_t dac_info;
741 uint8_t rev, bg, dac;
742 struct radeon_encoder_primary_dac *p_dac = NULL;
Alex Deucher246263c2009-12-29 12:09:17 -0500743 int found = 0;
744
745 p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac),
746 GFP_KERNEL);
747
748 if (!p_dac)
749 return NULL;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200750
751 if (rdev->bios == NULL)
Alex Deucher246263c2009-12-29 12:09:17 -0500752 goto out;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200753
754 /* check CRT table */
755 dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
756 if (dac_info) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200757 rev = RBIOS8(dac_info) & 0x3;
758 if (rev < 2) {
759 bg = RBIOS8(dac_info + 0x2) & 0xf;
760 dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf;
761 p_dac->ps2_pdac_adj = (bg << 8) | (dac);
762 } else {
763 bg = RBIOS8(dac_info + 0x2) & 0xf;
764 dac = RBIOS8(dac_info + 0x3) & 0xf;
765 p_dac->ps2_pdac_adj = (bg << 8) | (dac);
766 }
Alex Deucher246263c2009-12-29 12:09:17 -0500767 found = 1;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200768 }
769
Alex Deucher246263c2009-12-29 12:09:17 -0500770out:
771 if (!found) /* fallback to defaults */
772 radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac);
773
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200774 return p_dac;
775}
776
Alex Deucherd79766f2009-12-17 19:00:29 -0500777enum radeon_tv_std
778radeon_combios_get_tv_info(struct radeon_device *rdev)
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200779{
Alex Deucherd79766f2009-12-17 19:00:29 -0500780 struct drm_device *dev = rdev->ddev;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200781 uint16_t tv_info;
782 enum radeon_tv_std tv_std = TV_STD_NTSC;
783
Michel Dänzer11f3b592010-01-11 08:58:38 +0100784 if (rdev->bios == NULL)
785 return tv_std;
786
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200787 tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
788 if (tv_info) {
789 if (RBIOS8(tv_info + 6) == 'T') {
790 switch (RBIOS8(tv_info + 7) & 0xf) {
791 case 1:
792 tv_std = TV_STD_NTSC;
793 DRM_INFO("Default TV standard: NTSC\n");
794 break;
795 case 2:
796 tv_std = TV_STD_PAL;
797 DRM_INFO("Default TV standard: PAL\n");
798 break;
799 case 3:
800 tv_std = TV_STD_PAL_M;
801 DRM_INFO("Default TV standard: PAL-M\n");
802 break;
803 case 4:
804 tv_std = TV_STD_PAL_60;
805 DRM_INFO("Default TV standard: PAL-60\n");
806 break;
807 case 5:
808 tv_std = TV_STD_NTSC_J;
809 DRM_INFO("Default TV standard: NTSC-J\n");
810 break;
811 case 6:
812 tv_std = TV_STD_SCART_PAL;
813 DRM_INFO("Default TV standard: SCART-PAL\n");
814 break;
815 default:
816 tv_std = TV_STD_NTSC;
817 DRM_INFO
818 ("Unknown TV standard; defaulting to NTSC\n");
819 break;
820 }
821
822 switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) {
823 case 0:
824 DRM_INFO("29.498928713 MHz TV ref clk\n");
825 break;
826 case 1:
827 DRM_INFO("28.636360000 MHz TV ref clk\n");
828 break;
829 case 2:
830 DRM_INFO("14.318180000 MHz TV ref clk\n");
831 break;
832 case 3:
833 DRM_INFO("27.000000000 MHz TV ref clk\n");
834 break;
835 default:
836 break;
837 }
838 }
839 }
840 return tv_std;
841}
842
843static const uint32_t default_tvdac_adj[CHIP_LAST] = {
844 0x00000000, /* r100 */
845 0x00280000, /* rv100 */
846 0x00000000, /* rs100 */
847 0x00880000, /* rv200 */
848 0x00000000, /* rs200 */
849 0x00000000, /* r200 */
850 0x00770000, /* rv250 */
851 0x00290000, /* rs300 */
852 0x00560000, /* rv280 */
853 0x00780000, /* r300 */
854 0x00770000, /* r350 */
855 0x00780000, /* rv350 */
856 0x00780000, /* rv380 */
857 0x01080000, /* r420 */
858 0x01080000, /* r423 */
859 0x01080000, /* rv410 */
860 0x00780000, /* rs400 */
861 0x00780000, /* rs480 */
862};
863
Dave Airlie6a719e02009-08-17 10:19:51 +1000864static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev,
865 struct radeon_encoder_tv_dac *tv_dac)
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200866{
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200867 tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family];
868 if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250))
869 tv_dac->ps2_tvdac_adj = 0x00880000;
870 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
871 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
Dave Airlie6a719e02009-08-17 10:19:51 +1000872 return;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200873}
874
875struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
876 radeon_encoder
877 *encoder)
878{
879 struct drm_device *dev = encoder->base.dev;
880 struct radeon_device *rdev = dev->dev_private;
881 uint16_t dac_info;
882 uint8_t rev, bg, dac;
883 struct radeon_encoder_tv_dac *tv_dac = NULL;
Dave Airlie6a719e02009-08-17 10:19:51 +1000884 int found = 0;
885
886 tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
887 if (!tv_dac)
888 return NULL;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200889
890 if (rdev->bios == NULL)
Dave Airlie6a719e02009-08-17 10:19:51 +1000891 goto out;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200892
893 /* first check TV table */
894 dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
895 if (dac_info) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200896 rev = RBIOS8(dac_info + 0x3);
897 if (rev > 4) {
898 bg = RBIOS8(dac_info + 0xc) & 0xf;
899 dac = RBIOS8(dac_info + 0xd) & 0xf;
900 tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
901
902 bg = RBIOS8(dac_info + 0xe) & 0xf;
903 dac = RBIOS8(dac_info + 0xf) & 0xf;
904 tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
905
906 bg = RBIOS8(dac_info + 0x10) & 0xf;
907 dac = RBIOS8(dac_info + 0x11) & 0xf;
908 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
Dave Airlie6a719e02009-08-17 10:19:51 +1000909 found = 1;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200910 } else if (rev > 1) {
911 bg = RBIOS8(dac_info + 0xc) & 0xf;
912 dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf;
913 tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
914
915 bg = RBIOS8(dac_info + 0xd) & 0xf;
916 dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf;
917 tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
918
919 bg = RBIOS8(dac_info + 0xe) & 0xf;
920 dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf;
921 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
Dave Airlie6a719e02009-08-17 10:19:51 +1000922 found = 1;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200923 }
Alex Deucherd79766f2009-12-17 19:00:29 -0500924 tv_dac->tv_std = radeon_combios_get_tv_info(rdev);
Dave Airlie6a719e02009-08-17 10:19:51 +1000925 }
926 if (!found) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200927 /* then check CRT table */
928 dac_info =
929 combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
930 if (dac_info) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200931 rev = RBIOS8(dac_info) & 0x3;
932 if (rev < 2) {
933 bg = RBIOS8(dac_info + 0x3) & 0xf;
934 dac = (RBIOS8(dac_info + 0x3) >> 4) & 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;
Dave Airlie6a719e02009-08-17 10:19:51 +1000939 found = 1;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200940 } else {
941 bg = RBIOS8(dac_info + 0x4) & 0xf;
942 dac = RBIOS8(dac_info + 0x5) & 0xf;
943 tv_dac->ps2_tvdac_adj =
944 (bg << 16) | (dac << 20);
945 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
946 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
Dave Airlie6a719e02009-08-17 10:19:51 +1000947 found = 1;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200948 }
Alex Deucher6fe7ac32009-06-12 17:26:08 +0000949 } else {
950 DRM_INFO("No TV DAC info found in BIOS\n");
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200951 }
952 }
953
Dave Airlie6a719e02009-08-17 10:19:51 +1000954out:
955 if (!found) /* fallback to defaults */
956 radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac);
957
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200958 return tv_dac;
959}
960
961static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct
962 radeon_device
963 *rdev)
964{
965 struct radeon_encoder_lvds *lvds = NULL;
966 uint32_t fp_vert_stretch, fp_horz_stretch;
967 uint32_t ppll_div_sel, ppll_val;
Michel Dänzer8b5c7442009-06-17 18:28:38 +0200968 uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200969
970 lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL);
971
972 if (!lvds)
973 return NULL;
974
975 fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH);
976 fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH);
977
Michel Dänzer8b5c7442009-06-17 18:28:38 +0200978 /* These should be fail-safe defaults, fingers crossed */
979 lvds->panel_pwr_delay = 200;
980 lvds->panel_vcc_delay = 2000;
981
982 lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL);
983 lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf;
984 lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf;
985
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200986 if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE)
Alex Deucherde2103e2009-10-09 15:14:30 -0400987 lvds->native_mode.vdisplay =
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200988 ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >>
989 RADEON_VERT_PANEL_SHIFT) + 1;
990 else
Alex Deucherde2103e2009-10-09 15:14:30 -0400991 lvds->native_mode.vdisplay =
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200992 (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1;
993
994 if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE)
Alex Deucherde2103e2009-10-09 15:14:30 -0400995 lvds->native_mode.hdisplay =
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200996 (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >>
997 RADEON_HORZ_PANEL_SHIFT) + 1) * 8;
998 else
Alex Deucherde2103e2009-10-09 15:14:30 -0400999 lvds->native_mode.hdisplay =
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001000 ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8;
1001
Alex Deucherde2103e2009-10-09 15:14:30 -04001002 if ((lvds->native_mode.hdisplay < 640) ||
1003 (lvds->native_mode.vdisplay < 480)) {
1004 lvds->native_mode.hdisplay = 640;
1005 lvds->native_mode.vdisplay = 480;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001006 }
1007
1008 ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3;
1009 ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel);
1010 if ((ppll_val & 0x000707ff) == 0x1bb)
1011 lvds->use_bios_dividers = false;
1012 else {
1013 lvds->panel_ref_divider =
1014 RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff;
1015 lvds->panel_post_divider = (ppll_val >> 16) & 0x7;
1016 lvds->panel_fb_divider = ppll_val & 0x7ff;
1017
1018 if ((lvds->panel_ref_divider != 0) &&
1019 (lvds->panel_fb_divider > 3))
1020 lvds->use_bios_dividers = true;
1021 }
1022 lvds->panel_vcc_delay = 200;
1023
1024 DRM_INFO("Panel info derived from registers\n");
Alex Deucherde2103e2009-10-09 15:14:30 -04001025 DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
1026 lvds->native_mode.vdisplay);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001027
1028 return lvds;
1029}
1030
1031struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder
1032 *encoder)
1033{
1034 struct drm_device *dev = encoder->base.dev;
1035 struct radeon_device *rdev = dev->dev_private;
1036 uint16_t lcd_info;
1037 uint32_t panel_setup;
1038 char stmp[30];
1039 int tmp, i;
1040 struct radeon_encoder_lvds *lvds = NULL;
1041
Michel Dänzer8dfaa8a2009-09-15 17:09:27 +02001042 if (rdev->bios == NULL) {
1043 lvds = radeon_legacy_get_lvds_info_from_regs(rdev);
1044 goto out;
1045 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001046
1047 lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE);
1048
1049 if (lcd_info) {
1050 lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL);
1051
1052 if (!lvds)
1053 return NULL;
1054
1055 for (i = 0; i < 24; i++)
1056 stmp[i] = RBIOS8(lcd_info + i + 1);
1057 stmp[24] = 0;
1058
1059 DRM_INFO("Panel ID String: %s\n", stmp);
1060
Alex Deucherde2103e2009-10-09 15:14:30 -04001061 lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19);
1062 lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001063
Alex Deucherde2103e2009-10-09 15:14:30 -04001064 DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
1065 lvds->native_mode.vdisplay);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001066
1067 lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c);
Andrew Morton94cf6432010-02-02 14:40:29 -08001068 lvds->panel_vcc_delay = min_t(u16, lvds->panel_vcc_delay, 2000);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001069
1070 lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24);
1071 lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf;
1072 lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf;
1073
1074 lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e);
1075 lvds->panel_post_divider = RBIOS8(lcd_info + 0x30);
1076 lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31);
1077 if ((lvds->panel_ref_divider != 0) &&
1078 (lvds->panel_fb_divider > 3))
1079 lvds->use_bios_dividers = true;
1080
1081 panel_setup = RBIOS32(lcd_info + 0x39);
1082 lvds->lvds_gen_cntl = 0xff00;
1083 if (panel_setup & 0x1)
1084 lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT;
1085
1086 if ((panel_setup >> 4) & 0x1)
1087 lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE;
1088
1089 switch ((panel_setup >> 8) & 0x7) {
1090 case 0:
1091 lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM;
1092 break;
1093 case 1:
1094 lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY;
1095 break;
1096 case 2:
1097 lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY;
1098 break;
1099 default:
1100 break;
1101 }
1102
1103 if ((panel_setup >> 16) & 0x1)
1104 lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW;
1105
1106 if ((panel_setup >> 17) & 0x1)
1107 lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW;
1108
1109 if ((panel_setup >> 18) & 0x1)
1110 lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW;
1111
1112 if ((panel_setup >> 23) & 0x1)
1113 lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL;
1114
1115 lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000);
1116
1117 for (i = 0; i < 32; i++) {
1118 tmp = RBIOS16(lcd_info + 64 + i * 2);
1119 if (tmp == 0)
1120 break;
1121
Alex Deucherde2103e2009-10-09 15:14:30 -04001122 if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) &&
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001123 (RBIOS16(tmp + 2) ==
Alex Deucherde2103e2009-10-09 15:14:30 -04001124 lvds->native_mode.vdisplay)) {
1125 lvds->native_mode.htotal = RBIOS16(tmp + 17) * 8;
1126 lvds->native_mode.hsync_start = RBIOS16(tmp + 21) * 8;
1127 lvds->native_mode.hsync_end = (RBIOS8(tmp + 23) +
1128 RBIOS16(tmp + 21)) * 8;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001129
Alex Deucherde2103e2009-10-09 15:14:30 -04001130 lvds->native_mode.vtotal = RBIOS16(tmp + 24);
1131 lvds->native_mode.vsync_start = RBIOS16(tmp + 28) & 0x7ff;
1132 lvds->native_mode.vsync_end =
1133 ((RBIOS16(tmp + 28) & 0xf800) >> 11) +
1134 (RBIOS16(tmp + 28) & 0x7ff);
1135
1136 lvds->native_mode.clock = RBIOS16(tmp + 9) * 10;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001137 lvds->native_mode.flags = 0;
Alex Deucherde2103e2009-10-09 15:14:30 -04001138 /* set crtc values */
1139 drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V);
1140
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001141 }
1142 }
Alex Deucher6fe7ac32009-06-12 17:26:08 +00001143 } else {
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001144 DRM_INFO("No panel info found in BIOS\n");
Michel Dänzer8dfaa8a2009-09-15 17:09:27 +02001145 lvds = radeon_legacy_get_lvds_info_from_regs(rdev);
Alex Deucher6fe7ac32009-06-12 17:26:08 +00001146 }
Michel Dänzer8dfaa8a2009-09-15 17:09:27 +02001147out:
1148 if (lvds)
1149 encoder->native_mode = lvds->native_mode;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001150 return lvds;
1151}
1152
1153static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = {
1154 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */
1155 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */
1156 {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */
1157 {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */
1158 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */
1159 {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */
1160 {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */
1161 {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */
1162 {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */
1163 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */
1164 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */
1165 {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */
1166 {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */
1167 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */
1168 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */
1169 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */
Alex Deucherfcec5702009-11-10 21:25:07 -05001170 { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */
1171 { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001172};
1173
Dave Airlie445282d2009-09-09 17:40:54 +10001174bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder,
1175 struct radeon_encoder_int_tmds *tmds)
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001176{
Dave Airlie445282d2009-09-09 17:40:54 +10001177 struct drm_device *dev = encoder->base.dev;
1178 struct radeon_device *rdev = dev->dev_private;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001179 int i;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001180
1181 for (i = 0; i < 4; i++) {
1182 tmds->tmds_pll[i].value =
Dave Airlie445282d2009-09-09 17:40:54 +10001183 default_tmds_pll[rdev->family][i].value;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001184 tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq;
1185 }
1186
Dave Airlie445282d2009-09-09 17:40:54 +10001187 return true;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001188}
1189
Dave Airlie445282d2009-09-09 17:40:54 +10001190bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder,
1191 struct radeon_encoder_int_tmds *tmds)
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001192{
1193 struct drm_device *dev = encoder->base.dev;
1194 struct radeon_device *rdev = dev->dev_private;
1195 uint16_t tmds_info;
1196 int i, n;
1197 uint8_t ver;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001198
1199 if (rdev->bios == NULL)
Dave Airlie445282d2009-09-09 17:40:54 +10001200 return false;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001201
1202 tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE);
1203
1204 if (tmds_info) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001205 ver = RBIOS8(tmds_info);
1206 DRM_INFO("DFP table revision: %d\n", ver);
1207 if (ver == 3) {
1208 n = RBIOS8(tmds_info + 5) + 1;
1209 if (n > 4)
1210 n = 4;
1211 for (i = 0; i < n; i++) {
1212 tmds->tmds_pll[i].value =
1213 RBIOS32(tmds_info + i * 10 + 0x08);
1214 tmds->tmds_pll[i].freq =
1215 RBIOS16(tmds_info + i * 10 + 0x10);
1216 DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n",
1217 tmds->tmds_pll[i].freq,
1218 tmds->tmds_pll[i].value);
1219 }
1220 } else if (ver == 4) {
1221 int stride = 0;
1222 n = RBIOS8(tmds_info + 5) + 1;
1223 if (n > 4)
1224 n = 4;
1225 for (i = 0; i < n; i++) {
1226 tmds->tmds_pll[i].value =
1227 RBIOS32(tmds_info + stride + 0x08);
1228 tmds->tmds_pll[i].freq =
1229 RBIOS16(tmds_info + stride + 0x10);
1230 if (i == 0)
1231 stride += 10;
1232 else
1233 stride += 6;
1234 DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n",
1235 tmds->tmds_pll[i].freq,
1236 tmds->tmds_pll[i].value);
1237 }
1238 }
Alex Deucherfcec5702009-11-10 21:25:07 -05001239 } else {
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001240 DRM_INFO("No TMDS info found in BIOS\n");
Alex Deucherfcec5702009-11-10 21:25:07 -05001241 return false;
1242 }
Dave Airlie445282d2009-09-09 17:40:54 +10001243 return true;
1244}
1245
Alex Deucherfcec5702009-11-10 21:25:07 -05001246bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder,
1247 struct radeon_encoder_ext_tmds *tmds)
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001248{
1249 struct drm_device *dev = encoder->base.dev;
1250 struct radeon_device *rdev = dev->dev_private;
Alex Deucherfcec5702009-11-10 21:25:07 -05001251 struct radeon_i2c_bus_rec i2c_bus;
1252
1253 /* default for macs */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001254 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
Alex Deucherfcec5702009-11-10 21:25:07 -05001255 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1256
1257 /* XXX some macs have duallink chips */
1258 switch (rdev->mode_info.connector_table) {
1259 case CT_POWERBOOK_EXTERNAL:
1260 case CT_MINI_EXTERNAL:
1261 default:
1262 tmds->dvo_chip = DVO_SIL164;
1263 tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */
1264 break;
1265 }
1266
1267 return true;
1268}
1269
1270bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder,
1271 struct radeon_encoder_ext_tmds *tmds)
1272{
1273 struct drm_device *dev = encoder->base.dev;
1274 struct radeon_device *rdev = dev->dev_private;
1275 uint16_t offset;
1276 uint8_t ver, id, blocks, clk, data;
1277 int i;
1278 enum radeon_combios_ddc gpio;
1279 struct radeon_i2c_bus_rec i2c_bus;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001280
1281 if (rdev->bios == NULL)
Alex Deucherfcec5702009-11-10 21:25:07 -05001282 return false;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001283
Alex Deucherfcec5702009-11-10 21:25:07 -05001284 tmds->i2c_bus = NULL;
1285 if (rdev->flags & RADEON_IS_IGP) {
1286 offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE);
1287 if (offset) {
1288 ver = RBIOS8(offset);
1289 DRM_INFO("GPIO Table revision: %d\n", ver);
1290 blocks = RBIOS8(offset + 2);
1291 for (i = 0; i < blocks; i++) {
1292 id = RBIOS8(offset + 3 + (i * 5) + 0);
1293 if (id == 136) {
1294 clk = RBIOS8(offset + 3 + (i * 5) + 3);
1295 data = RBIOS8(offset + 3 + (i * 5) + 4);
1296 i2c_bus.valid = true;
1297 i2c_bus.mask_clk_mask = (1 << clk);
1298 i2c_bus.mask_data_mask = (1 << data);
1299 i2c_bus.a_clk_mask = (1 << clk);
1300 i2c_bus.a_data_mask = (1 << data);
1301 i2c_bus.en_clk_mask = (1 << clk);
1302 i2c_bus.en_data_mask = (1 << data);
1303 i2c_bus.y_clk_mask = (1 << clk);
1304 i2c_bus.y_data_mask = (1 << data);
1305 i2c_bus.mask_clk_reg = RADEON_GPIOPAD_MASK;
1306 i2c_bus.mask_data_reg = RADEON_GPIOPAD_MASK;
1307 i2c_bus.a_clk_reg = RADEON_GPIOPAD_A;
1308 i2c_bus.a_data_reg = RADEON_GPIOPAD_A;
1309 i2c_bus.en_clk_reg = RADEON_GPIOPAD_EN;
1310 i2c_bus.en_data_reg = RADEON_GPIOPAD_EN;
1311 i2c_bus.y_clk_reg = RADEON_GPIOPAD_Y;
1312 i2c_bus.y_data_reg = RADEON_GPIOPAD_Y;
1313 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1314 tmds->dvo_chip = DVO_SIL164;
1315 tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */
1316 break;
1317 }
1318 }
1319 }
1320 } else {
1321 offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
1322 if (offset) {
1323 ver = RBIOS8(offset);
1324 DRM_INFO("External TMDS Table revision: %d\n", ver);
1325 tmds->slave_addr = RBIOS8(offset + 4 + 2);
1326 tmds->slave_addr >>= 1; /* 7 bit addressing */
1327 gpio = RBIOS8(offset + 4 + 3);
1328 switch (gpio) {
1329 case DDC_MONID:
Alex Deucher6a93cb22009-11-23 17:39:28 -05001330 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
Alex Deucherfcec5702009-11-10 21:25:07 -05001331 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1332 break;
1333 case DDC_DVI:
Alex Deucher6a93cb22009-11-23 17:39:28 -05001334 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
Alex Deucherfcec5702009-11-10 21:25:07 -05001335 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1336 break;
1337 case DDC_VGA:
Alex Deucher6a93cb22009-11-23 17:39:28 -05001338 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
Alex Deucherfcec5702009-11-10 21:25:07 -05001339 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1340 break;
1341 case DDC_CRT2:
1342 /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */
1343 if (rdev->family >= CHIP_R300)
Alex Deucher6a93cb22009-11-23 17:39:28 -05001344 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
Alex Deucherfcec5702009-11-10 21:25:07 -05001345 else
Alex Deucher6a93cb22009-11-23 17:39:28 -05001346 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
Alex Deucherfcec5702009-11-10 21:25:07 -05001347 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1348 break;
1349 case DDC_LCD: /* MM i2c */
Alex Deucher40bacf12009-12-23 03:23:21 -05001350 i2c_bus.valid = true;
1351 i2c_bus.hw_capable = true;
1352 i2c_bus.mm_i2c = true;
1353 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
Alex Deucherfcec5702009-11-10 21:25:07 -05001354 break;
1355 default:
1356 DRM_ERROR("Unsupported gpio %d\n", gpio);
1357 break;
1358 }
1359 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001360 }
Alex Deucherfcec5702009-11-10 21:25:07 -05001361
1362 if (!tmds->i2c_bus) {
1363 DRM_INFO("No valid Ext TMDS info found in BIOS\n");
1364 return false;
1365 }
1366
1367 return true;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001368}
1369
1370bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1371{
1372 struct radeon_device *rdev = dev->dev_private;
1373 struct radeon_i2c_bus_rec ddc_i2c;
Alex Deuchereed45b32009-12-04 14:45:27 -05001374 struct radeon_hpd hpd;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001375
1376 rdev->mode_info.connector_table = radeon_connector_table;
1377 if (rdev->mode_info.connector_table == CT_NONE) {
1378#ifdef CONFIG_PPC_PMAC
1379 if (machine_is_compatible("PowerBook3,3")) {
1380 /* powerbook with VGA */
1381 rdev->mode_info.connector_table = CT_POWERBOOK_VGA;
1382 } else if (machine_is_compatible("PowerBook3,4") ||
1383 machine_is_compatible("PowerBook3,5")) {
1384 /* powerbook with internal tmds */
1385 rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL;
1386 } else if (machine_is_compatible("PowerBook5,1") ||
1387 machine_is_compatible("PowerBook5,2") ||
1388 machine_is_compatible("PowerBook5,3") ||
1389 machine_is_compatible("PowerBook5,4") ||
1390 machine_is_compatible("PowerBook5,5")) {
1391 /* powerbook with external single link tmds (sil164) */
1392 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
1393 } else if (machine_is_compatible("PowerBook5,6")) {
1394 /* powerbook with external dual or single link tmds */
1395 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
1396 } else if (machine_is_compatible("PowerBook5,7") ||
1397 machine_is_compatible("PowerBook5,8") ||
1398 machine_is_compatible("PowerBook5,9")) {
1399 /* PowerBook6,2 ? */
1400 /* powerbook with external dual link tmds (sil1178?) */
1401 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
1402 } else if (machine_is_compatible("PowerBook4,1") ||
1403 machine_is_compatible("PowerBook4,2") ||
1404 machine_is_compatible("PowerBook4,3") ||
1405 machine_is_compatible("PowerBook6,3") ||
1406 machine_is_compatible("PowerBook6,5") ||
1407 machine_is_compatible("PowerBook6,7")) {
1408 /* ibook */
1409 rdev->mode_info.connector_table = CT_IBOOK;
1410 } else if (machine_is_compatible("PowerMac4,4")) {
1411 /* emac */
1412 rdev->mode_info.connector_table = CT_EMAC;
1413 } else if (machine_is_compatible("PowerMac10,1")) {
1414 /* mini with internal tmds */
1415 rdev->mode_info.connector_table = CT_MINI_INTERNAL;
1416 } else if (machine_is_compatible("PowerMac10,2")) {
1417 /* mini with external tmds */
1418 rdev->mode_info.connector_table = CT_MINI_EXTERNAL;
1419 } else if (machine_is_compatible("PowerMac12,1")) {
1420 /* PowerMac8,1 ? */
1421 /* imac g5 isight */
1422 rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT;
1423 } else
1424#endif /* CONFIG_PPC_PMAC */
1425 rdev->mode_info.connector_table = CT_GENERIC;
1426 }
1427
1428 switch (rdev->mode_info.connector_table) {
1429 case CT_GENERIC:
1430 DRM_INFO("Connector Table: %d (generic)\n",
1431 rdev->mode_info.connector_table);
1432 /* these are the most common settings */
1433 if (rdev->flags & RADEON_SINGLE_CRTC) {
1434 /* VGA - primary dac */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001435 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001436 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001437 radeon_add_legacy_encoder(dev,
1438 radeon_get_encoder_id(dev,
1439 ATOM_DEVICE_CRT1_SUPPORT,
1440 1),
1441 ATOM_DEVICE_CRT1_SUPPORT);
1442 radeon_add_legacy_connector(dev, 0,
1443 ATOM_DEVICE_CRT1_SUPPORT,
1444 DRM_MODE_CONNECTOR_VGA,
Alex Deucherb75fad02009-11-05 13:16:01 -05001445 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001446 CONNECTOR_OBJECT_ID_VGA,
1447 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001448 } else if (rdev->flags & RADEON_IS_MOBILITY) {
1449 /* LVDS */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001450 ddc_i2c = combios_setup_i2c_bus(rdev, 0);
Alex Deuchereed45b32009-12-04 14:45:27 -05001451 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001452 radeon_add_legacy_encoder(dev,
1453 radeon_get_encoder_id(dev,
1454 ATOM_DEVICE_LCD1_SUPPORT,
1455 0),
1456 ATOM_DEVICE_LCD1_SUPPORT);
1457 radeon_add_legacy_connector(dev, 0,
1458 ATOM_DEVICE_LCD1_SUPPORT,
1459 DRM_MODE_CONNECTOR_LVDS,
Alex Deucherb75fad02009-11-05 13:16:01 -05001460 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001461 CONNECTOR_OBJECT_ID_LVDS,
1462 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001463
1464 /* VGA - primary dac */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001465 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001466 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001467 radeon_add_legacy_encoder(dev,
1468 radeon_get_encoder_id(dev,
1469 ATOM_DEVICE_CRT1_SUPPORT,
1470 1),
1471 ATOM_DEVICE_CRT1_SUPPORT);
1472 radeon_add_legacy_connector(dev, 1,
1473 ATOM_DEVICE_CRT1_SUPPORT,
1474 DRM_MODE_CONNECTOR_VGA,
Alex Deucherb75fad02009-11-05 13:16:01 -05001475 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001476 CONNECTOR_OBJECT_ID_VGA,
1477 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001478 } else {
1479 /* DVI-I - tv dac, int tmds */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001480 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001481 hpd.hpd = RADEON_HPD_1;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001482 radeon_add_legacy_encoder(dev,
1483 radeon_get_encoder_id(dev,
1484 ATOM_DEVICE_DFP1_SUPPORT,
1485 0),
1486 ATOM_DEVICE_DFP1_SUPPORT);
1487 radeon_add_legacy_encoder(dev,
1488 radeon_get_encoder_id(dev,
1489 ATOM_DEVICE_CRT2_SUPPORT,
1490 2),
1491 ATOM_DEVICE_CRT2_SUPPORT);
1492 radeon_add_legacy_connector(dev, 0,
1493 ATOM_DEVICE_DFP1_SUPPORT |
1494 ATOM_DEVICE_CRT2_SUPPORT,
1495 DRM_MODE_CONNECTOR_DVII,
Alex Deucherb75fad02009-11-05 13:16:01 -05001496 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001497 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1498 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001499
1500 /* VGA - primary dac */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001501 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001502 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001503 radeon_add_legacy_encoder(dev,
1504 radeon_get_encoder_id(dev,
1505 ATOM_DEVICE_CRT1_SUPPORT,
1506 1),
1507 ATOM_DEVICE_CRT1_SUPPORT);
1508 radeon_add_legacy_connector(dev, 1,
1509 ATOM_DEVICE_CRT1_SUPPORT,
1510 DRM_MODE_CONNECTOR_VGA,
Alex Deucherb75fad02009-11-05 13:16:01 -05001511 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001512 CONNECTOR_OBJECT_ID_VGA,
1513 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001514 }
1515
1516 if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) {
1517 /* TV - tv dac */
Alex Deuchereed45b32009-12-04 14:45:27 -05001518 ddc_i2c.valid = false;
1519 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001520 radeon_add_legacy_encoder(dev,
1521 radeon_get_encoder_id(dev,
1522 ATOM_DEVICE_TV1_SUPPORT,
1523 2),
1524 ATOM_DEVICE_TV1_SUPPORT);
1525 radeon_add_legacy_connector(dev, 2,
1526 ATOM_DEVICE_TV1_SUPPORT,
1527 DRM_MODE_CONNECTOR_SVIDEO,
Alex Deucherb75fad02009-11-05 13:16:01 -05001528 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001529 CONNECTOR_OBJECT_ID_SVIDEO,
1530 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001531 }
1532 break;
1533 case CT_IBOOK:
1534 DRM_INFO("Connector Table: %d (ibook)\n",
1535 rdev->mode_info.connector_table);
1536 /* LVDS */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001537 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001538 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001539 radeon_add_legacy_encoder(dev,
1540 radeon_get_encoder_id(dev,
1541 ATOM_DEVICE_LCD1_SUPPORT,
1542 0),
1543 ATOM_DEVICE_LCD1_SUPPORT);
1544 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
Alex Deucherb75fad02009-11-05 13:16:01 -05001545 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001546 CONNECTOR_OBJECT_ID_LVDS,
1547 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001548 /* VGA - TV DAC */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001549 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001550 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001551 radeon_add_legacy_encoder(dev,
1552 radeon_get_encoder_id(dev,
1553 ATOM_DEVICE_CRT2_SUPPORT,
1554 2),
1555 ATOM_DEVICE_CRT2_SUPPORT);
1556 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
Alex Deucherb75fad02009-11-05 13:16:01 -05001557 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001558 CONNECTOR_OBJECT_ID_VGA,
1559 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001560 /* TV - TV DAC */
Alex Deuchereed45b32009-12-04 14:45:27 -05001561 ddc_i2c.valid = false;
1562 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001563 radeon_add_legacy_encoder(dev,
1564 radeon_get_encoder_id(dev,
1565 ATOM_DEVICE_TV1_SUPPORT,
1566 2),
1567 ATOM_DEVICE_TV1_SUPPORT);
1568 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1569 DRM_MODE_CONNECTOR_SVIDEO,
Alex Deucherb75fad02009-11-05 13:16:01 -05001570 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001571 CONNECTOR_OBJECT_ID_SVIDEO,
1572 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001573 break;
1574 case CT_POWERBOOK_EXTERNAL:
1575 DRM_INFO("Connector Table: %d (powerbook external tmds)\n",
1576 rdev->mode_info.connector_table);
1577 /* LVDS */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001578 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001579 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001580 radeon_add_legacy_encoder(dev,
1581 radeon_get_encoder_id(dev,
1582 ATOM_DEVICE_LCD1_SUPPORT,
1583 0),
1584 ATOM_DEVICE_LCD1_SUPPORT);
1585 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
Alex Deucherb75fad02009-11-05 13:16:01 -05001586 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001587 CONNECTOR_OBJECT_ID_LVDS,
1588 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001589 /* DVI-I - primary dac, ext tmds */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001590 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001591 hpd.hpd = RADEON_HPD_2; /* ??? */
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001592 radeon_add_legacy_encoder(dev,
1593 radeon_get_encoder_id(dev,
1594 ATOM_DEVICE_DFP2_SUPPORT,
1595 0),
1596 ATOM_DEVICE_DFP2_SUPPORT);
1597 radeon_add_legacy_encoder(dev,
1598 radeon_get_encoder_id(dev,
1599 ATOM_DEVICE_CRT1_SUPPORT,
1600 1),
1601 ATOM_DEVICE_CRT1_SUPPORT);
Alex Deucherb75fad02009-11-05 13:16:01 -05001602 /* XXX some are SL */
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001603 radeon_add_legacy_connector(dev, 1,
1604 ATOM_DEVICE_DFP2_SUPPORT |
1605 ATOM_DEVICE_CRT1_SUPPORT,
Alex Deucherb75fad02009-11-05 13:16:01 -05001606 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001607 CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I,
1608 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001609 /* TV - TV DAC */
Alex Deuchereed45b32009-12-04 14:45:27 -05001610 ddc_i2c.valid = false;
1611 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001612 radeon_add_legacy_encoder(dev,
1613 radeon_get_encoder_id(dev,
1614 ATOM_DEVICE_TV1_SUPPORT,
1615 2),
1616 ATOM_DEVICE_TV1_SUPPORT);
1617 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1618 DRM_MODE_CONNECTOR_SVIDEO,
Alex Deucherb75fad02009-11-05 13:16:01 -05001619 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001620 CONNECTOR_OBJECT_ID_SVIDEO,
1621 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001622 break;
1623 case CT_POWERBOOK_INTERNAL:
1624 DRM_INFO("Connector Table: %d (powerbook internal tmds)\n",
1625 rdev->mode_info.connector_table);
1626 /* LVDS */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001627 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001628 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001629 radeon_add_legacy_encoder(dev,
1630 radeon_get_encoder_id(dev,
1631 ATOM_DEVICE_LCD1_SUPPORT,
1632 0),
1633 ATOM_DEVICE_LCD1_SUPPORT);
1634 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
Alex Deucherb75fad02009-11-05 13:16:01 -05001635 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001636 CONNECTOR_OBJECT_ID_LVDS,
1637 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001638 /* DVI-I - primary dac, int tmds */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001639 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001640 hpd.hpd = RADEON_HPD_1; /* ??? */
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001641 radeon_add_legacy_encoder(dev,
1642 radeon_get_encoder_id(dev,
1643 ATOM_DEVICE_DFP1_SUPPORT,
1644 0),
1645 ATOM_DEVICE_DFP1_SUPPORT);
1646 radeon_add_legacy_encoder(dev,
1647 radeon_get_encoder_id(dev,
1648 ATOM_DEVICE_CRT1_SUPPORT,
1649 1),
1650 ATOM_DEVICE_CRT1_SUPPORT);
1651 radeon_add_legacy_connector(dev, 1,
1652 ATOM_DEVICE_DFP1_SUPPORT |
1653 ATOM_DEVICE_CRT1_SUPPORT,
Alex Deucherb75fad02009-11-05 13:16:01 -05001654 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001655 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1656 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001657 /* TV - TV DAC */
Alex Deuchereed45b32009-12-04 14:45:27 -05001658 ddc_i2c.valid = false;
1659 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001660 radeon_add_legacy_encoder(dev,
1661 radeon_get_encoder_id(dev,
1662 ATOM_DEVICE_TV1_SUPPORT,
1663 2),
1664 ATOM_DEVICE_TV1_SUPPORT);
1665 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1666 DRM_MODE_CONNECTOR_SVIDEO,
Alex Deucherb75fad02009-11-05 13:16:01 -05001667 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001668 CONNECTOR_OBJECT_ID_SVIDEO,
1669 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001670 break;
1671 case CT_POWERBOOK_VGA:
1672 DRM_INFO("Connector Table: %d (powerbook vga)\n",
1673 rdev->mode_info.connector_table);
1674 /* LVDS */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001675 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001676 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001677 radeon_add_legacy_encoder(dev,
1678 radeon_get_encoder_id(dev,
1679 ATOM_DEVICE_LCD1_SUPPORT,
1680 0),
1681 ATOM_DEVICE_LCD1_SUPPORT);
1682 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
Alex Deucherb75fad02009-11-05 13:16:01 -05001683 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001684 CONNECTOR_OBJECT_ID_LVDS,
1685 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001686 /* VGA - primary dac */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001687 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001688 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001689 radeon_add_legacy_encoder(dev,
1690 radeon_get_encoder_id(dev,
1691 ATOM_DEVICE_CRT1_SUPPORT,
1692 1),
1693 ATOM_DEVICE_CRT1_SUPPORT);
1694 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT,
Alex Deucherb75fad02009-11-05 13:16:01 -05001695 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001696 CONNECTOR_OBJECT_ID_VGA,
1697 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001698 /* TV - TV DAC */
Alex Deuchereed45b32009-12-04 14:45:27 -05001699 ddc_i2c.valid = false;
1700 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001701 radeon_add_legacy_encoder(dev,
1702 radeon_get_encoder_id(dev,
1703 ATOM_DEVICE_TV1_SUPPORT,
1704 2),
1705 ATOM_DEVICE_TV1_SUPPORT);
1706 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1707 DRM_MODE_CONNECTOR_SVIDEO,
Alex Deucherb75fad02009-11-05 13:16:01 -05001708 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001709 CONNECTOR_OBJECT_ID_SVIDEO,
1710 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001711 break;
1712 case CT_MINI_EXTERNAL:
1713 DRM_INFO("Connector Table: %d (mini external tmds)\n",
1714 rdev->mode_info.connector_table);
1715 /* DVI-I - tv dac, ext tmds */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001716 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001717 hpd.hpd = RADEON_HPD_2; /* ??? */
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001718 radeon_add_legacy_encoder(dev,
1719 radeon_get_encoder_id(dev,
1720 ATOM_DEVICE_DFP2_SUPPORT,
1721 0),
1722 ATOM_DEVICE_DFP2_SUPPORT);
1723 radeon_add_legacy_encoder(dev,
1724 radeon_get_encoder_id(dev,
1725 ATOM_DEVICE_CRT2_SUPPORT,
1726 2),
1727 ATOM_DEVICE_CRT2_SUPPORT);
Alex Deucherb75fad02009-11-05 13:16:01 -05001728 /* XXX are any DL? */
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001729 radeon_add_legacy_connector(dev, 0,
1730 ATOM_DEVICE_DFP2_SUPPORT |
1731 ATOM_DEVICE_CRT2_SUPPORT,
Alex Deucherb75fad02009-11-05 13:16:01 -05001732 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001733 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1734 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001735 /* TV - TV DAC */
Alex Deuchereed45b32009-12-04 14:45:27 -05001736 ddc_i2c.valid = false;
1737 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001738 radeon_add_legacy_encoder(dev,
1739 radeon_get_encoder_id(dev,
1740 ATOM_DEVICE_TV1_SUPPORT,
1741 2),
1742 ATOM_DEVICE_TV1_SUPPORT);
1743 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT,
1744 DRM_MODE_CONNECTOR_SVIDEO,
Alex Deucherb75fad02009-11-05 13:16:01 -05001745 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001746 CONNECTOR_OBJECT_ID_SVIDEO,
1747 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001748 break;
1749 case CT_MINI_INTERNAL:
1750 DRM_INFO("Connector Table: %d (mini internal tmds)\n",
1751 rdev->mode_info.connector_table);
1752 /* DVI-I - tv dac, int tmds */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001753 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001754 hpd.hpd = RADEON_HPD_1; /* ??? */
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001755 radeon_add_legacy_encoder(dev,
1756 radeon_get_encoder_id(dev,
1757 ATOM_DEVICE_DFP1_SUPPORT,
1758 0),
1759 ATOM_DEVICE_DFP1_SUPPORT);
1760 radeon_add_legacy_encoder(dev,
1761 radeon_get_encoder_id(dev,
1762 ATOM_DEVICE_CRT2_SUPPORT,
1763 2),
1764 ATOM_DEVICE_CRT2_SUPPORT);
1765 radeon_add_legacy_connector(dev, 0,
1766 ATOM_DEVICE_DFP1_SUPPORT |
1767 ATOM_DEVICE_CRT2_SUPPORT,
Alex Deucherb75fad02009-11-05 13:16:01 -05001768 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001769 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1770 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001771 /* TV - TV DAC */
Alex Deuchereed45b32009-12-04 14:45:27 -05001772 ddc_i2c.valid = false;
1773 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001774 radeon_add_legacy_encoder(dev,
1775 radeon_get_encoder_id(dev,
1776 ATOM_DEVICE_TV1_SUPPORT,
1777 2),
1778 ATOM_DEVICE_TV1_SUPPORT);
1779 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT,
1780 DRM_MODE_CONNECTOR_SVIDEO,
Alex Deucherb75fad02009-11-05 13:16:01 -05001781 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001782 CONNECTOR_OBJECT_ID_SVIDEO,
1783 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001784 break;
1785 case CT_IMAC_G5_ISIGHT:
1786 DRM_INFO("Connector Table: %d (imac g5 isight)\n",
1787 rdev->mode_info.connector_table);
1788 /* DVI-D - int tmds */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001789 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
Alex Deuchereed45b32009-12-04 14:45:27 -05001790 hpd.hpd = RADEON_HPD_1; /* ??? */
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001791 radeon_add_legacy_encoder(dev,
1792 radeon_get_encoder_id(dev,
1793 ATOM_DEVICE_DFP1_SUPPORT,
1794 0),
1795 ATOM_DEVICE_DFP1_SUPPORT);
1796 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT,
Alex Deucherb75fad02009-11-05 13:16:01 -05001797 DRM_MODE_CONNECTOR_DVID, &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001798 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D,
1799 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001800 /* VGA - tv dac */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001801 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001802 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001803 radeon_add_legacy_encoder(dev,
1804 radeon_get_encoder_id(dev,
1805 ATOM_DEVICE_CRT2_SUPPORT,
1806 2),
1807 ATOM_DEVICE_CRT2_SUPPORT);
1808 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
Alex Deucherb75fad02009-11-05 13:16:01 -05001809 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001810 CONNECTOR_OBJECT_ID_VGA,
1811 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001812 /* TV - TV DAC */
Alex Deuchereed45b32009-12-04 14:45:27 -05001813 ddc_i2c.valid = false;
1814 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001815 radeon_add_legacy_encoder(dev,
1816 radeon_get_encoder_id(dev,
1817 ATOM_DEVICE_TV1_SUPPORT,
1818 2),
1819 ATOM_DEVICE_TV1_SUPPORT);
1820 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1821 DRM_MODE_CONNECTOR_SVIDEO,
Alex Deucherb75fad02009-11-05 13:16:01 -05001822 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001823 CONNECTOR_OBJECT_ID_SVIDEO,
1824 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001825 break;
1826 case CT_EMAC:
1827 DRM_INFO("Connector Table: %d (emac)\n",
1828 rdev->mode_info.connector_table);
1829 /* VGA - primary dac */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001830 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001831 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001832 radeon_add_legacy_encoder(dev,
1833 radeon_get_encoder_id(dev,
1834 ATOM_DEVICE_CRT1_SUPPORT,
1835 1),
1836 ATOM_DEVICE_CRT1_SUPPORT);
1837 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT,
Alex Deucherb75fad02009-11-05 13:16:01 -05001838 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001839 CONNECTOR_OBJECT_ID_VGA,
1840 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001841 /* VGA - tv dac */
Alex Deucher6a93cb22009-11-23 17:39:28 -05001842 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05001843 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001844 radeon_add_legacy_encoder(dev,
1845 radeon_get_encoder_id(dev,
1846 ATOM_DEVICE_CRT2_SUPPORT,
1847 2),
1848 ATOM_DEVICE_CRT2_SUPPORT);
1849 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
Alex Deucherb75fad02009-11-05 13:16:01 -05001850 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001851 CONNECTOR_OBJECT_ID_VGA,
1852 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001853 /* TV - TV DAC */
Alex Deuchereed45b32009-12-04 14:45:27 -05001854 ddc_i2c.valid = false;
1855 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001856 radeon_add_legacy_encoder(dev,
1857 radeon_get_encoder_id(dev,
1858 ATOM_DEVICE_TV1_SUPPORT,
1859 2),
1860 ATOM_DEVICE_TV1_SUPPORT);
1861 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1862 DRM_MODE_CONNECTOR_SVIDEO,
Alex Deucherb75fad02009-11-05 13:16:01 -05001863 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05001864 CONNECTOR_OBJECT_ID_SVIDEO,
1865 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001866 break;
1867 default:
1868 DRM_INFO("Connector table: %d (invalid)\n",
1869 rdev->mode_info.connector_table);
1870 return false;
1871 }
1872
1873 radeon_link_encoder_connector(dev);
1874
1875 return true;
1876}
1877
1878static bool radeon_apply_legacy_quirks(struct drm_device *dev,
1879 int bios_index,
1880 enum radeon_combios_connector
1881 *legacy_connector,
Alex Deuchereed45b32009-12-04 14:45:27 -05001882 struct radeon_i2c_bus_rec *ddc_i2c,
1883 struct radeon_hpd *hpd)
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001884{
1885 struct radeon_device *rdev = dev->dev_private;
1886
1887 /* XPRESS DDC quirks */
1888 if ((rdev->family == CHIP_RS400 ||
1889 rdev->family == CHIP_RS480) &&
1890 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
Alex Deucher6a93cb22009-11-23 17:39:28 -05001891 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001892 else if ((rdev->family == CHIP_RS400 ||
1893 rdev->family == CHIP_RS480) &&
1894 ddc_i2c->mask_clk_reg == RADEON_GPIO_MONID) {
Alex Deucher6a93cb22009-11-23 17:39:28 -05001895 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIOPAD_MASK);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001896 ddc_i2c->mask_clk_mask = (0x20 << 8);
1897 ddc_i2c->mask_data_mask = 0x80;
1898 ddc_i2c->a_clk_mask = (0x20 << 8);
1899 ddc_i2c->a_data_mask = 0x80;
Alex Deucher9b9fe722009-11-10 15:59:44 -05001900 ddc_i2c->en_clk_mask = (0x20 << 8);
1901 ddc_i2c->en_data_mask = 0x80;
1902 ddc_i2c->y_clk_mask = (0x20 << 8);
1903 ddc_i2c->y_data_mask = 0x80;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001904 }
1905
Alex Deucherfcec5702009-11-10 21:25:07 -05001906 /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */
1907 if ((rdev->family >= CHIP_R300) &&
1908 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
Alex Deucher6a93cb22009-11-23 17:39:28 -05001909 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
Alex Deucherfcec5702009-11-10 21:25:07 -05001910
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001911 /* Certain IBM chipset RN50s have a BIOS reporting two VGAs,
1912 one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */
1913 if (dev->pdev->device == 0x515e &&
1914 dev->pdev->subsystem_vendor == 0x1014) {
1915 if (*legacy_connector == CONNECTOR_CRT_LEGACY &&
1916 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
1917 return false;
1918 }
1919
1920 /* Some RV100 cards with 2 VGA ports show up with DVI+VGA */
1921 if (dev->pdev->device == 0x5159 &&
1922 dev->pdev->subsystem_vendor == 0x1002 &&
1923 dev->pdev->subsystem_device == 0x013a) {
1924 if (*legacy_connector == CONNECTOR_DVI_I_LEGACY)
1925 *legacy_connector = CONNECTOR_CRT_LEGACY;
1926
1927 }
1928
1929 /* X300 card with extra non-existent DVI port */
1930 if (dev->pdev->device == 0x5B60 &&
1931 dev->pdev->subsystem_vendor == 0x17af &&
1932 dev->pdev->subsystem_device == 0x201e && bios_index == 2) {
1933 if (*legacy_connector == CONNECTOR_DVI_I_LEGACY)
1934 return false;
1935 }
1936
1937 return true;
1938}
1939
Alex Deucher790cfb32009-10-15 23:26:09 -04001940static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev)
1941{
1942 /* Acer 5102 has non-existent TV port */
1943 if (dev->pdev->device == 0x5975 &&
1944 dev->pdev->subsystem_vendor == 0x1025 &&
1945 dev->pdev->subsystem_device == 0x009f)
1946 return false;
1947
Alex Deucherfc7f7112009-10-28 01:46:54 -04001948 /* HP dc5750 has non-existent TV port */
1949 if (dev->pdev->device == 0x5974 &&
1950 dev->pdev->subsystem_vendor == 0x103c &&
1951 dev->pdev->subsystem_device == 0x280a)
1952 return false;
1953
Alex Deucherfd874ad2009-11-16 18:33:51 -05001954 /* MSI S270 has non-existent TV port */
1955 if (dev->pdev->device == 0x5955 &&
1956 dev->pdev->subsystem_vendor == 0x1462 &&
1957 dev->pdev->subsystem_device == 0x0131)
1958 return false;
1959
Alex Deucher790cfb32009-10-15 23:26:09 -04001960 return true;
1961}
1962
Alex Deucherb75fad02009-11-05 13:16:01 -05001963static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d)
1964{
1965 struct radeon_device *rdev = dev->dev_private;
1966 uint32_t ext_tmds_info;
1967
1968 if (rdev->flags & RADEON_IS_IGP) {
1969 if (is_dvi_d)
1970 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
1971 else
1972 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
1973 }
1974 ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
1975 if (ext_tmds_info) {
1976 uint8_t rev = RBIOS8(ext_tmds_info);
1977 uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5);
1978 if (rev >= 3) {
1979 if (is_dvi_d)
1980 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
1981 else
1982 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
1983 } else {
1984 if (flags & 1) {
1985 if (is_dvi_d)
1986 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
1987 else
1988 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
1989 }
1990 }
1991 }
1992 if (is_dvi_d)
1993 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
1994 else
1995 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
1996}
1997
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001998bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev)
1999{
2000 struct radeon_device *rdev = dev->dev_private;
2001 uint32_t conn_info, entry, devices;
Alex Deucherb75fad02009-11-05 13:16:01 -05002002 uint16_t tmp, connector_object_id;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002003 enum radeon_combios_ddc ddc_type;
2004 enum radeon_combios_connector connector;
2005 int i = 0;
2006 struct radeon_i2c_bus_rec ddc_i2c;
Alex Deuchereed45b32009-12-04 14:45:27 -05002007 struct radeon_hpd hpd;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002008
2009 if (rdev->bios == NULL)
2010 return false;
2011
2012 conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE);
2013 if (conn_info) {
2014 for (i = 0; i < 4; i++) {
2015 entry = conn_info + 2 + i * 2;
2016
2017 if (!RBIOS16(entry))
2018 break;
2019
2020 tmp = RBIOS16(entry);
2021
2022 connector = (tmp >> 12) & 0xf;
2023
2024 ddc_type = (tmp >> 8) & 0xf;
2025 switch (ddc_type) {
2026 case DDC_MONID:
2027 ddc_i2c =
Alex Deucher6a93cb22009-11-23 17:39:28 -05002028 combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002029 break;
2030 case DDC_DVI:
2031 ddc_i2c =
Alex Deucher6a93cb22009-11-23 17:39:28 -05002032 combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002033 break;
2034 case DDC_VGA:
2035 ddc_i2c =
Alex Deucher6a93cb22009-11-23 17:39:28 -05002036 combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002037 break;
2038 case DDC_CRT2:
2039 ddc_i2c =
Alex Deucher6a93cb22009-11-23 17:39:28 -05002040 combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002041 break;
2042 default:
2043 break;
2044 }
2045
Alex Deuchereed45b32009-12-04 14:45:27 -05002046 switch (connector) {
2047 case CONNECTOR_PROPRIETARY_LEGACY:
2048 case CONNECTOR_DVI_I_LEGACY:
2049 case CONNECTOR_DVI_D_LEGACY:
2050 if ((tmp >> 4) & 0x1)
2051 hpd.hpd = RADEON_HPD_2;
2052 else
2053 hpd.hpd = RADEON_HPD_1;
2054 break;
2055 default:
2056 hpd.hpd = RADEON_HPD_NONE;
2057 break;
2058 }
2059
Alex Deucher2d152c62009-10-15 23:08:05 -04002060 if (!radeon_apply_legacy_quirks(dev, i, &connector,
Alex Deuchereed45b32009-12-04 14:45:27 -05002061 &ddc_i2c, &hpd))
Alex Deucher2d152c62009-10-15 23:08:05 -04002062 continue;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002063
2064 switch (connector) {
2065 case CONNECTOR_PROPRIETARY_LEGACY:
2066 if ((tmp >> 4) & 0x1)
2067 devices = ATOM_DEVICE_DFP2_SUPPORT;
2068 else
2069 devices = ATOM_DEVICE_DFP1_SUPPORT;
2070 radeon_add_legacy_encoder(dev,
2071 radeon_get_encoder_id
2072 (dev, devices, 0),
2073 devices);
2074 radeon_add_legacy_connector(dev, i, devices,
2075 legacy_connector_convert
2076 [connector],
Alex Deucherb75fad02009-11-05 13:16:01 -05002077 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05002078 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D,
2079 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002080 break;
2081 case CONNECTOR_CRT_LEGACY:
2082 if (tmp & 0x1) {
2083 devices = ATOM_DEVICE_CRT2_SUPPORT;
2084 radeon_add_legacy_encoder(dev,
2085 radeon_get_encoder_id
2086 (dev,
2087 ATOM_DEVICE_CRT2_SUPPORT,
2088 2),
2089 ATOM_DEVICE_CRT2_SUPPORT);
2090 } else {
2091 devices = ATOM_DEVICE_CRT1_SUPPORT;
2092 radeon_add_legacy_encoder(dev,
2093 radeon_get_encoder_id
2094 (dev,
2095 ATOM_DEVICE_CRT1_SUPPORT,
2096 1),
2097 ATOM_DEVICE_CRT1_SUPPORT);
2098 }
2099 radeon_add_legacy_connector(dev,
2100 i,
2101 devices,
2102 legacy_connector_convert
2103 [connector],
Alex Deucherb75fad02009-11-05 13:16:01 -05002104 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05002105 CONNECTOR_OBJECT_ID_VGA,
2106 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002107 break;
2108 case CONNECTOR_DVI_I_LEGACY:
2109 devices = 0;
2110 if (tmp & 0x1) {
2111 devices |= ATOM_DEVICE_CRT2_SUPPORT;
2112 radeon_add_legacy_encoder(dev,
2113 radeon_get_encoder_id
2114 (dev,
2115 ATOM_DEVICE_CRT2_SUPPORT,
2116 2),
2117 ATOM_DEVICE_CRT2_SUPPORT);
2118 } else {
2119 devices |= ATOM_DEVICE_CRT1_SUPPORT;
2120 radeon_add_legacy_encoder(dev,
2121 radeon_get_encoder_id
2122 (dev,
2123 ATOM_DEVICE_CRT1_SUPPORT,
2124 1),
2125 ATOM_DEVICE_CRT1_SUPPORT);
2126 }
2127 if ((tmp >> 4) & 0x1) {
2128 devices |= ATOM_DEVICE_DFP2_SUPPORT;
2129 radeon_add_legacy_encoder(dev,
2130 radeon_get_encoder_id
2131 (dev,
2132 ATOM_DEVICE_DFP2_SUPPORT,
2133 0),
2134 ATOM_DEVICE_DFP2_SUPPORT);
Alex Deucherb75fad02009-11-05 13:16:01 -05002135 connector_object_id = combios_check_dl_dvi(dev, 0);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002136 } else {
2137 devices |= ATOM_DEVICE_DFP1_SUPPORT;
2138 radeon_add_legacy_encoder(dev,
2139 radeon_get_encoder_id
2140 (dev,
2141 ATOM_DEVICE_DFP1_SUPPORT,
2142 0),
2143 ATOM_DEVICE_DFP1_SUPPORT);
Alex Deucherb75fad02009-11-05 13:16:01 -05002144 connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002145 }
2146 radeon_add_legacy_connector(dev,
2147 i,
2148 devices,
2149 legacy_connector_convert
2150 [connector],
Alex Deucherb75fad02009-11-05 13:16:01 -05002151 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05002152 connector_object_id,
2153 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002154 break;
2155 case CONNECTOR_DVI_D_LEGACY:
Alex Deucherb75fad02009-11-05 13:16:01 -05002156 if ((tmp >> 4) & 0x1) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002157 devices = ATOM_DEVICE_DFP2_SUPPORT;
Alex Deucherb75fad02009-11-05 13:16:01 -05002158 connector_object_id = combios_check_dl_dvi(dev, 1);
2159 } else {
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002160 devices = ATOM_DEVICE_DFP1_SUPPORT;
Alex Deucherb75fad02009-11-05 13:16:01 -05002161 connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
2162 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002163 radeon_add_legacy_encoder(dev,
2164 radeon_get_encoder_id
2165 (dev, devices, 0),
2166 devices);
2167 radeon_add_legacy_connector(dev, i, devices,
2168 legacy_connector_convert
2169 [connector],
Alex Deucherb75fad02009-11-05 13:16:01 -05002170 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05002171 connector_object_id,
2172 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002173 break;
2174 case CONNECTOR_CTV_LEGACY:
2175 case CONNECTOR_STV_LEGACY:
2176 radeon_add_legacy_encoder(dev,
2177 radeon_get_encoder_id
2178 (dev,
2179 ATOM_DEVICE_TV1_SUPPORT,
2180 2),
2181 ATOM_DEVICE_TV1_SUPPORT);
2182 radeon_add_legacy_connector(dev, i,
2183 ATOM_DEVICE_TV1_SUPPORT,
2184 legacy_connector_convert
2185 [connector],
Alex Deucherb75fad02009-11-05 13:16:01 -05002186 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05002187 CONNECTOR_OBJECT_ID_SVIDEO,
2188 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002189 break;
2190 default:
2191 DRM_ERROR("Unknown connector type: %d\n",
2192 connector);
2193 continue;
2194 }
2195
2196 }
2197 } else {
2198 uint16_t tmds_info =
2199 combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE);
2200 if (tmds_info) {
2201 DRM_DEBUG("Found DFP table, assuming DVI connector\n");
2202
2203 radeon_add_legacy_encoder(dev,
2204 radeon_get_encoder_id(dev,
2205 ATOM_DEVICE_CRT1_SUPPORT,
2206 1),
2207 ATOM_DEVICE_CRT1_SUPPORT);
2208 radeon_add_legacy_encoder(dev,
2209 radeon_get_encoder_id(dev,
2210 ATOM_DEVICE_DFP1_SUPPORT,
2211 0),
2212 ATOM_DEVICE_DFP1_SUPPORT);
2213
Alex Deucher6a93cb22009-11-23 17:39:28 -05002214 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05002215 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002216 radeon_add_legacy_connector(dev,
2217 0,
2218 ATOM_DEVICE_CRT1_SUPPORT |
2219 ATOM_DEVICE_DFP1_SUPPORT,
2220 DRM_MODE_CONNECTOR_DVII,
Alex Deucherb75fad02009-11-05 13:16:01 -05002221 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05002222 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
2223 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002224 } else {
Alex Deucherd0c403e2009-10-15 23:38:32 -04002225 uint16_t crt_info =
2226 combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
2227 DRM_DEBUG("Found CRT table, assuming VGA connector\n");
2228 if (crt_info) {
2229 radeon_add_legacy_encoder(dev,
2230 radeon_get_encoder_id(dev,
2231 ATOM_DEVICE_CRT1_SUPPORT,
2232 1),
2233 ATOM_DEVICE_CRT1_SUPPORT);
Alex Deucher6a93cb22009-11-23 17:39:28 -05002234 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
Alex Deuchereed45b32009-12-04 14:45:27 -05002235 hpd.hpd = RADEON_HPD_NONE;
Alex Deucherd0c403e2009-10-15 23:38:32 -04002236 radeon_add_legacy_connector(dev,
2237 0,
2238 ATOM_DEVICE_CRT1_SUPPORT,
2239 DRM_MODE_CONNECTOR_VGA,
Alex Deucherb75fad02009-11-05 13:16:01 -05002240 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05002241 CONNECTOR_OBJECT_ID_VGA,
2242 &hpd);
Alex Deucherd0c403e2009-10-15 23:38:32 -04002243 } else {
2244 DRM_DEBUG("No connector info found\n");
2245 return false;
2246 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002247 }
2248 }
2249
2250 if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) {
2251 uint16_t lcd_info =
2252 combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE);
2253 if (lcd_info) {
2254 uint16_t lcd_ddc_info =
2255 combios_get_table_offset(dev,
2256 COMBIOS_LCD_DDC_INFO_TABLE);
2257
2258 radeon_add_legacy_encoder(dev,
2259 radeon_get_encoder_id(dev,
2260 ATOM_DEVICE_LCD1_SUPPORT,
2261 0),
2262 ATOM_DEVICE_LCD1_SUPPORT);
2263
2264 if (lcd_ddc_info) {
2265 ddc_type = RBIOS8(lcd_ddc_info + 2);
2266 switch (ddc_type) {
2267 case DDC_MONID:
2268 ddc_i2c =
2269 combios_setup_i2c_bus
Alex Deucher6a93cb22009-11-23 17:39:28 -05002270 (rdev, RADEON_GPIO_MONID);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002271 break;
2272 case DDC_DVI:
2273 ddc_i2c =
2274 combios_setup_i2c_bus
Alex Deucher6a93cb22009-11-23 17:39:28 -05002275 (rdev, RADEON_GPIO_DVI_DDC);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002276 break;
2277 case DDC_VGA:
2278 ddc_i2c =
2279 combios_setup_i2c_bus
Alex Deucher6a93cb22009-11-23 17:39:28 -05002280 (rdev, RADEON_GPIO_VGA_DDC);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002281 break;
2282 case DDC_CRT2:
2283 ddc_i2c =
2284 combios_setup_i2c_bus
Alex Deucher6a93cb22009-11-23 17:39:28 -05002285 (rdev, RADEON_GPIO_CRT2_DDC);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002286 break;
2287 case DDC_LCD:
2288 ddc_i2c =
2289 combios_setup_i2c_bus
Alex Deucher6a93cb22009-11-23 17:39:28 -05002290 (rdev, RADEON_GPIOPAD_MASK);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002291 ddc_i2c.mask_clk_mask =
2292 RBIOS32(lcd_ddc_info + 3);
2293 ddc_i2c.mask_data_mask =
2294 RBIOS32(lcd_ddc_info + 7);
2295 ddc_i2c.a_clk_mask =
2296 RBIOS32(lcd_ddc_info + 3);
2297 ddc_i2c.a_data_mask =
2298 RBIOS32(lcd_ddc_info + 7);
Alex Deucher9b9fe722009-11-10 15:59:44 -05002299 ddc_i2c.en_clk_mask =
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002300 RBIOS32(lcd_ddc_info + 3);
Alex Deucher9b9fe722009-11-10 15:59:44 -05002301 ddc_i2c.en_data_mask =
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002302 RBIOS32(lcd_ddc_info + 7);
Alex Deucher9b9fe722009-11-10 15:59:44 -05002303 ddc_i2c.y_clk_mask =
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002304 RBIOS32(lcd_ddc_info + 3);
Alex Deucher9b9fe722009-11-10 15:59:44 -05002305 ddc_i2c.y_data_mask =
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002306 RBIOS32(lcd_ddc_info + 7);
2307 break;
2308 case DDC_GPIO:
2309 ddc_i2c =
2310 combios_setup_i2c_bus
Alex Deucher6a93cb22009-11-23 17:39:28 -05002311 (rdev, RADEON_MDGPIO_MASK);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002312 ddc_i2c.mask_clk_mask =
2313 RBIOS32(lcd_ddc_info + 3);
2314 ddc_i2c.mask_data_mask =
2315 RBIOS32(lcd_ddc_info + 7);
2316 ddc_i2c.a_clk_mask =
2317 RBIOS32(lcd_ddc_info + 3);
2318 ddc_i2c.a_data_mask =
2319 RBIOS32(lcd_ddc_info + 7);
Alex Deucher9b9fe722009-11-10 15:59:44 -05002320 ddc_i2c.en_clk_mask =
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002321 RBIOS32(lcd_ddc_info + 3);
Alex Deucher9b9fe722009-11-10 15:59:44 -05002322 ddc_i2c.en_data_mask =
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002323 RBIOS32(lcd_ddc_info + 7);
Alex Deucher9b9fe722009-11-10 15:59:44 -05002324 ddc_i2c.y_clk_mask =
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002325 RBIOS32(lcd_ddc_info + 3);
Alex Deucher9b9fe722009-11-10 15:59:44 -05002326 ddc_i2c.y_data_mask =
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002327 RBIOS32(lcd_ddc_info + 7);
2328 break;
2329 default:
2330 ddc_i2c.valid = false;
2331 break;
2332 }
2333 DRM_DEBUG("LCD DDC Info Table found!\n");
2334 } else
2335 ddc_i2c.valid = false;
2336
Alex Deuchereed45b32009-12-04 14:45:27 -05002337 hpd.hpd = RADEON_HPD_NONE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002338 radeon_add_legacy_connector(dev,
2339 5,
2340 ATOM_DEVICE_LCD1_SUPPORT,
2341 DRM_MODE_CONNECTOR_LVDS,
Alex Deucherb75fad02009-11-05 13:16:01 -05002342 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05002343 CONNECTOR_OBJECT_ID_LVDS,
2344 &hpd);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002345 }
2346 }
2347
2348 /* check TV table */
2349 if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) {
2350 uint32_t tv_info =
2351 combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
2352 if (tv_info) {
2353 if (RBIOS8(tv_info + 6) == 'T') {
Alex Deucher790cfb32009-10-15 23:26:09 -04002354 if (radeon_apply_legacy_tv_quirks(dev)) {
Alex Deuchereed45b32009-12-04 14:45:27 -05002355 hpd.hpd = RADEON_HPD_NONE;
Alex Deucher790cfb32009-10-15 23:26:09 -04002356 radeon_add_legacy_encoder(dev,
2357 radeon_get_encoder_id
2358 (dev,
2359 ATOM_DEVICE_TV1_SUPPORT,
2360 2),
2361 ATOM_DEVICE_TV1_SUPPORT);
2362 radeon_add_legacy_connector(dev, 6,
2363 ATOM_DEVICE_TV1_SUPPORT,
2364 DRM_MODE_CONNECTOR_SVIDEO,
Alex Deucherb75fad02009-11-05 13:16:01 -05002365 &ddc_i2c,
Alex Deuchereed45b32009-12-04 14:45:27 -05002366 CONNECTOR_OBJECT_ID_SVIDEO,
2367 &hpd);
Alex Deucher790cfb32009-10-15 23:26:09 -04002368 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002369 }
2370 }
2371 }
2372
2373 radeon_link_encoder_connector(dev);
2374
2375 return true;
2376}
2377
Alex Deucher56278a82009-12-28 13:58:44 -05002378void radeon_combios_get_power_modes(struct radeon_device *rdev)
2379{
2380 struct drm_device *dev = rdev->ddev;
2381 u16 offset, misc, misc2 = 0;
2382 u8 rev, blocks, tmp;
2383 int state_index = 0;
2384
2385 rdev->pm.default_power_state = NULL;
2386 rdev->pm.current_power_state = NULL;
2387
2388 /* XXX mac/sparc cards */
2389 if (rdev->bios == NULL)
2390 goto default_mode;
2391
2392 if (rdev->flags & RADEON_IS_MOBILITY) {
2393 offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE);
2394 if (offset) {
2395 rev = RBIOS8(offset);
2396 blocks = RBIOS8(offset + 0x2);
2397 /* power mode 0 tends to be the only valid one */
2398 rdev->pm.power_state[state_index].num_clock_modes = 1;
2399 rdev->pm.power_state[state_index].clock_info[0].mclk = RBIOS32(offset + 0x5 + 0x2);
2400 rdev->pm.power_state[state_index].clock_info[0].sclk = RBIOS32(offset + 0x5 + 0x6);
2401 if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) ||
2402 (rdev->pm.power_state[state_index].clock_info[0].sclk == 0))
2403 goto default_mode;
2404 /* skip overclock modes for now */
2405 if ((rdev->pm.power_state[state_index].clock_info[0].mclk >
2406 rdev->clock.default_mclk) ||
2407 (rdev->pm.power_state[state_index].clock_info[0].sclk >
2408 rdev->clock.default_sclk))
2409 goto default_mode;
Alex Deucher0ec0e742009-12-23 13:21:58 -05002410 rdev->pm.power_state[state_index].type =
2411 POWER_STATE_TYPE_BATTERY;
Alex Deucher56278a82009-12-28 13:58:44 -05002412 misc = RBIOS16(offset + 0x5 + 0x0);
2413 if (rev > 4)
2414 misc2 = RBIOS16(offset + 0x5 + 0xe);
2415 if (misc & 0x4) {
2416 rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_GPIO;
2417 if (misc & 0x8)
2418 rdev->pm.power_state[state_index].clock_info[0].voltage.active_high =
2419 true;
2420 else
2421 rdev->pm.power_state[state_index].clock_info[0].voltage.active_high =
2422 false;
2423 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = true;
2424 if (rev < 6) {
2425 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg =
2426 RBIOS16(offset + 0x5 + 0xb) * 4;
2427 tmp = RBIOS8(offset + 0x5 + 0xd);
2428 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp);
2429 } else {
2430 u8 entries = RBIOS8(offset + 0x5 + 0xb);
2431 u16 voltage_table_offset = RBIOS16(offset + 0x5 + 0xc);
2432 if (entries && voltage_table_offset) {
2433 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg =
2434 RBIOS16(voltage_table_offset) * 4;
2435 tmp = RBIOS8(voltage_table_offset + 0x2);
2436 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp);
2437 } else
2438 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = false;
2439 }
2440 switch ((misc2 & 0x700) >> 8) {
2441 case 0:
2442 default:
2443 rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 0;
2444 break;
2445 case 1:
2446 rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 33;
2447 break;
2448 case 2:
2449 rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 66;
2450 break;
2451 case 3:
2452 rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 99;
2453 break;
2454 case 4:
2455 rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 132;
2456 break;
2457 }
2458 } else
2459 rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
2460 if (rev > 6)
2461 rdev->pm.power_state[state_index].non_clock_info.pcie_lanes =
2462 RBIOS8(offset + 0x5 + 0x10);
2463 state_index++;
2464 } else {
2465 /* XXX figure out some good default low power mode for mobility cards w/out power tables */
2466 }
2467 } else {
2468 /* XXX figure out some good default low power mode for desktop cards */
2469 }
2470
2471default_mode:
2472 /* add the default mode */
Alex Deucher0ec0e742009-12-23 13:21:58 -05002473 rdev->pm.power_state[state_index].type =
2474 POWER_STATE_TYPE_DEFAULT;
Alex Deucher56278a82009-12-28 13:58:44 -05002475 rdev->pm.power_state[state_index].num_clock_modes = 1;
2476 rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk;
2477 rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk;
2478 rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0];
2479 rdev->pm.power_state[state_index].current_clock_mode = &rdev->pm.power_state[state_index].clock_info[0];
2480 rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
2481 if (rdev->asic->get_pcie_lanes)
2482 rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = radeon_get_pcie_lanes(rdev);
2483 else
2484 rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = 16;
2485 rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
2486 rdev->pm.current_power_state = &rdev->pm.power_state[state_index];
2487 rdev->pm.num_power_states = state_index + 1;
2488}
2489
Alex Deucherfcec5702009-11-10 21:25:07 -05002490void radeon_external_tmds_setup(struct drm_encoder *encoder)
2491{
2492 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2493 struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
2494
2495 if (!tmds)
2496 return;
2497
2498 switch (tmds->dvo_chip) {
2499 case DVO_SIL164:
2500 /* sil 164 */
Alex Deucher5a6f98f2009-12-22 15:04:48 -05002501 radeon_i2c_put_byte(tmds->i2c_bus,
2502 tmds->slave_addr,
2503 0x08, 0x30);
2504 radeon_i2c_put_byte(tmds->i2c_bus,
Alex Deucherfcec5702009-11-10 21:25:07 -05002505 tmds->slave_addr,
2506 0x09, 0x00);
Alex Deucher5a6f98f2009-12-22 15:04:48 -05002507 radeon_i2c_put_byte(tmds->i2c_bus,
2508 tmds->slave_addr,
2509 0x0a, 0x90);
2510 radeon_i2c_put_byte(tmds->i2c_bus,
2511 tmds->slave_addr,
2512 0x0c, 0x89);
2513 radeon_i2c_put_byte(tmds->i2c_bus,
Alex Deucherfcec5702009-11-10 21:25:07 -05002514 tmds->slave_addr,
2515 0x08, 0x3b);
Alex Deucherfcec5702009-11-10 21:25:07 -05002516 break;
2517 case DVO_SIL1178:
2518 /* sil 1178 - untested */
2519 /*
2520 * 0x0f, 0x44
2521 * 0x0f, 0x4c
2522 * 0x0e, 0x01
2523 * 0x0a, 0x80
2524 * 0x09, 0x30
2525 * 0x0c, 0xc9
2526 * 0x0d, 0x70
2527 * 0x08, 0x32
2528 * 0x08, 0x33
2529 */
2530 break;
2531 default:
2532 break;
2533 }
2534
2535}
2536
2537bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder)
2538{
2539 struct drm_device *dev = encoder->dev;
2540 struct radeon_device *rdev = dev->dev_private;
2541 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2542 uint16_t offset;
2543 uint8_t blocks, slave_addr, rev;
2544 uint32_t index, id;
2545 uint32_t reg, val, and_mask, or_mask;
2546 struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
2547
2548 if (rdev->bios == NULL)
2549 return false;
2550
2551 if (!tmds)
2552 return false;
2553
2554 if (rdev->flags & RADEON_IS_IGP) {
2555 offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE);
2556 rev = RBIOS8(offset);
2557 if (offset) {
2558 rev = RBIOS8(offset);
2559 if (rev > 1) {
2560 blocks = RBIOS8(offset + 3);
2561 index = offset + 4;
2562 while (blocks > 0) {
2563 id = RBIOS16(index);
2564 index += 2;
2565 switch (id >> 13) {
2566 case 0:
2567 reg = (id & 0x1fff) * 4;
2568 val = RBIOS32(index);
2569 index += 4;
2570 WREG32(reg, val);
2571 break;
2572 case 2:
2573 reg = (id & 0x1fff) * 4;
2574 and_mask = RBIOS32(index);
2575 index += 4;
2576 or_mask = RBIOS32(index);
2577 index += 4;
2578 val = RREG32(reg);
2579 val = (val & and_mask) | or_mask;
2580 WREG32(reg, val);
2581 break;
2582 case 3:
2583 val = RBIOS16(index);
2584 index += 2;
2585 udelay(val);
2586 break;
2587 case 4:
2588 val = RBIOS16(index);
2589 index += 2;
2590 udelay(val * 1000);
2591 break;
2592 case 6:
2593 slave_addr = id & 0xff;
2594 slave_addr >>= 1; /* 7 bit addressing */
2595 index++;
2596 reg = RBIOS8(index);
2597 index++;
2598 val = RBIOS8(index);
2599 index++;
Alex Deucher5a6f98f2009-12-22 15:04:48 -05002600 radeon_i2c_put_byte(tmds->i2c_bus,
2601 slave_addr,
2602 reg, val);
Alex Deucherfcec5702009-11-10 21:25:07 -05002603 break;
2604 default:
2605 DRM_ERROR("Unknown id %d\n", id >> 13);
2606 break;
2607 }
2608 blocks--;
2609 }
2610 return true;
2611 }
2612 }
2613 } else {
2614 offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
2615 if (offset) {
2616 index = offset + 10;
2617 id = RBIOS16(index);
2618 while (id != 0xffff) {
2619 index += 2;
2620 switch (id >> 13) {
2621 case 0:
2622 reg = (id & 0x1fff) * 4;
2623 val = RBIOS32(index);
2624 WREG32(reg, val);
2625 break;
2626 case 2:
2627 reg = (id & 0x1fff) * 4;
2628 and_mask = RBIOS32(index);
2629 index += 4;
2630 or_mask = RBIOS32(index);
2631 index += 4;
2632 val = RREG32(reg);
2633 val = (val & and_mask) | or_mask;
2634 WREG32(reg, val);
2635 break;
2636 case 4:
2637 val = RBIOS16(index);
2638 index += 2;
2639 udelay(val);
2640 break;
2641 case 5:
2642 reg = id & 0x1fff;
2643 and_mask = RBIOS32(index);
2644 index += 4;
2645 or_mask = RBIOS32(index);
2646 index += 4;
2647 val = RREG32_PLL(reg);
2648 val = (val & and_mask) | or_mask;
2649 WREG32_PLL(reg, val);
2650 break;
2651 case 6:
2652 reg = id & 0x1fff;
2653 val = RBIOS8(index);
2654 index += 1;
Alex Deucher5a6f98f2009-12-22 15:04:48 -05002655 radeon_i2c_put_byte(tmds->i2c_bus,
2656 tmds->slave_addr,
2657 reg, val);
Alex Deucherfcec5702009-11-10 21:25:07 -05002658 break;
2659 default:
2660 DRM_ERROR("Unknown id %d\n", id >> 13);
2661 break;
2662 }
2663 id = RBIOS16(index);
2664 }
2665 return true;
2666 }
2667 }
2668 return false;
2669}
2670
Jerome Glisse771fe6b2009-06-05 14:42:42 +02002671static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset)
2672{
2673 struct radeon_device *rdev = dev->dev_private;
2674
2675 if (offset) {
2676 while (RBIOS16(offset)) {
2677 uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13);
2678 uint32_t addr = (RBIOS16(offset) & 0x1fff);
2679 uint32_t val, and_mask, or_mask;
2680 uint32_t tmp;
2681
2682 offset += 2;
2683 switch (cmd) {
2684 case 0:
2685 val = RBIOS32(offset);
2686 offset += 4;
2687 WREG32(addr, val);
2688 break;
2689 case 1:
2690 val = RBIOS32(offset);
2691 offset += 4;
2692 WREG32(addr, val);
2693 break;
2694 case 2:
2695 and_mask = RBIOS32(offset);
2696 offset += 4;
2697 or_mask = RBIOS32(offset);
2698 offset += 4;
2699 tmp = RREG32(addr);
2700 tmp &= and_mask;
2701 tmp |= or_mask;
2702 WREG32(addr, tmp);
2703 break;
2704 case 3:
2705 and_mask = RBIOS32(offset);
2706 offset += 4;
2707 or_mask = RBIOS32(offset);
2708 offset += 4;
2709 tmp = RREG32(addr);
2710 tmp &= and_mask;
2711 tmp |= or_mask;
2712 WREG32(addr, tmp);
2713 break;
2714 case 4:
2715 val = RBIOS16(offset);
2716 offset += 2;
2717 udelay(val);
2718 break;
2719 case 5:
2720 val = RBIOS16(offset);
2721 offset += 2;
2722 switch (addr) {
2723 case 8:
2724 while (val--) {
2725 if (!
2726 (RREG32_PLL
2727 (RADEON_CLK_PWRMGT_CNTL) &
2728 RADEON_MC_BUSY))
2729 break;
2730 }
2731 break;
2732 case 9:
2733 while (val--) {
2734 if ((RREG32(RADEON_MC_STATUS) &
2735 RADEON_MC_IDLE))
2736 break;
2737 }
2738 break;
2739 default:
2740 break;
2741 }
2742 break;
2743 default:
2744 break;
2745 }
2746 }
2747 }
2748}
2749
2750static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset)
2751{
2752 struct radeon_device *rdev = dev->dev_private;
2753
2754 if (offset) {
2755 while (RBIOS8(offset)) {
2756 uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6);
2757 uint8_t addr = (RBIOS8(offset) & 0x3f);
2758 uint32_t val, shift, tmp;
2759 uint32_t and_mask, or_mask;
2760
2761 offset++;
2762 switch (cmd) {
2763 case 0:
2764 val = RBIOS32(offset);
2765 offset += 4;
2766 WREG32_PLL(addr, val);
2767 break;
2768 case 1:
2769 shift = RBIOS8(offset) * 8;
2770 offset++;
2771 and_mask = RBIOS8(offset) << shift;
2772 and_mask |= ~(0xff << shift);
2773 offset++;
2774 or_mask = RBIOS8(offset) << shift;
2775 offset++;
2776 tmp = RREG32_PLL(addr);
2777 tmp &= and_mask;
2778 tmp |= or_mask;
2779 WREG32_PLL(addr, tmp);
2780 break;
2781 case 2:
2782 case 3:
2783 tmp = 1000;
2784 switch (addr) {
2785 case 1:
2786 udelay(150);
2787 break;
2788 case 2:
2789 udelay(1000);
2790 break;
2791 case 3:
2792 while (tmp--) {
2793 if (!
2794 (RREG32_PLL
2795 (RADEON_CLK_PWRMGT_CNTL) &
2796 RADEON_MC_BUSY))
2797 break;
2798 }
2799 break;
2800 case 4:
2801 while (tmp--) {
2802 if (RREG32_PLL
2803 (RADEON_CLK_PWRMGT_CNTL) &
2804 RADEON_DLL_READY)
2805 break;
2806 }
2807 break;
2808 case 5:
2809 tmp =
2810 RREG32_PLL(RADEON_CLK_PWRMGT_CNTL);
2811 if (tmp & RADEON_CG_NO1_DEBUG_0) {
2812#if 0
2813 uint32_t mclk_cntl =
2814 RREG32_PLL
2815 (RADEON_MCLK_CNTL);
2816 mclk_cntl &= 0xffff0000;
2817 /*mclk_cntl |= 0x00001111;*//* ??? */
2818 WREG32_PLL(RADEON_MCLK_CNTL,
2819 mclk_cntl);
2820 udelay(10000);
2821#endif
2822 WREG32_PLL
2823 (RADEON_CLK_PWRMGT_CNTL,
2824 tmp &
2825 ~RADEON_CG_NO1_DEBUG_0);
2826 udelay(10000);
2827 }
2828 break;
2829 default:
2830 break;
2831 }
2832 break;
2833 default:
2834 break;
2835 }
2836 }
2837 }
2838}
2839
2840static void combios_parse_ram_reset_table(struct drm_device *dev,
2841 uint16_t offset)
2842{
2843 struct radeon_device *rdev = dev->dev_private;
2844 uint32_t tmp;
2845
2846 if (offset) {
2847 uint8_t val = RBIOS8(offset);
2848 while (val != 0xff) {
2849 offset++;
2850
2851 if (val == 0x0f) {
2852 uint32_t channel_complete_mask;
2853
2854 if (ASIC_IS_R300(rdev))
2855 channel_complete_mask =
2856 R300_MEM_PWRUP_COMPLETE;
2857 else
2858 channel_complete_mask =
2859 RADEON_MEM_PWRUP_COMPLETE;
2860 tmp = 20000;
2861 while (tmp--) {
2862 if ((RREG32(RADEON_MEM_STR_CNTL) &
2863 channel_complete_mask) ==
2864 channel_complete_mask)
2865 break;
2866 }
2867 } else {
2868 uint32_t or_mask = RBIOS16(offset);
2869 offset += 2;
2870
2871 tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG);
2872 tmp &= RADEON_SDRAM_MODE_MASK;
2873 tmp |= or_mask;
2874 WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp);
2875
2876 or_mask = val << 24;
2877 tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG);
2878 tmp &= RADEON_B3MEM_RESET_MASK;
2879 tmp |= or_mask;
2880 WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp);
2881 }
2882 val = RBIOS8(offset);
2883 }
2884 }
2885}
2886
2887static uint32_t combios_detect_ram(struct drm_device *dev, int ram,
2888 int mem_addr_mapping)
2889{
2890 struct radeon_device *rdev = dev->dev_private;
2891 uint32_t mem_cntl;
2892 uint32_t mem_size;
2893 uint32_t addr = 0;
2894
2895 mem_cntl = RREG32(RADEON_MEM_CNTL);
2896 if (mem_cntl & RV100_HALF_MODE)
2897 ram /= 2;
2898 mem_size = ram;
2899 mem_cntl &= ~(0xff << 8);
2900 mem_cntl |= (mem_addr_mapping & 0xff) << 8;
2901 WREG32(RADEON_MEM_CNTL, mem_cntl);
2902 RREG32(RADEON_MEM_CNTL);
2903
2904 /* sdram reset ? */
2905
2906 /* something like this???? */
2907 while (ram--) {
2908 addr = ram * 1024 * 1024;
2909 /* write to each page */
2910 WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER);
2911 WREG32(RADEON_MM_DATA, 0xdeadbeef);
2912 /* read back and verify */
2913 WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER);
2914 if (RREG32(RADEON_MM_DATA) != 0xdeadbeef)
2915 return 0;
2916 }
2917
2918 return mem_size;
2919}
2920
2921static void combios_write_ram_size(struct drm_device *dev)
2922{
2923 struct radeon_device *rdev = dev->dev_private;
2924 uint8_t rev;
2925 uint16_t offset;
2926 uint32_t mem_size = 0;
2927 uint32_t mem_cntl = 0;
2928
2929 /* should do something smarter here I guess... */
2930 if (rdev->flags & RADEON_IS_IGP)
2931 return;
2932
2933 /* first check detected mem table */
2934 offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE);
2935 if (offset) {
2936 rev = RBIOS8(offset);
2937 if (rev < 3) {
2938 mem_cntl = RBIOS32(offset + 1);
2939 mem_size = RBIOS16(offset + 5);
2940 if (((rdev->flags & RADEON_FAMILY_MASK) < CHIP_R200) &&
2941 ((dev->pdev->device != 0x515e)
2942 && (dev->pdev->device != 0x5969)))
2943 WREG32(RADEON_MEM_CNTL, mem_cntl);
2944 }
2945 }
2946
2947 if (!mem_size) {
2948 offset =
2949 combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE);
2950 if (offset) {
2951 rev = RBIOS8(offset - 1);
2952 if (rev < 1) {
2953 if (((rdev->flags & RADEON_FAMILY_MASK) <
2954 CHIP_R200)
2955 && ((dev->pdev->device != 0x515e)
2956 && (dev->pdev->device != 0x5969))) {
2957 int ram = 0;
2958 int mem_addr_mapping = 0;
2959
2960 while (RBIOS8(offset)) {
2961 ram = RBIOS8(offset);
2962 mem_addr_mapping =
2963 RBIOS8(offset + 1);
2964 if (mem_addr_mapping != 0x25)
2965 ram *= 2;
2966 mem_size =
2967 combios_detect_ram(dev, ram,
2968 mem_addr_mapping);
2969 if (mem_size)
2970 break;
2971 offset += 2;
2972 }
2973 } else
2974 mem_size = RBIOS8(offset);
2975 } else {
2976 mem_size = RBIOS8(offset);
2977 mem_size *= 2; /* convert to MB */
2978 }
2979 }
2980 }
2981
2982 mem_size *= (1024 * 1024); /* convert to bytes */
2983 WREG32(RADEON_CONFIG_MEMSIZE, mem_size);
2984}
2985
2986void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable)
2987{
2988 uint16_t dyn_clk_info =
2989 combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
2990
2991 if (dyn_clk_info)
2992 combios_parse_pll_table(dev, dyn_clk_info);
2993}
2994
2995void radeon_combios_asic_init(struct drm_device *dev)
2996{
2997 struct radeon_device *rdev = dev->dev_private;
2998 uint16_t table;
2999
3000 /* port hardcoded mac stuff from radeonfb */
3001 if (rdev->bios == NULL)
3002 return;
3003
3004 /* ASIC INIT 1 */
3005 table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE);
3006 if (table)
3007 combios_parse_mmio_table(dev, table);
3008
3009 /* PLL INIT */
3010 table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE);
3011 if (table)
3012 combios_parse_pll_table(dev, table);
3013
3014 /* ASIC INIT 2 */
3015 table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE);
3016 if (table)
3017 combios_parse_mmio_table(dev, table);
3018
3019 if (!(rdev->flags & RADEON_IS_IGP)) {
3020 /* ASIC INIT 4 */
3021 table =
3022 combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE);
3023 if (table)
3024 combios_parse_mmio_table(dev, table);
3025
3026 /* RAM RESET */
3027 table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE);
3028 if (table)
3029 combios_parse_ram_reset_table(dev, table);
3030
3031 /* ASIC INIT 3 */
3032 table =
3033 combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE);
3034 if (table)
3035 combios_parse_mmio_table(dev, table);
3036
3037 /* write CONFIG_MEMSIZE */
3038 combios_write_ram_size(dev);
3039 }
3040
3041 /* DYN CLK 1 */
3042 table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
3043 if (table)
3044 combios_parse_pll_table(dev, table);
3045
3046}
3047
3048void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev)
3049{
3050 struct radeon_device *rdev = dev->dev_private;
3051 uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch;
3052
3053 bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH);
3054 bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
3055 bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH);
3056
3057 /* let the bios control the backlight */
3058 bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN;
3059
3060 /* tell the bios not to handle mode switching */
3061 bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS |
3062 RADEON_ACC_MODE_CHANGE);
3063
3064 /* tell the bios a driver is loaded */
3065 bios_7_scratch |= RADEON_DRV_LOADED;
3066
3067 WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch);
3068 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
3069 WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch);
3070}
3071
3072void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock)
3073{
3074 struct drm_device *dev = encoder->dev;
3075 struct radeon_device *rdev = dev->dev_private;
3076 uint32_t bios_6_scratch;
3077
3078 bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
3079
3080 if (lock)
3081 bios_6_scratch |= RADEON_DRIVER_CRITICAL;
3082 else
3083 bios_6_scratch &= ~RADEON_DRIVER_CRITICAL;
3084
3085 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
3086}
3087
3088void
3089radeon_combios_connected_scratch_regs(struct drm_connector *connector,
3090 struct drm_encoder *encoder,
3091 bool connected)
3092{
3093 struct drm_device *dev = connector->dev;
3094 struct radeon_device *rdev = dev->dev_private;
3095 struct radeon_connector *radeon_connector =
3096 to_radeon_connector(connector);
3097 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
3098 uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH);
3099 uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH);
3100
3101 if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) &&
3102 (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) {
3103 if (connected) {
3104 DRM_DEBUG("TV1 connected\n");
3105 /* fix me */
3106 bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO;
3107 /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */
3108 bios_5_scratch |= RADEON_TV1_ON;
3109 bios_5_scratch |= RADEON_ACC_REQ_TV1;
3110 } else {
3111 DRM_DEBUG("TV1 disconnected\n");
3112 bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK;
3113 bios_5_scratch &= ~RADEON_TV1_ON;
3114 bios_5_scratch &= ~RADEON_ACC_REQ_TV1;
3115 }
3116 }
3117 if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) &&
3118 (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) {
3119 if (connected) {
3120 DRM_DEBUG("LCD1 connected\n");
3121 bios_4_scratch |= RADEON_LCD1_ATTACHED;
3122 bios_5_scratch |= RADEON_LCD1_ON;
3123 bios_5_scratch |= RADEON_ACC_REQ_LCD1;
3124 } else {
3125 DRM_DEBUG("LCD1 disconnected\n");
3126 bios_4_scratch &= ~RADEON_LCD1_ATTACHED;
3127 bios_5_scratch &= ~RADEON_LCD1_ON;
3128 bios_5_scratch &= ~RADEON_ACC_REQ_LCD1;
3129 }
3130 }
3131 if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) &&
3132 (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) {
3133 if (connected) {
3134 DRM_DEBUG("CRT1 connected\n");
3135 bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR;
3136 bios_5_scratch |= RADEON_CRT1_ON;
3137 bios_5_scratch |= RADEON_ACC_REQ_CRT1;
3138 } else {
3139 DRM_DEBUG("CRT1 disconnected\n");
3140 bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK;
3141 bios_5_scratch &= ~RADEON_CRT1_ON;
3142 bios_5_scratch &= ~RADEON_ACC_REQ_CRT1;
3143 }
3144 }
3145 if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) &&
3146 (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) {
3147 if (connected) {
3148 DRM_DEBUG("CRT2 connected\n");
3149 bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR;
3150 bios_5_scratch |= RADEON_CRT2_ON;
3151 bios_5_scratch |= RADEON_ACC_REQ_CRT2;
3152 } else {
3153 DRM_DEBUG("CRT2 disconnected\n");
3154 bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK;
3155 bios_5_scratch &= ~RADEON_CRT2_ON;
3156 bios_5_scratch &= ~RADEON_ACC_REQ_CRT2;
3157 }
3158 }
3159 if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) &&
3160 (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) {
3161 if (connected) {
3162 DRM_DEBUG("DFP1 connected\n");
3163 bios_4_scratch |= RADEON_DFP1_ATTACHED;
3164 bios_5_scratch |= RADEON_DFP1_ON;
3165 bios_5_scratch |= RADEON_ACC_REQ_DFP1;
3166 } else {
3167 DRM_DEBUG("DFP1 disconnected\n");
3168 bios_4_scratch &= ~RADEON_DFP1_ATTACHED;
3169 bios_5_scratch &= ~RADEON_DFP1_ON;
3170 bios_5_scratch &= ~RADEON_ACC_REQ_DFP1;
3171 }
3172 }
3173 if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) &&
3174 (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) {
3175 if (connected) {
3176 DRM_DEBUG("DFP2 connected\n");
3177 bios_4_scratch |= RADEON_DFP2_ATTACHED;
3178 bios_5_scratch |= RADEON_DFP2_ON;
3179 bios_5_scratch |= RADEON_ACC_REQ_DFP2;
3180 } else {
3181 DRM_DEBUG("DFP2 disconnected\n");
3182 bios_4_scratch &= ~RADEON_DFP2_ATTACHED;
3183 bios_5_scratch &= ~RADEON_DFP2_ON;
3184 bios_5_scratch &= ~RADEON_ACC_REQ_DFP2;
3185 }
3186 }
3187 WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch);
3188 WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch);
3189}
3190
3191void
3192radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc)
3193{
3194 struct drm_device *dev = encoder->dev;
3195 struct radeon_device *rdev = dev->dev_private;
3196 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
3197 uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH);
3198
3199 if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) {
3200 bios_5_scratch &= ~RADEON_TV1_CRTC_MASK;
3201 bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT);
3202 }
3203 if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) {
3204 bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK;
3205 bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT);
3206 }
3207 if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) {
3208 bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK;
3209 bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT);
3210 }
3211 if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) {
3212 bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK;
3213 bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT);
3214 }
3215 if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) {
3216 bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK;
3217 bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT);
3218 }
3219 if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) {
3220 bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK;
3221 bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT);
3222 }
3223 WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch);
3224}
3225
3226void
3227radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on)
3228{
3229 struct drm_device *dev = encoder->dev;
3230 struct radeon_device *rdev = dev->dev_private;
3231 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
3232 uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
3233
3234 if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) {
3235 if (on)
3236 bios_6_scratch |= RADEON_TV_DPMS_ON;
3237 else
3238 bios_6_scratch &= ~RADEON_TV_DPMS_ON;
3239 }
3240 if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) {
3241 if (on)
3242 bios_6_scratch |= RADEON_CRT_DPMS_ON;
3243 else
3244 bios_6_scratch &= ~RADEON_CRT_DPMS_ON;
3245 }
3246 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
3247 if (on)
3248 bios_6_scratch |= RADEON_LCD_DPMS_ON;
3249 else
3250 bios_6_scratch &= ~RADEON_LCD_DPMS_ON;
3251 }
3252 if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
3253 if (on)
3254 bios_6_scratch |= RADEON_DFP_DPMS_ON;
3255 else
3256 bios_6_scratch &= ~RADEON_DFP_DPMS_ON;
3257 }
3258 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
3259}