Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1 | /* |
| 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 */ |
| 41 | extern uint32_t |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 42 | radeon_get_encoder_enum(struct drm_device *dev, uint32_t supported_device, |
| 43 | uint8_t dac); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 44 | extern void radeon_link_encoder_connector(struct drm_device *dev); |
| 45 | |
| 46 | /* from radeon_connector.c */ |
| 47 | extern void |
| 48 | radeon_add_legacy_connector(struct drm_device *dev, |
| 49 | uint32_t connector_id, |
| 50 | uint32_t supported_device, |
| 51 | int connector_type, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 52 | struct radeon_i2c_bus_rec *i2c_bus, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 53 | uint16_t connector_object_id, |
| 54 | struct radeon_hpd *hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 55 | |
| 56 | /* from radeon_legacy_encoder.c */ |
| 57 | extern void |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 58 | radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_enum, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 59 | uint32_t supported_device); |
| 60 | |
| 61 | /* old legacy ATI BIOS routines */ |
| 62 | |
| 63 | /* COMBIOS table offsets */ |
| 64 | enum radeon_combios_table_offset { |
| 65 | /* absolute offset tables */ |
| 66 | COMBIOS_ASIC_INIT_1_TABLE, |
| 67 | COMBIOS_BIOS_SUPPORT_TABLE, |
| 68 | COMBIOS_DAC_PROGRAMMING_TABLE, |
| 69 | COMBIOS_MAX_COLOR_DEPTH_TABLE, |
| 70 | COMBIOS_CRTC_INFO_TABLE, |
| 71 | COMBIOS_PLL_INFO_TABLE, |
| 72 | COMBIOS_TV_INFO_TABLE, |
| 73 | COMBIOS_DFP_INFO_TABLE, |
| 74 | COMBIOS_HW_CONFIG_INFO_TABLE, |
| 75 | COMBIOS_MULTIMEDIA_INFO_TABLE, |
| 76 | COMBIOS_TV_STD_PATCH_TABLE, |
| 77 | COMBIOS_LCD_INFO_TABLE, |
| 78 | COMBIOS_MOBILE_INFO_TABLE, |
| 79 | COMBIOS_PLL_INIT_TABLE, |
| 80 | COMBIOS_MEM_CONFIG_TABLE, |
| 81 | COMBIOS_SAVE_MASK_TABLE, |
| 82 | COMBIOS_HARDCODED_EDID_TABLE, |
| 83 | COMBIOS_ASIC_INIT_2_TABLE, |
| 84 | COMBIOS_CONNECTOR_INFO_TABLE, |
| 85 | COMBIOS_DYN_CLK_1_TABLE, |
| 86 | COMBIOS_RESERVED_MEM_TABLE, |
| 87 | COMBIOS_EXT_TMDS_INFO_TABLE, |
| 88 | COMBIOS_MEM_CLK_INFO_TABLE, |
| 89 | COMBIOS_EXT_DAC_INFO_TABLE, |
| 90 | COMBIOS_MISC_INFO_TABLE, |
| 91 | COMBIOS_CRT_INFO_TABLE, |
| 92 | COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE, |
| 93 | COMBIOS_COMPONENT_VIDEO_INFO_TABLE, |
| 94 | COMBIOS_FAN_SPEED_INFO_TABLE, |
| 95 | COMBIOS_OVERDRIVE_INFO_TABLE, |
| 96 | COMBIOS_OEM_INFO_TABLE, |
| 97 | COMBIOS_DYN_CLK_2_TABLE, |
| 98 | COMBIOS_POWER_CONNECTOR_INFO_TABLE, |
| 99 | COMBIOS_I2C_INFO_TABLE, |
| 100 | /* relative offset tables */ |
| 101 | COMBIOS_ASIC_INIT_3_TABLE, /* offset from misc info */ |
| 102 | COMBIOS_ASIC_INIT_4_TABLE, /* offset from misc info */ |
| 103 | COMBIOS_DETECTED_MEM_TABLE, /* offset from misc info */ |
| 104 | COMBIOS_ASIC_INIT_5_TABLE, /* offset from misc info */ |
| 105 | COMBIOS_RAM_RESET_TABLE, /* offset from mem config */ |
| 106 | COMBIOS_POWERPLAY_INFO_TABLE, /* offset from mobile info */ |
| 107 | COMBIOS_GPIO_INFO_TABLE, /* offset from mobile info */ |
| 108 | COMBIOS_LCD_DDC_INFO_TABLE, /* offset from mobile info */ |
| 109 | COMBIOS_TMDS_POWER_TABLE, /* offset from mobile info */ |
| 110 | COMBIOS_TMDS_POWER_ON_TABLE, /* offset from tmds power */ |
| 111 | COMBIOS_TMDS_POWER_OFF_TABLE, /* offset from tmds power */ |
| 112 | }; |
| 113 | |
| 114 | enum 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 | |
| 124 | enum radeon_combios_connector { |
| 125 | CONNECTOR_NONE_LEGACY, |
| 126 | CONNECTOR_PROPRIETARY_LEGACY, |
| 127 | CONNECTOR_CRT_LEGACY, |
| 128 | CONNECTOR_DVI_I_LEGACY, |
| 129 | CONNECTOR_DVI_D_LEGACY, |
| 130 | CONNECTOR_CTV_LEGACY, |
| 131 | CONNECTOR_STV_LEGACY, |
| 132 | CONNECTOR_UNSUPPORTED_LEGACY |
| 133 | }; |
| 134 | |
| 135 | const int legacy_connector_convert[] = { |
| 136 | DRM_MODE_CONNECTOR_Unknown, |
| 137 | DRM_MODE_CONNECTOR_DVID, |
| 138 | DRM_MODE_CONNECTOR_VGA, |
| 139 | DRM_MODE_CONNECTOR_DVII, |
| 140 | DRM_MODE_CONNECTOR_DVID, |
| 141 | DRM_MODE_CONNECTOR_Composite, |
| 142 | DRM_MODE_CONNECTOR_SVIDEO, |
| 143 | DRM_MODE_CONNECTOR_Unknown, |
| 144 | }; |
| 145 | |
| 146 | static 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 | |
Michel Dänzer | 03047cd | 2010-02-10 11:05:11 +0100 | [diff] [blame] | 153 | if (!rdev->bios) |
| 154 | return 0; |
| 155 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 156 | switch (table) { |
| 157 | /* absolute offset tables */ |
| 158 | case COMBIOS_ASIC_INIT_1_TABLE: |
| 159 | check_offset = RBIOS16(rdev->bios_header_start + 0xc); |
| 160 | if (check_offset) |
| 161 | offset = check_offset; |
| 162 | break; |
| 163 | case COMBIOS_BIOS_SUPPORT_TABLE: |
| 164 | check_offset = RBIOS16(rdev->bios_header_start + 0x14); |
| 165 | if (check_offset) |
| 166 | offset = check_offset; |
| 167 | break; |
| 168 | case COMBIOS_DAC_PROGRAMMING_TABLE: |
| 169 | check_offset = RBIOS16(rdev->bios_header_start + 0x2a); |
| 170 | if (check_offset) |
| 171 | offset = check_offset; |
| 172 | break; |
| 173 | case COMBIOS_MAX_COLOR_DEPTH_TABLE: |
| 174 | check_offset = RBIOS16(rdev->bios_header_start + 0x2c); |
| 175 | if (check_offset) |
| 176 | offset = check_offset; |
| 177 | break; |
| 178 | case COMBIOS_CRTC_INFO_TABLE: |
| 179 | check_offset = RBIOS16(rdev->bios_header_start + 0x2e); |
| 180 | if (check_offset) |
| 181 | offset = check_offset; |
| 182 | break; |
| 183 | case COMBIOS_PLL_INFO_TABLE: |
| 184 | check_offset = RBIOS16(rdev->bios_header_start + 0x30); |
| 185 | if (check_offset) |
| 186 | offset = check_offset; |
| 187 | break; |
| 188 | case COMBIOS_TV_INFO_TABLE: |
| 189 | check_offset = RBIOS16(rdev->bios_header_start + 0x32); |
| 190 | if (check_offset) |
| 191 | offset = check_offset; |
| 192 | break; |
| 193 | case COMBIOS_DFP_INFO_TABLE: |
| 194 | check_offset = RBIOS16(rdev->bios_header_start + 0x34); |
| 195 | if (check_offset) |
| 196 | offset = check_offset; |
| 197 | break; |
| 198 | case COMBIOS_HW_CONFIG_INFO_TABLE: |
| 199 | check_offset = RBIOS16(rdev->bios_header_start + 0x36); |
| 200 | if (check_offset) |
| 201 | offset = check_offset; |
| 202 | break; |
| 203 | case COMBIOS_MULTIMEDIA_INFO_TABLE: |
| 204 | check_offset = RBIOS16(rdev->bios_header_start + 0x38); |
| 205 | if (check_offset) |
| 206 | offset = check_offset; |
| 207 | break; |
| 208 | case COMBIOS_TV_STD_PATCH_TABLE: |
| 209 | check_offset = RBIOS16(rdev->bios_header_start + 0x3e); |
| 210 | if (check_offset) |
| 211 | offset = check_offset; |
| 212 | break; |
| 213 | case COMBIOS_LCD_INFO_TABLE: |
| 214 | check_offset = RBIOS16(rdev->bios_header_start + 0x40); |
| 215 | if (check_offset) |
| 216 | offset = check_offset; |
| 217 | break; |
| 218 | case COMBIOS_MOBILE_INFO_TABLE: |
| 219 | check_offset = RBIOS16(rdev->bios_header_start + 0x42); |
| 220 | if (check_offset) |
| 221 | offset = check_offset; |
| 222 | break; |
| 223 | case COMBIOS_PLL_INIT_TABLE: |
| 224 | check_offset = RBIOS16(rdev->bios_header_start + 0x46); |
| 225 | if (check_offset) |
| 226 | offset = check_offset; |
| 227 | break; |
| 228 | case COMBIOS_MEM_CONFIG_TABLE: |
| 229 | check_offset = RBIOS16(rdev->bios_header_start + 0x48); |
| 230 | if (check_offset) |
| 231 | offset = check_offset; |
| 232 | break; |
| 233 | case COMBIOS_SAVE_MASK_TABLE: |
| 234 | check_offset = RBIOS16(rdev->bios_header_start + 0x4a); |
| 235 | if (check_offset) |
| 236 | offset = check_offset; |
| 237 | break; |
| 238 | case COMBIOS_HARDCODED_EDID_TABLE: |
| 239 | check_offset = RBIOS16(rdev->bios_header_start + 0x4c); |
| 240 | if (check_offset) |
| 241 | offset = check_offset; |
| 242 | break; |
| 243 | case COMBIOS_ASIC_INIT_2_TABLE: |
| 244 | check_offset = RBIOS16(rdev->bios_header_start + 0x4e); |
| 245 | if (check_offset) |
| 246 | offset = check_offset; |
| 247 | break; |
| 248 | case COMBIOS_CONNECTOR_INFO_TABLE: |
| 249 | check_offset = RBIOS16(rdev->bios_header_start + 0x50); |
| 250 | if (check_offset) |
| 251 | offset = check_offset; |
| 252 | break; |
| 253 | case COMBIOS_DYN_CLK_1_TABLE: |
| 254 | check_offset = RBIOS16(rdev->bios_header_start + 0x52); |
| 255 | if (check_offset) |
| 256 | offset = check_offset; |
| 257 | break; |
| 258 | case COMBIOS_RESERVED_MEM_TABLE: |
| 259 | check_offset = RBIOS16(rdev->bios_header_start + 0x54); |
| 260 | if (check_offset) |
| 261 | offset = check_offset; |
| 262 | break; |
| 263 | case COMBIOS_EXT_TMDS_INFO_TABLE: |
| 264 | check_offset = RBIOS16(rdev->bios_header_start + 0x58); |
| 265 | if (check_offset) |
| 266 | offset = check_offset; |
| 267 | break; |
| 268 | case COMBIOS_MEM_CLK_INFO_TABLE: |
| 269 | check_offset = RBIOS16(rdev->bios_header_start + 0x5a); |
| 270 | if (check_offset) |
| 271 | offset = check_offset; |
| 272 | break; |
| 273 | case COMBIOS_EXT_DAC_INFO_TABLE: |
| 274 | check_offset = RBIOS16(rdev->bios_header_start + 0x5c); |
| 275 | if (check_offset) |
| 276 | offset = check_offset; |
| 277 | break; |
| 278 | case COMBIOS_MISC_INFO_TABLE: |
| 279 | check_offset = RBIOS16(rdev->bios_header_start + 0x5e); |
| 280 | if (check_offset) |
| 281 | offset = check_offset; |
| 282 | break; |
| 283 | case COMBIOS_CRT_INFO_TABLE: |
| 284 | check_offset = RBIOS16(rdev->bios_header_start + 0x60); |
| 285 | if (check_offset) |
| 286 | offset = check_offset; |
| 287 | break; |
| 288 | case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE: |
| 289 | check_offset = RBIOS16(rdev->bios_header_start + 0x62); |
| 290 | if (check_offset) |
| 291 | offset = check_offset; |
| 292 | break; |
| 293 | case COMBIOS_COMPONENT_VIDEO_INFO_TABLE: |
| 294 | check_offset = RBIOS16(rdev->bios_header_start + 0x64); |
| 295 | if (check_offset) |
| 296 | offset = check_offset; |
| 297 | break; |
| 298 | case COMBIOS_FAN_SPEED_INFO_TABLE: |
| 299 | check_offset = RBIOS16(rdev->bios_header_start + 0x66); |
| 300 | if (check_offset) |
| 301 | offset = check_offset; |
| 302 | break; |
| 303 | case COMBIOS_OVERDRIVE_INFO_TABLE: |
| 304 | check_offset = RBIOS16(rdev->bios_header_start + 0x68); |
| 305 | if (check_offset) |
| 306 | offset = check_offset; |
| 307 | break; |
| 308 | case COMBIOS_OEM_INFO_TABLE: |
| 309 | check_offset = RBIOS16(rdev->bios_header_start + 0x6a); |
| 310 | if (check_offset) |
| 311 | offset = check_offset; |
| 312 | break; |
| 313 | case COMBIOS_DYN_CLK_2_TABLE: |
| 314 | check_offset = RBIOS16(rdev->bios_header_start + 0x6c); |
| 315 | if (check_offset) |
| 316 | offset = check_offset; |
| 317 | break; |
| 318 | case COMBIOS_POWER_CONNECTOR_INFO_TABLE: |
| 319 | check_offset = RBIOS16(rdev->bios_header_start + 0x6e); |
| 320 | if (check_offset) |
| 321 | offset = check_offset; |
| 322 | break; |
| 323 | case COMBIOS_I2C_INFO_TABLE: |
| 324 | check_offset = RBIOS16(rdev->bios_header_start + 0x70); |
| 325 | if (check_offset) |
| 326 | offset = check_offset; |
| 327 | break; |
| 328 | /* relative offset tables */ |
| 329 | case COMBIOS_ASIC_INIT_3_TABLE: /* offset from misc info */ |
| 330 | check_offset = |
| 331 | combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); |
| 332 | if (check_offset) { |
| 333 | rev = RBIOS8(check_offset); |
| 334 | if (rev > 0) { |
| 335 | check_offset = RBIOS16(check_offset + 0x3); |
| 336 | if (check_offset) |
| 337 | offset = check_offset; |
| 338 | } |
| 339 | } |
| 340 | break; |
| 341 | case COMBIOS_ASIC_INIT_4_TABLE: /* offset from misc info */ |
| 342 | check_offset = |
| 343 | combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); |
| 344 | if (check_offset) { |
| 345 | rev = RBIOS8(check_offset); |
| 346 | if (rev > 0) { |
| 347 | check_offset = RBIOS16(check_offset + 0x5); |
| 348 | if (check_offset) |
| 349 | offset = check_offset; |
| 350 | } |
| 351 | } |
| 352 | break; |
| 353 | case COMBIOS_DETECTED_MEM_TABLE: /* offset from misc info */ |
| 354 | check_offset = |
| 355 | combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); |
| 356 | if (check_offset) { |
| 357 | rev = RBIOS8(check_offset); |
| 358 | if (rev > 0) { |
| 359 | check_offset = RBIOS16(check_offset + 0x7); |
| 360 | if (check_offset) |
| 361 | offset = check_offset; |
| 362 | } |
| 363 | } |
| 364 | break; |
| 365 | case COMBIOS_ASIC_INIT_5_TABLE: /* offset from misc info */ |
| 366 | check_offset = |
| 367 | combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); |
| 368 | if (check_offset) { |
| 369 | rev = RBIOS8(check_offset); |
| 370 | if (rev == 2) { |
| 371 | check_offset = RBIOS16(check_offset + 0x9); |
| 372 | if (check_offset) |
| 373 | offset = check_offset; |
| 374 | } |
| 375 | } |
| 376 | break; |
| 377 | case COMBIOS_RAM_RESET_TABLE: /* offset from mem config */ |
| 378 | check_offset = |
| 379 | combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); |
| 380 | if (check_offset) { |
| 381 | while (RBIOS8(check_offset++)); |
| 382 | check_offset += 2; |
| 383 | if (check_offset) |
| 384 | offset = check_offset; |
| 385 | } |
| 386 | break; |
| 387 | case COMBIOS_POWERPLAY_INFO_TABLE: /* offset from mobile info */ |
| 388 | check_offset = |
| 389 | combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); |
| 390 | if (check_offset) { |
| 391 | check_offset = RBIOS16(check_offset + 0x11); |
| 392 | if (check_offset) |
| 393 | offset = check_offset; |
| 394 | } |
| 395 | break; |
| 396 | case COMBIOS_GPIO_INFO_TABLE: /* offset from mobile info */ |
| 397 | check_offset = |
| 398 | combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); |
| 399 | if (check_offset) { |
| 400 | check_offset = RBIOS16(check_offset + 0x13); |
| 401 | if (check_offset) |
| 402 | offset = check_offset; |
| 403 | } |
| 404 | break; |
| 405 | case COMBIOS_LCD_DDC_INFO_TABLE: /* offset from mobile info */ |
| 406 | check_offset = |
| 407 | combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); |
| 408 | if (check_offset) { |
| 409 | check_offset = RBIOS16(check_offset + 0x15); |
| 410 | if (check_offset) |
| 411 | offset = check_offset; |
| 412 | } |
| 413 | break; |
| 414 | case COMBIOS_TMDS_POWER_TABLE: /* offset from mobile info */ |
| 415 | check_offset = |
| 416 | combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); |
| 417 | if (check_offset) { |
| 418 | check_offset = RBIOS16(check_offset + 0x17); |
| 419 | if (check_offset) |
| 420 | offset = check_offset; |
| 421 | } |
| 422 | break; |
| 423 | case COMBIOS_TMDS_POWER_ON_TABLE: /* offset from tmds power */ |
| 424 | check_offset = |
| 425 | combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); |
| 426 | if (check_offset) { |
| 427 | check_offset = RBIOS16(check_offset + 0x2); |
| 428 | if (check_offset) |
| 429 | offset = check_offset; |
| 430 | } |
| 431 | break; |
| 432 | case COMBIOS_TMDS_POWER_OFF_TABLE: /* offset from tmds power */ |
| 433 | check_offset = |
| 434 | combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); |
| 435 | if (check_offset) { |
| 436 | check_offset = RBIOS16(check_offset + 0x4); |
| 437 | if (check_offset) |
| 438 | offset = check_offset; |
| 439 | } |
| 440 | break; |
| 441 | default: |
| 442 | break; |
| 443 | } |
| 444 | |
| 445 | return offset; |
| 446 | |
| 447 | } |
| 448 | |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 449 | bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev) |
| 450 | { |
Alex Deucher | fafcf94 | 2011-03-23 08:10:10 +0000 | [diff] [blame] | 451 | int edid_info, size; |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 452 | struct edid *edid; |
Adam Jackson | 7466f4c | 2010-03-29 21:43:23 +0000 | [diff] [blame] | 453 | unsigned char *raw; |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 454 | edid_info = combios_get_table_offset(rdev->ddev, COMBIOS_HARDCODED_EDID_TABLE); |
| 455 | if (!edid_info) |
| 456 | return false; |
| 457 | |
Adam Jackson | 7466f4c | 2010-03-29 21:43:23 +0000 | [diff] [blame] | 458 | raw = rdev->bios + edid_info; |
Alex Deucher | fafcf94 | 2011-03-23 08:10:10 +0000 | [diff] [blame] | 459 | size = EDID_LENGTH * (raw[0x7e] + 1); |
| 460 | edid = kmalloc(size, GFP_KERNEL); |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 461 | if (edid == NULL) |
| 462 | return false; |
| 463 | |
Alex Deucher | fafcf94 | 2011-03-23 08:10:10 +0000 | [diff] [blame] | 464 | memcpy((unsigned char *)edid, raw, size); |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 465 | |
| 466 | if (!drm_edid_is_valid(edid)) { |
| 467 | kfree(edid); |
| 468 | return false; |
| 469 | } |
| 470 | |
| 471 | rdev->mode_info.bios_hardcoded_edid = edid; |
Alex Deucher | fafcf94 | 2011-03-23 08:10:10 +0000 | [diff] [blame] | 472 | rdev->mode_info.bios_hardcoded_edid_size = size; |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 473 | return true; |
| 474 | } |
| 475 | |
Alex Deucher | c324acd | 2010-12-08 22:13:06 -0500 | [diff] [blame] | 476 | /* this is used for atom LCDs as well */ |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 477 | struct edid * |
Alex Deucher | c324acd | 2010-12-08 22:13:06 -0500 | [diff] [blame] | 478 | radeon_bios_get_hardcoded_edid(struct radeon_device *rdev) |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 479 | { |
Alex Deucher | fafcf94 | 2011-03-23 08:10:10 +0000 | [diff] [blame] | 480 | struct edid *edid; |
| 481 | |
| 482 | if (rdev->mode_info.bios_hardcoded_edid) { |
| 483 | edid = kmalloc(rdev->mode_info.bios_hardcoded_edid_size, GFP_KERNEL); |
| 484 | if (edid) { |
| 485 | memcpy((unsigned char *)edid, |
| 486 | (unsigned char *)rdev->mode_info.bios_hardcoded_edid, |
| 487 | rdev->mode_info.bios_hardcoded_edid_size); |
| 488 | return edid; |
| 489 | } |
| 490 | } |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 491 | return NULL; |
| 492 | } |
| 493 | |
Alex Deucher | 6a93cb2 | 2009-11-23 17:39:28 -0500 | [diff] [blame] | 494 | static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev, |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 495 | enum radeon_combios_ddc ddc, |
| 496 | u32 clk_mask, |
| 497 | u32 data_mask) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 498 | { |
| 499 | struct radeon_i2c_bus_rec i2c; |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 500 | int ddc_line = 0; |
| 501 | |
| 502 | /* ddc id = mask reg |
| 503 | * DDC_NONE_DETECTED = none |
| 504 | * DDC_DVI = RADEON_GPIO_DVI_DDC |
| 505 | * DDC_VGA = RADEON_GPIO_VGA_DDC |
| 506 | * DDC_LCD = RADEON_GPIOPAD_MASK |
| 507 | * DDC_GPIO = RADEON_MDGPIO_MASK |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 508 | * r1xx |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 509 | * DDC_MONID = RADEON_GPIO_MONID |
| 510 | * DDC_CRT2 = RADEON_GPIO_CRT2_DDC |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 511 | * r200 |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 512 | * DDC_MONID = RADEON_GPIO_MONID |
| 513 | * DDC_CRT2 = RADEON_GPIO_DVI_DDC |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 514 | * r300/r350 |
| 515 | * DDC_MONID = RADEON_GPIO_DVI_DDC |
| 516 | * DDC_CRT2 = RADEON_GPIO_DVI_DDC |
| 517 | * rv2xx/rv3xx |
| 518 | * DDC_MONID = RADEON_GPIO_MONID |
| 519 | * DDC_CRT2 = RADEON_GPIO_MONID |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 520 | * rs3xx/rs4xx |
| 521 | * DDC_MONID = RADEON_GPIOPAD_MASK |
| 522 | * DDC_CRT2 = RADEON_GPIO_MONID |
| 523 | */ |
| 524 | switch (ddc) { |
| 525 | case DDC_NONE_DETECTED: |
| 526 | default: |
| 527 | ddc_line = 0; |
| 528 | break; |
| 529 | case DDC_DVI: |
| 530 | ddc_line = RADEON_GPIO_DVI_DDC; |
| 531 | break; |
| 532 | case DDC_VGA: |
| 533 | ddc_line = RADEON_GPIO_VGA_DDC; |
| 534 | break; |
| 535 | case DDC_LCD: |
| 536 | ddc_line = RADEON_GPIOPAD_MASK; |
| 537 | break; |
| 538 | case DDC_GPIO: |
| 539 | ddc_line = RADEON_MDGPIO_MASK; |
| 540 | break; |
| 541 | case DDC_MONID: |
| 542 | if (rdev->family == CHIP_RS300 || |
| 543 | rdev->family == CHIP_RS400 || |
| 544 | rdev->family == CHIP_RS480) |
| 545 | ddc_line = RADEON_GPIOPAD_MASK; |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 546 | else if (rdev->family == CHIP_R300 || |
| 547 | rdev->family == CHIP_R350) |
| 548 | ddc_line = RADEON_GPIO_DVI_DDC; |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 549 | else |
| 550 | ddc_line = RADEON_GPIO_MONID; |
| 551 | break; |
| 552 | case DDC_CRT2: |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 553 | if (rdev->family == CHIP_R200 || |
| 554 | rdev->family == CHIP_R300 || |
| 555 | rdev->family == CHIP_R350) |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 556 | ddc_line = RADEON_GPIO_DVI_DDC; |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 557 | else if (rdev->family == CHIP_RS300 || |
| 558 | rdev->family >= CHIP_RV350) |
| 559 | ddc_line = RADEON_GPIO_MONID; |
| 560 | else |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 561 | ddc_line = RADEON_GPIO_CRT2_DDC; |
| 562 | break; |
| 563 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 564 | |
Alex Deucher | 6a93cb2 | 2009-11-23 17:39:28 -0500 | [diff] [blame] | 565 | if (ddc_line == RADEON_GPIOPAD_MASK) { |
| 566 | i2c.mask_clk_reg = RADEON_GPIOPAD_MASK; |
| 567 | i2c.mask_data_reg = RADEON_GPIOPAD_MASK; |
| 568 | i2c.a_clk_reg = RADEON_GPIOPAD_A; |
| 569 | i2c.a_data_reg = RADEON_GPIOPAD_A; |
| 570 | i2c.en_clk_reg = RADEON_GPIOPAD_EN; |
| 571 | i2c.en_data_reg = RADEON_GPIOPAD_EN; |
| 572 | i2c.y_clk_reg = RADEON_GPIOPAD_Y; |
| 573 | i2c.y_data_reg = RADEON_GPIOPAD_Y; |
| 574 | } else if (ddc_line == RADEON_MDGPIO_MASK) { |
| 575 | i2c.mask_clk_reg = RADEON_MDGPIO_MASK; |
| 576 | i2c.mask_data_reg = RADEON_MDGPIO_MASK; |
| 577 | i2c.a_clk_reg = RADEON_MDGPIO_A; |
| 578 | i2c.a_data_reg = RADEON_MDGPIO_A; |
| 579 | i2c.en_clk_reg = RADEON_MDGPIO_EN; |
| 580 | i2c.en_data_reg = RADEON_MDGPIO_EN; |
| 581 | i2c.y_clk_reg = RADEON_MDGPIO_Y; |
| 582 | i2c.y_data_reg = RADEON_MDGPIO_Y; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 583 | } else { |
| 584 | i2c.mask_clk_reg = ddc_line; |
| 585 | i2c.mask_data_reg = ddc_line; |
| 586 | i2c.a_clk_reg = ddc_line; |
| 587 | i2c.a_data_reg = ddc_line; |
Alex Deucher | 9b9fe72 | 2009-11-10 15:59:44 -0500 | [diff] [blame] | 588 | i2c.en_clk_reg = ddc_line; |
| 589 | i2c.en_data_reg = ddc_line; |
| 590 | i2c.y_clk_reg = ddc_line; |
| 591 | i2c.y_data_reg = ddc_line; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 592 | } |
| 593 | |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 594 | if (clk_mask && data_mask) { |
Alex Deucher | be66305 | 2010-11-18 17:18:08 -0500 | [diff] [blame] | 595 | /* system specific masks */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 596 | i2c.mask_clk_mask = clk_mask; |
| 597 | i2c.mask_data_mask = data_mask; |
| 598 | i2c.a_clk_mask = clk_mask; |
| 599 | i2c.a_data_mask = data_mask; |
| 600 | i2c.en_clk_mask = clk_mask; |
| 601 | i2c.en_data_mask = data_mask; |
| 602 | i2c.y_clk_mask = clk_mask; |
| 603 | i2c.y_data_mask = data_mask; |
Alex Deucher | be66305 | 2010-11-18 17:18:08 -0500 | [diff] [blame] | 604 | } else if ((ddc_line == RADEON_GPIOPAD_MASK) || |
| 605 | (ddc_line == RADEON_MDGPIO_MASK)) { |
| 606 | /* default gpiopad masks */ |
| 607 | i2c.mask_clk_mask = (0x20 << 8); |
| 608 | i2c.mask_data_mask = 0x80; |
| 609 | i2c.a_clk_mask = (0x20 << 8); |
| 610 | i2c.a_data_mask = 0x80; |
| 611 | i2c.en_clk_mask = (0x20 << 8); |
| 612 | i2c.en_data_mask = 0x80; |
| 613 | i2c.y_clk_mask = (0x20 << 8); |
| 614 | i2c.y_data_mask = 0x80; |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 615 | } else { |
Alex Deucher | be66305 | 2010-11-18 17:18:08 -0500 | [diff] [blame] | 616 | /* default masks for ddc pads */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 617 | i2c.mask_clk_mask = RADEON_GPIO_EN_1; |
| 618 | i2c.mask_data_mask = RADEON_GPIO_EN_0; |
| 619 | i2c.a_clk_mask = RADEON_GPIO_A_1; |
| 620 | i2c.a_data_mask = RADEON_GPIO_A_0; |
| 621 | i2c.en_clk_mask = RADEON_GPIO_EN_1; |
| 622 | i2c.en_data_mask = RADEON_GPIO_EN_0; |
| 623 | i2c.y_clk_mask = RADEON_GPIO_Y_1; |
| 624 | i2c.y_data_mask = RADEON_GPIO_Y_0; |
| 625 | } |
| 626 | |
Alex Deucher | 40bacf1 | 2009-12-23 03:23:21 -0500 | [diff] [blame] | 627 | switch (rdev->family) { |
| 628 | case CHIP_R100: |
| 629 | case CHIP_RV100: |
| 630 | case CHIP_RS100: |
| 631 | case CHIP_RV200: |
| 632 | case CHIP_RS200: |
| 633 | case CHIP_RS300: |
| 634 | switch (ddc_line) { |
| 635 | case RADEON_GPIO_DVI_DDC: |
Alex Deucher | b28ea41 | 2010-03-12 13:30:49 -0500 | [diff] [blame] | 636 | i2c.hw_capable = true; |
Alex Deucher | 40bacf1 | 2009-12-23 03:23:21 -0500 | [diff] [blame] | 637 | break; |
| 638 | default: |
| 639 | i2c.hw_capable = false; |
| 640 | break; |
| 641 | } |
| 642 | break; |
| 643 | case CHIP_R200: |
| 644 | switch (ddc_line) { |
| 645 | case RADEON_GPIO_DVI_DDC: |
| 646 | case RADEON_GPIO_MONID: |
| 647 | i2c.hw_capable = true; |
| 648 | break; |
| 649 | default: |
| 650 | i2c.hw_capable = false; |
| 651 | break; |
| 652 | } |
| 653 | break; |
| 654 | case CHIP_RV250: |
| 655 | case CHIP_RV280: |
| 656 | switch (ddc_line) { |
| 657 | case RADEON_GPIO_VGA_DDC: |
| 658 | case RADEON_GPIO_DVI_DDC: |
| 659 | case RADEON_GPIO_CRT2_DDC: |
| 660 | i2c.hw_capable = true; |
| 661 | break; |
| 662 | default: |
| 663 | i2c.hw_capable = false; |
| 664 | break; |
| 665 | } |
| 666 | break; |
| 667 | case CHIP_R300: |
| 668 | case CHIP_R350: |
| 669 | switch (ddc_line) { |
| 670 | case RADEON_GPIO_VGA_DDC: |
| 671 | case RADEON_GPIO_DVI_DDC: |
| 672 | i2c.hw_capable = true; |
| 673 | break; |
| 674 | default: |
| 675 | i2c.hw_capable = false; |
| 676 | break; |
| 677 | } |
| 678 | break; |
| 679 | case CHIP_RV350: |
| 680 | case CHIP_RV380: |
| 681 | case CHIP_RS400: |
| 682 | case CHIP_RS480: |
Alex Deucher | 6a93cb2 | 2009-11-23 17:39:28 -0500 | [diff] [blame] | 683 | switch (ddc_line) { |
| 684 | case RADEON_GPIO_VGA_DDC: |
| 685 | case RADEON_GPIO_DVI_DDC: |
| 686 | i2c.hw_capable = true; |
| 687 | break; |
| 688 | case RADEON_GPIO_MONID: |
| 689 | /* hw i2c on RADEON_GPIO_MONID doesn't seem to work |
| 690 | * reliably on some pre-r4xx hardware; not sure why. |
| 691 | */ |
| 692 | i2c.hw_capable = false; |
| 693 | break; |
| 694 | default: |
| 695 | i2c.hw_capable = false; |
| 696 | break; |
| 697 | } |
Alex Deucher | 40bacf1 | 2009-12-23 03:23:21 -0500 | [diff] [blame] | 698 | break; |
| 699 | default: |
| 700 | i2c.hw_capable = false; |
| 701 | break; |
Alex Deucher | 6a93cb2 | 2009-11-23 17:39:28 -0500 | [diff] [blame] | 702 | } |
| 703 | i2c.mm_i2c = false; |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 704 | |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 705 | i2c.i2c_id = ddc; |
Alex Deucher | 8e36ed0 | 2010-05-18 19:26:47 -0400 | [diff] [blame] | 706 | i2c.hpd = RADEON_HPD_NONE; |
Alex Deucher | 6a93cb2 | 2009-11-23 17:39:28 -0500 | [diff] [blame] | 707 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 708 | if (ddc_line) |
| 709 | i2c.valid = true; |
| 710 | else |
| 711 | i2c.valid = false; |
| 712 | |
| 713 | return i2c; |
| 714 | } |
| 715 | |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 716 | void radeon_combios_i2c_init(struct radeon_device *rdev) |
| 717 | { |
| 718 | struct drm_device *dev = rdev->ddev; |
| 719 | struct radeon_i2c_bus_rec i2c; |
| 720 | |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 721 | /* actual hw pads |
| 722 | * r1xx/rs2xx/rs3xx |
| 723 | * 0x60, 0x64, 0x68, 0x6c, gpiopads, mm |
| 724 | * r200 |
| 725 | * 0x60, 0x64, 0x68, mm |
| 726 | * r300/r350 |
| 727 | * 0x60, 0x64, mm |
| 728 | * rv2xx/rv3xx/rs4xx |
| 729 | * 0x60, 0x64, 0x68, gpiopads, mm |
| 730 | */ |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 731 | |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 732 | /* 0x60 */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 733 | i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); |
| 734 | rdev->i2c_bus[0] = radeon_i2c_create(dev, &i2c, "DVI_DDC"); |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 735 | /* 0x64 */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 736 | i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); |
| 737 | rdev->i2c_bus[1] = radeon_i2c_create(dev, &i2c, "VGA_DDC"); |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 738 | |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 739 | /* mm i2c */ |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 740 | i2c.valid = true; |
| 741 | i2c.hw_capable = true; |
| 742 | i2c.mm_i2c = true; |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 743 | i2c.i2c_id = 0xa0; |
| 744 | rdev->i2c_bus[2] = radeon_i2c_create(dev, &i2c, "MM_I2C"); |
| 745 | |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 746 | if (rdev->family == CHIP_R300 || |
| 747 | rdev->family == CHIP_R350) { |
| 748 | /* only 2 sw i2c pads */ |
| 749 | } else if (rdev->family == CHIP_RS300 || |
| 750 | rdev->family == CHIP_RS400 || |
| 751 | rdev->family == CHIP_RS480) { |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 752 | u16 offset; |
| 753 | u8 id, blocks, clk, data; |
| 754 | int i; |
| 755 | |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 756 | /* 0x68 */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 757 | i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); |
| 758 | rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); |
| 759 | |
| 760 | offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE); |
| 761 | if (offset) { |
| 762 | blocks = RBIOS8(offset + 2); |
| 763 | for (i = 0; i < blocks; i++) { |
| 764 | id = RBIOS8(offset + 3 + (i * 5) + 0); |
| 765 | if (id == 136) { |
| 766 | clk = RBIOS8(offset + 3 + (i * 5) + 3); |
| 767 | data = RBIOS8(offset + 3 + (i * 5) + 4); |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 768 | /* gpiopad */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 769 | i2c = combios_setup_i2c_bus(rdev, DDC_MONID, |
Alex Deucher | 791cfe2 | 2010-11-21 10:58:05 -0500 | [diff] [blame] | 770 | (1 << clk), (1 << data)); |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 771 | rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "GPIOPAD_MASK"); |
| 772 | break; |
| 773 | } |
| 774 | } |
| 775 | } |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 776 | } else if (rdev->family >= CHIP_R200) { |
| 777 | /* 0x68 */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 778 | i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); |
| 779 | rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); |
| 780 | } else { |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 781 | /* 0x68 */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 782 | i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); |
| 783 | rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); |
Alex Deucher | 508c8d6 | 2011-05-03 19:47:44 -0400 | [diff] [blame^] | 784 | /* 0x6c */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 785 | i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); |
| 786 | rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "CRT2_DDC"); |
| 787 | } |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 788 | } |
| 789 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 790 | bool radeon_combios_get_clock_info(struct drm_device *dev) |
| 791 | { |
| 792 | struct radeon_device *rdev = dev->dev_private; |
| 793 | uint16_t pll_info; |
| 794 | struct radeon_pll *p1pll = &rdev->clock.p1pll; |
| 795 | struct radeon_pll *p2pll = &rdev->clock.p2pll; |
| 796 | struct radeon_pll *spll = &rdev->clock.spll; |
| 797 | struct radeon_pll *mpll = &rdev->clock.mpll; |
| 798 | int8_t rev; |
| 799 | uint16_t sclk, mclk; |
| 800 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 801 | pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE); |
| 802 | if (pll_info) { |
| 803 | rev = RBIOS8(pll_info); |
| 804 | |
| 805 | /* pixel clocks */ |
| 806 | p1pll->reference_freq = RBIOS16(pll_info + 0xe); |
| 807 | p1pll->reference_div = RBIOS16(pll_info + 0x10); |
| 808 | p1pll->pll_out_min = RBIOS32(pll_info + 0x12); |
| 809 | p1pll->pll_out_max = RBIOS32(pll_info + 0x16); |
Alex Deucher | 86cb2bb | 2010-03-08 12:55:16 -0500 | [diff] [blame] | 810 | p1pll->lcd_pll_out_min = p1pll->pll_out_min; |
| 811 | p1pll->lcd_pll_out_max = p1pll->pll_out_max; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 812 | |
| 813 | if (rev > 9) { |
| 814 | p1pll->pll_in_min = RBIOS32(pll_info + 0x36); |
| 815 | p1pll->pll_in_max = RBIOS32(pll_info + 0x3a); |
| 816 | } else { |
| 817 | p1pll->pll_in_min = 40; |
| 818 | p1pll->pll_in_max = 500; |
| 819 | } |
| 820 | *p2pll = *p1pll; |
| 821 | |
| 822 | /* system clock */ |
| 823 | spll->reference_freq = RBIOS16(pll_info + 0x1a); |
| 824 | spll->reference_div = RBIOS16(pll_info + 0x1c); |
| 825 | spll->pll_out_min = RBIOS32(pll_info + 0x1e); |
| 826 | spll->pll_out_max = RBIOS32(pll_info + 0x22); |
| 827 | |
| 828 | if (rev > 10) { |
| 829 | spll->pll_in_min = RBIOS32(pll_info + 0x48); |
| 830 | spll->pll_in_max = RBIOS32(pll_info + 0x4c); |
| 831 | } else { |
| 832 | /* ??? */ |
| 833 | spll->pll_in_min = 40; |
| 834 | spll->pll_in_max = 500; |
| 835 | } |
| 836 | |
| 837 | /* memory clock */ |
| 838 | mpll->reference_freq = RBIOS16(pll_info + 0x26); |
| 839 | mpll->reference_div = RBIOS16(pll_info + 0x28); |
| 840 | mpll->pll_out_min = RBIOS32(pll_info + 0x2a); |
| 841 | mpll->pll_out_max = RBIOS32(pll_info + 0x2e); |
| 842 | |
| 843 | if (rev > 10) { |
| 844 | mpll->pll_in_min = RBIOS32(pll_info + 0x5a); |
| 845 | mpll->pll_in_max = RBIOS32(pll_info + 0x5e); |
| 846 | } else { |
| 847 | /* ??? */ |
| 848 | mpll->pll_in_min = 40; |
| 849 | mpll->pll_in_max = 500; |
| 850 | } |
| 851 | |
| 852 | /* default sclk/mclk */ |
| 853 | sclk = RBIOS16(pll_info + 0xa); |
| 854 | mclk = RBIOS16(pll_info + 0x8); |
| 855 | if (sclk == 0) |
| 856 | sclk = 200 * 100; |
| 857 | if (mclk == 0) |
| 858 | mclk = 200 * 100; |
| 859 | |
| 860 | rdev->clock.default_sclk = sclk; |
| 861 | rdev->clock.default_mclk = mclk; |
| 862 | |
| 863 | return true; |
| 864 | } |
| 865 | return false; |
| 866 | } |
| 867 | |
Alex Deucher | 06b6476 | 2010-01-05 11:27:29 -0500 | [diff] [blame] | 868 | bool radeon_combios_sideport_present(struct radeon_device *rdev) |
| 869 | { |
| 870 | struct drm_device *dev = rdev->ddev; |
| 871 | u16 igp_info; |
| 872 | |
Alex Deucher | 4c70b2e | 2010-08-02 19:39:15 -0400 | [diff] [blame] | 873 | /* sideport is AMD only */ |
| 874 | if (rdev->family == CHIP_RS400) |
| 875 | return false; |
| 876 | |
Alex Deucher | 06b6476 | 2010-01-05 11:27:29 -0500 | [diff] [blame] | 877 | igp_info = combios_get_table_offset(dev, COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE); |
| 878 | |
| 879 | if (igp_info) { |
| 880 | if (RBIOS16(igp_info + 0x4)) |
| 881 | return true; |
| 882 | } |
| 883 | return false; |
| 884 | } |
| 885 | |
Alex Deucher | 246263c | 2009-12-29 12:09:17 -0500 | [diff] [blame] | 886 | static const uint32_t default_primarydac_adj[CHIP_LAST] = { |
| 887 | 0x00000808, /* r100 */ |
| 888 | 0x00000808, /* rv100 */ |
| 889 | 0x00000808, /* rs100 */ |
| 890 | 0x00000808, /* rv200 */ |
| 891 | 0x00000808, /* rs200 */ |
| 892 | 0x00000808, /* r200 */ |
| 893 | 0x00000808, /* rv250 */ |
| 894 | 0x00000000, /* rs300 */ |
| 895 | 0x00000808, /* rv280 */ |
| 896 | 0x00000808, /* r300 */ |
| 897 | 0x00000808, /* r350 */ |
| 898 | 0x00000808, /* rv350 */ |
| 899 | 0x00000808, /* rv380 */ |
| 900 | 0x00000808, /* r420 */ |
| 901 | 0x00000808, /* r423 */ |
| 902 | 0x00000808, /* rv410 */ |
| 903 | 0x00000000, /* rs400 */ |
| 904 | 0x00000000, /* rs480 */ |
| 905 | }; |
| 906 | |
| 907 | static void radeon_legacy_get_primary_dac_info_from_table(struct radeon_device *rdev, |
| 908 | struct radeon_encoder_primary_dac *p_dac) |
| 909 | { |
| 910 | p_dac->ps2_pdac_adj = default_primarydac_adj[rdev->family]; |
| 911 | return; |
| 912 | } |
| 913 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 914 | struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct |
| 915 | radeon_encoder |
| 916 | *encoder) |
| 917 | { |
| 918 | struct drm_device *dev = encoder->base.dev; |
| 919 | struct radeon_device *rdev = dev->dev_private; |
| 920 | uint16_t dac_info; |
| 921 | uint8_t rev, bg, dac; |
| 922 | struct radeon_encoder_primary_dac *p_dac = NULL; |
Alex Deucher | 246263c | 2009-12-29 12:09:17 -0500 | [diff] [blame] | 923 | int found = 0; |
| 924 | |
| 925 | p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), |
| 926 | GFP_KERNEL); |
| 927 | |
| 928 | if (!p_dac) |
| 929 | return NULL; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 930 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 931 | /* check CRT table */ |
| 932 | dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); |
| 933 | if (dac_info) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 934 | rev = RBIOS8(dac_info) & 0x3; |
| 935 | if (rev < 2) { |
| 936 | bg = RBIOS8(dac_info + 0x2) & 0xf; |
| 937 | dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf; |
| 938 | p_dac->ps2_pdac_adj = (bg << 8) | (dac); |
| 939 | } else { |
| 940 | bg = RBIOS8(dac_info + 0x2) & 0xf; |
| 941 | dac = RBIOS8(dac_info + 0x3) & 0xf; |
| 942 | p_dac->ps2_pdac_adj = (bg << 8) | (dac); |
| 943 | } |
Alex Deucher | 3a89b4a | 2010-04-06 12:35:26 -0400 | [diff] [blame] | 944 | /* if the values are all zeros, use the table */ |
| 945 | if (p_dac->ps2_pdac_adj) |
| 946 | found = 1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 947 | } |
| 948 | |
Alex Deucher | 246263c | 2009-12-29 12:09:17 -0500 | [diff] [blame] | 949 | if (!found) /* fallback to defaults */ |
| 950 | radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac); |
| 951 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 952 | return p_dac; |
| 953 | } |
| 954 | |
Alex Deucher | d79766f | 2009-12-17 19:00:29 -0500 | [diff] [blame] | 955 | enum radeon_tv_std |
| 956 | radeon_combios_get_tv_info(struct radeon_device *rdev) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 957 | { |
Alex Deucher | d79766f | 2009-12-17 19:00:29 -0500 | [diff] [blame] | 958 | struct drm_device *dev = rdev->ddev; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 959 | uint16_t tv_info; |
| 960 | enum radeon_tv_std tv_std = TV_STD_NTSC; |
| 961 | |
| 962 | tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); |
| 963 | if (tv_info) { |
| 964 | if (RBIOS8(tv_info + 6) == 'T') { |
| 965 | switch (RBIOS8(tv_info + 7) & 0xf) { |
| 966 | case 1: |
| 967 | tv_std = TV_STD_NTSC; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 968 | DRM_DEBUG_KMS("Default TV standard: NTSC\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 969 | break; |
| 970 | case 2: |
| 971 | tv_std = TV_STD_PAL; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 972 | DRM_DEBUG_KMS("Default TV standard: PAL\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 973 | break; |
| 974 | case 3: |
| 975 | tv_std = TV_STD_PAL_M; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 976 | DRM_DEBUG_KMS("Default TV standard: PAL-M\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 977 | break; |
| 978 | case 4: |
| 979 | tv_std = TV_STD_PAL_60; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 980 | DRM_DEBUG_KMS("Default TV standard: PAL-60\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 981 | break; |
| 982 | case 5: |
| 983 | tv_std = TV_STD_NTSC_J; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 984 | DRM_DEBUG_KMS("Default TV standard: NTSC-J\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 985 | break; |
| 986 | case 6: |
| 987 | tv_std = TV_STD_SCART_PAL; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 988 | DRM_DEBUG_KMS("Default TV standard: SCART-PAL\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 989 | break; |
| 990 | default: |
| 991 | tv_std = TV_STD_NTSC; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 992 | DRM_DEBUG_KMS |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 993 | ("Unknown TV standard; defaulting to NTSC\n"); |
| 994 | break; |
| 995 | } |
| 996 | |
| 997 | switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) { |
| 998 | case 0: |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 999 | DRM_DEBUG_KMS("29.498928713 MHz TV ref clk\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1000 | break; |
| 1001 | case 1: |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 1002 | DRM_DEBUG_KMS("28.636360000 MHz TV ref clk\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1003 | break; |
| 1004 | case 2: |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 1005 | DRM_DEBUG_KMS("14.318180000 MHz TV ref clk\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1006 | break; |
| 1007 | case 3: |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 1008 | DRM_DEBUG_KMS("27.000000000 MHz TV ref clk\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1009 | break; |
| 1010 | default: |
| 1011 | break; |
| 1012 | } |
| 1013 | } |
| 1014 | } |
| 1015 | return tv_std; |
| 1016 | } |
| 1017 | |
| 1018 | static const uint32_t default_tvdac_adj[CHIP_LAST] = { |
| 1019 | 0x00000000, /* r100 */ |
| 1020 | 0x00280000, /* rv100 */ |
| 1021 | 0x00000000, /* rs100 */ |
| 1022 | 0x00880000, /* rv200 */ |
| 1023 | 0x00000000, /* rs200 */ |
| 1024 | 0x00000000, /* r200 */ |
| 1025 | 0x00770000, /* rv250 */ |
| 1026 | 0x00290000, /* rs300 */ |
| 1027 | 0x00560000, /* rv280 */ |
| 1028 | 0x00780000, /* r300 */ |
| 1029 | 0x00770000, /* r350 */ |
| 1030 | 0x00780000, /* rv350 */ |
| 1031 | 0x00780000, /* rv380 */ |
| 1032 | 0x01080000, /* r420 */ |
| 1033 | 0x01080000, /* r423 */ |
| 1034 | 0x01080000, /* rv410 */ |
| 1035 | 0x00780000, /* rs400 */ |
| 1036 | 0x00780000, /* rs480 */ |
| 1037 | }; |
| 1038 | |
Dave Airlie | 6a719e0 | 2009-08-17 10:19:51 +1000 | [diff] [blame] | 1039 | static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev, |
| 1040 | struct radeon_encoder_tv_dac *tv_dac) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1041 | { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1042 | tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; |
| 1043 | if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) |
| 1044 | tv_dac->ps2_tvdac_adj = 0x00880000; |
| 1045 | tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; |
| 1046 | tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; |
Dave Airlie | 6a719e0 | 2009-08-17 10:19:51 +1000 | [diff] [blame] | 1047 | return; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1048 | } |
| 1049 | |
| 1050 | struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct |
| 1051 | radeon_encoder |
| 1052 | *encoder) |
| 1053 | { |
| 1054 | struct drm_device *dev = encoder->base.dev; |
| 1055 | struct radeon_device *rdev = dev->dev_private; |
| 1056 | uint16_t dac_info; |
| 1057 | uint8_t rev, bg, dac; |
| 1058 | struct radeon_encoder_tv_dac *tv_dac = NULL; |
Dave Airlie | 6a719e0 | 2009-08-17 10:19:51 +1000 | [diff] [blame] | 1059 | int found = 0; |
| 1060 | |
| 1061 | tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); |
| 1062 | if (!tv_dac) |
| 1063 | return NULL; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1064 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1065 | /* first check TV table */ |
| 1066 | dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); |
| 1067 | if (dac_info) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1068 | rev = RBIOS8(dac_info + 0x3); |
| 1069 | if (rev > 4) { |
| 1070 | bg = RBIOS8(dac_info + 0xc) & 0xf; |
| 1071 | dac = RBIOS8(dac_info + 0xd) & 0xf; |
| 1072 | tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); |
| 1073 | |
| 1074 | bg = RBIOS8(dac_info + 0xe) & 0xf; |
| 1075 | dac = RBIOS8(dac_info + 0xf) & 0xf; |
| 1076 | tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); |
| 1077 | |
| 1078 | bg = RBIOS8(dac_info + 0x10) & 0xf; |
| 1079 | dac = RBIOS8(dac_info + 0x11) & 0xf; |
| 1080 | tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); |
Alex Deucher | 3a89b4a | 2010-04-06 12:35:26 -0400 | [diff] [blame] | 1081 | /* if the values are all zeros, use the table */ |
| 1082 | if (tv_dac->ps2_tvdac_adj) |
| 1083 | found = 1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1084 | } else if (rev > 1) { |
| 1085 | bg = RBIOS8(dac_info + 0xc) & 0xf; |
| 1086 | dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; |
| 1087 | tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); |
| 1088 | |
| 1089 | bg = RBIOS8(dac_info + 0xd) & 0xf; |
| 1090 | dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf; |
| 1091 | tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); |
| 1092 | |
| 1093 | bg = RBIOS8(dac_info + 0xe) & 0xf; |
| 1094 | dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; |
| 1095 | tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); |
Alex Deucher | 3a89b4a | 2010-04-06 12:35:26 -0400 | [diff] [blame] | 1096 | /* if the values are all zeros, use the table */ |
| 1097 | if (tv_dac->ps2_tvdac_adj) |
| 1098 | found = 1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1099 | } |
Alex Deucher | d79766f | 2009-12-17 19:00:29 -0500 | [diff] [blame] | 1100 | tv_dac->tv_std = radeon_combios_get_tv_info(rdev); |
Dave Airlie | 6a719e0 | 2009-08-17 10:19:51 +1000 | [diff] [blame] | 1101 | } |
| 1102 | if (!found) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1103 | /* then check CRT table */ |
| 1104 | dac_info = |
| 1105 | combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); |
| 1106 | if (dac_info) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1107 | rev = RBIOS8(dac_info) & 0x3; |
| 1108 | if (rev < 2) { |
| 1109 | bg = RBIOS8(dac_info + 0x3) & 0xf; |
| 1110 | dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf; |
| 1111 | tv_dac->ps2_tvdac_adj = |
| 1112 | (bg << 16) | (dac << 20); |
| 1113 | tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; |
| 1114 | tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; |
Alex Deucher | 3a89b4a | 2010-04-06 12:35:26 -0400 | [diff] [blame] | 1115 | /* if the values are all zeros, use the table */ |
| 1116 | if (tv_dac->ps2_tvdac_adj) |
| 1117 | found = 1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1118 | } else { |
| 1119 | bg = RBIOS8(dac_info + 0x4) & 0xf; |
| 1120 | dac = RBIOS8(dac_info + 0x5) & 0xf; |
| 1121 | tv_dac->ps2_tvdac_adj = |
| 1122 | (bg << 16) | (dac << 20); |
| 1123 | tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; |
| 1124 | tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; |
Alex Deucher | 3a89b4a | 2010-04-06 12:35:26 -0400 | [diff] [blame] | 1125 | /* if the values are all zeros, use the table */ |
| 1126 | if (tv_dac->ps2_tvdac_adj) |
| 1127 | found = 1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1128 | } |
Alex Deucher | 6fe7ac3 | 2009-06-12 17:26:08 +0000 | [diff] [blame] | 1129 | } else { |
| 1130 | DRM_INFO("No TV DAC info found in BIOS\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1131 | } |
| 1132 | } |
| 1133 | |
Dave Airlie | 6a719e0 | 2009-08-17 10:19:51 +1000 | [diff] [blame] | 1134 | if (!found) /* fallback to defaults */ |
| 1135 | radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac); |
| 1136 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1137 | return tv_dac; |
| 1138 | } |
| 1139 | |
| 1140 | static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct |
| 1141 | radeon_device |
| 1142 | *rdev) |
| 1143 | { |
| 1144 | struct radeon_encoder_lvds *lvds = NULL; |
| 1145 | uint32_t fp_vert_stretch, fp_horz_stretch; |
| 1146 | uint32_t ppll_div_sel, ppll_val; |
Michel Dänzer | 8b5c744 | 2009-06-17 18:28:38 +0200 | [diff] [blame] | 1147 | uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1148 | |
| 1149 | lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); |
| 1150 | |
| 1151 | if (!lvds) |
| 1152 | return NULL; |
| 1153 | |
| 1154 | fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH); |
| 1155 | fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH); |
| 1156 | |
Michel Dänzer | 8b5c744 | 2009-06-17 18:28:38 +0200 | [diff] [blame] | 1157 | /* These should be fail-safe defaults, fingers crossed */ |
| 1158 | lvds->panel_pwr_delay = 200; |
| 1159 | lvds->panel_vcc_delay = 2000; |
| 1160 | |
| 1161 | lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL); |
| 1162 | lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf; |
| 1163 | lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf; |
| 1164 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1165 | if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE) |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1166 | lvds->native_mode.vdisplay = |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1167 | ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >> |
| 1168 | RADEON_VERT_PANEL_SHIFT) + 1; |
| 1169 | else |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1170 | lvds->native_mode.vdisplay = |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1171 | (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1; |
| 1172 | |
| 1173 | if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE) |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1174 | lvds->native_mode.hdisplay = |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1175 | (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >> |
| 1176 | RADEON_HORZ_PANEL_SHIFT) + 1) * 8; |
| 1177 | else |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1178 | lvds->native_mode.hdisplay = |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1179 | ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8; |
| 1180 | |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1181 | if ((lvds->native_mode.hdisplay < 640) || |
| 1182 | (lvds->native_mode.vdisplay < 480)) { |
| 1183 | lvds->native_mode.hdisplay = 640; |
| 1184 | lvds->native_mode.vdisplay = 480; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1185 | } |
| 1186 | |
| 1187 | ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3; |
| 1188 | ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel); |
| 1189 | if ((ppll_val & 0x000707ff) == 0x1bb) |
| 1190 | lvds->use_bios_dividers = false; |
| 1191 | else { |
| 1192 | lvds->panel_ref_divider = |
| 1193 | RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff; |
| 1194 | lvds->panel_post_divider = (ppll_val >> 16) & 0x7; |
| 1195 | lvds->panel_fb_divider = ppll_val & 0x7ff; |
| 1196 | |
| 1197 | if ((lvds->panel_ref_divider != 0) && |
| 1198 | (lvds->panel_fb_divider > 3)) |
| 1199 | lvds->use_bios_dividers = true; |
| 1200 | } |
| 1201 | lvds->panel_vcc_delay = 200; |
| 1202 | |
| 1203 | DRM_INFO("Panel info derived from registers\n"); |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1204 | DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, |
| 1205 | lvds->native_mode.vdisplay); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1206 | |
| 1207 | return lvds; |
| 1208 | } |
| 1209 | |
| 1210 | struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder |
| 1211 | *encoder) |
| 1212 | { |
| 1213 | struct drm_device *dev = encoder->base.dev; |
| 1214 | struct radeon_device *rdev = dev->dev_private; |
| 1215 | uint16_t lcd_info; |
| 1216 | uint32_t panel_setup; |
| 1217 | char stmp[30]; |
| 1218 | int tmp, i; |
| 1219 | struct radeon_encoder_lvds *lvds = NULL; |
| 1220 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1221 | lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); |
| 1222 | |
| 1223 | if (lcd_info) { |
| 1224 | lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); |
| 1225 | |
| 1226 | if (!lvds) |
| 1227 | return NULL; |
| 1228 | |
| 1229 | for (i = 0; i < 24; i++) |
| 1230 | stmp[i] = RBIOS8(lcd_info + i + 1); |
| 1231 | stmp[24] = 0; |
| 1232 | |
| 1233 | DRM_INFO("Panel ID String: %s\n", stmp); |
| 1234 | |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1235 | lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19); |
| 1236 | lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1237 | |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1238 | DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, |
| 1239 | lvds->native_mode.vdisplay); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1240 | |
| 1241 | lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c); |
Andrew Morton | 94cf643 | 2010-02-02 14:40:29 -0800 | [diff] [blame] | 1242 | lvds->panel_vcc_delay = min_t(u16, lvds->panel_vcc_delay, 2000); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1243 | |
| 1244 | lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24); |
| 1245 | lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf; |
| 1246 | lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf; |
| 1247 | |
| 1248 | lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e); |
| 1249 | lvds->panel_post_divider = RBIOS8(lcd_info + 0x30); |
| 1250 | lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31); |
| 1251 | if ((lvds->panel_ref_divider != 0) && |
| 1252 | (lvds->panel_fb_divider > 3)) |
| 1253 | lvds->use_bios_dividers = true; |
| 1254 | |
| 1255 | panel_setup = RBIOS32(lcd_info + 0x39); |
| 1256 | lvds->lvds_gen_cntl = 0xff00; |
| 1257 | if (panel_setup & 0x1) |
| 1258 | lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT; |
| 1259 | |
| 1260 | if ((panel_setup >> 4) & 0x1) |
| 1261 | lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE; |
| 1262 | |
| 1263 | switch ((panel_setup >> 8) & 0x7) { |
| 1264 | case 0: |
| 1265 | lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM; |
| 1266 | break; |
| 1267 | case 1: |
| 1268 | lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY; |
| 1269 | break; |
| 1270 | case 2: |
| 1271 | lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY; |
| 1272 | break; |
| 1273 | default: |
| 1274 | break; |
| 1275 | } |
| 1276 | |
| 1277 | if ((panel_setup >> 16) & 0x1) |
| 1278 | lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW; |
| 1279 | |
| 1280 | if ((panel_setup >> 17) & 0x1) |
| 1281 | lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW; |
| 1282 | |
| 1283 | if ((panel_setup >> 18) & 0x1) |
| 1284 | lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW; |
| 1285 | |
| 1286 | if ((panel_setup >> 23) & 0x1) |
| 1287 | lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL; |
| 1288 | |
| 1289 | lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000); |
| 1290 | |
| 1291 | for (i = 0; i < 32; i++) { |
| 1292 | tmp = RBIOS16(lcd_info + 64 + i * 2); |
| 1293 | if (tmp == 0) |
| 1294 | break; |
| 1295 | |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1296 | if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) && |
Alex Deucher | 68b61a7 | 2010-05-18 00:30:05 -0400 | [diff] [blame] | 1297 | (RBIOS16(tmp + 2) == lvds->native_mode.vdisplay)) { |
| 1298 | lvds->native_mode.htotal = lvds->native_mode.hdisplay + |
| 1299 | (RBIOS16(tmp + 17) - RBIOS16(tmp + 19)) * 8; |
| 1300 | lvds->native_mode.hsync_start = lvds->native_mode.hdisplay + |
| 1301 | (RBIOS16(tmp + 21) - RBIOS16(tmp + 19) - 1) * 8; |
| 1302 | lvds->native_mode.hsync_end = lvds->native_mode.hsync_start + |
| 1303 | (RBIOS8(tmp + 23) * 8); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1304 | |
Alex Deucher | 68b61a7 | 2010-05-18 00:30:05 -0400 | [diff] [blame] | 1305 | lvds->native_mode.vtotal = lvds->native_mode.vdisplay + |
| 1306 | (RBIOS16(tmp + 24) - RBIOS16(tmp + 26)); |
| 1307 | lvds->native_mode.vsync_start = lvds->native_mode.vdisplay + |
| 1308 | ((RBIOS16(tmp + 28) & 0x7ff) - RBIOS16(tmp + 26)); |
| 1309 | lvds->native_mode.vsync_end = lvds->native_mode.vsync_start + |
| 1310 | ((RBIOS16(tmp + 28) & 0xf800) >> 11); |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1311 | |
| 1312 | lvds->native_mode.clock = RBIOS16(tmp + 9) * 10; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1313 | lvds->native_mode.flags = 0; |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1314 | /* set crtc values */ |
| 1315 | drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V); |
| 1316 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1317 | } |
| 1318 | } |
Alex Deucher | 6fe7ac3 | 2009-06-12 17:26:08 +0000 | [diff] [blame] | 1319 | } else { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1320 | DRM_INFO("No panel info found in BIOS\n"); |
Michel Dänzer | 8dfaa8a | 2009-09-15 17:09:27 +0200 | [diff] [blame] | 1321 | lvds = radeon_legacy_get_lvds_info_from_regs(rdev); |
Alex Deucher | 6fe7ac3 | 2009-06-12 17:26:08 +0000 | [diff] [blame] | 1322 | } |
Michel Dänzer | 03047cd | 2010-02-10 11:05:11 +0100 | [diff] [blame] | 1323 | |
Michel Dänzer | 8dfaa8a | 2009-09-15 17:09:27 +0200 | [diff] [blame] | 1324 | if (lvds) |
| 1325 | encoder->native_mode = lvds->native_mode; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1326 | return lvds; |
| 1327 | } |
| 1328 | |
| 1329 | static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = { |
| 1330 | {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */ |
| 1331 | {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */ |
| 1332 | {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */ |
| 1333 | {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */ |
| 1334 | {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */ |
| 1335 | {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */ |
| 1336 | {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */ |
| 1337 | {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */ |
| 1338 | {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */ |
| 1339 | {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */ |
| 1340 | {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */ |
| 1341 | {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */ |
| 1342 | {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */ |
| 1343 | {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */ |
| 1344 | {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */ |
| 1345 | {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */ |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 1346 | { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */ |
| 1347 | { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1348 | }; |
| 1349 | |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 1350 | bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder, |
| 1351 | struct radeon_encoder_int_tmds *tmds) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1352 | { |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 1353 | struct drm_device *dev = encoder->base.dev; |
| 1354 | struct radeon_device *rdev = dev->dev_private; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1355 | int i; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1356 | |
| 1357 | for (i = 0; i < 4; i++) { |
| 1358 | tmds->tmds_pll[i].value = |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 1359 | default_tmds_pll[rdev->family][i].value; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1360 | tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq; |
| 1361 | } |
| 1362 | |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 1363 | return true; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1364 | } |
| 1365 | |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 1366 | bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder, |
| 1367 | struct radeon_encoder_int_tmds *tmds) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1368 | { |
| 1369 | struct drm_device *dev = encoder->base.dev; |
| 1370 | struct radeon_device *rdev = dev->dev_private; |
| 1371 | uint16_t tmds_info; |
| 1372 | int i, n; |
| 1373 | uint8_t ver; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1374 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1375 | tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); |
| 1376 | |
| 1377 | if (tmds_info) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1378 | ver = RBIOS8(tmds_info); |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 1379 | DRM_DEBUG_KMS("DFP table revision: %d\n", ver); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1380 | if (ver == 3) { |
| 1381 | n = RBIOS8(tmds_info + 5) + 1; |
| 1382 | if (n > 4) |
| 1383 | n = 4; |
| 1384 | for (i = 0; i < n; i++) { |
| 1385 | tmds->tmds_pll[i].value = |
| 1386 | RBIOS32(tmds_info + i * 10 + 0x08); |
| 1387 | tmds->tmds_pll[i].freq = |
| 1388 | RBIOS16(tmds_info + i * 10 + 0x10); |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 1389 | DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1390 | tmds->tmds_pll[i].freq, |
| 1391 | tmds->tmds_pll[i].value); |
| 1392 | } |
| 1393 | } else if (ver == 4) { |
| 1394 | int stride = 0; |
| 1395 | n = RBIOS8(tmds_info + 5) + 1; |
| 1396 | if (n > 4) |
| 1397 | n = 4; |
| 1398 | for (i = 0; i < n; i++) { |
| 1399 | tmds->tmds_pll[i].value = |
| 1400 | RBIOS32(tmds_info + stride + 0x08); |
| 1401 | tmds->tmds_pll[i].freq = |
| 1402 | RBIOS16(tmds_info + stride + 0x10); |
| 1403 | if (i == 0) |
| 1404 | stride += 10; |
| 1405 | else |
| 1406 | stride += 6; |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 1407 | DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1408 | tmds->tmds_pll[i].freq, |
| 1409 | tmds->tmds_pll[i].value); |
| 1410 | } |
| 1411 | } |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 1412 | } else { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1413 | DRM_INFO("No TMDS info found in BIOS\n"); |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 1414 | return false; |
| 1415 | } |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 1416 | return true; |
| 1417 | } |
| 1418 | |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 1419 | bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder, |
| 1420 | struct radeon_encoder_ext_tmds *tmds) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1421 | { |
| 1422 | struct drm_device *dev = encoder->base.dev; |
| 1423 | struct radeon_device *rdev = dev->dev_private; |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 1424 | struct radeon_i2c_bus_rec i2c_bus; |
| 1425 | |
| 1426 | /* default for macs */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1427 | i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 1428 | tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 1429 | |
| 1430 | /* XXX some macs have duallink chips */ |
| 1431 | switch (rdev->mode_info.connector_table) { |
| 1432 | case CT_POWERBOOK_EXTERNAL: |
| 1433 | case CT_MINI_EXTERNAL: |
| 1434 | default: |
| 1435 | tmds->dvo_chip = DVO_SIL164; |
| 1436 | tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ |
| 1437 | break; |
| 1438 | } |
| 1439 | |
| 1440 | return true; |
| 1441 | } |
| 1442 | |
| 1443 | bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder, |
| 1444 | struct radeon_encoder_ext_tmds *tmds) |
| 1445 | { |
| 1446 | struct drm_device *dev = encoder->base.dev; |
| 1447 | struct radeon_device *rdev = dev->dev_private; |
| 1448 | uint16_t offset; |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1449 | uint8_t ver; |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 1450 | enum radeon_combios_ddc gpio; |
| 1451 | struct radeon_i2c_bus_rec i2c_bus; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1452 | |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 1453 | tmds->i2c_bus = NULL; |
| 1454 | if (rdev->flags & RADEON_IS_IGP) { |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1455 | i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); |
| 1456 | tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); |
| 1457 | tmds->dvo_chip = DVO_SIL164; |
| 1458 | tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 1459 | } else { |
| 1460 | offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); |
| 1461 | if (offset) { |
| 1462 | ver = RBIOS8(offset); |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 1463 | DRM_DEBUG_KMS("External TMDS Table revision: %d\n", ver); |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 1464 | tmds->slave_addr = RBIOS8(offset + 4 + 2); |
| 1465 | tmds->slave_addr >>= 1; /* 7 bit addressing */ |
| 1466 | gpio = RBIOS8(offset + 4 + 3); |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1467 | if (gpio == DDC_LCD) { |
| 1468 | /* MM i2c */ |
Alex Deucher | 40bacf1 | 2009-12-23 03:23:21 -0500 | [diff] [blame] | 1469 | i2c_bus.valid = true; |
| 1470 | i2c_bus.hw_capable = true; |
| 1471 | i2c_bus.mm_i2c = true; |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1472 | i2c_bus.i2c_id = 0xa0; |
| 1473 | } else |
| 1474 | i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0); |
| 1475 | tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 1476 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1477 | } |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 1478 | |
| 1479 | if (!tmds->i2c_bus) { |
| 1480 | DRM_INFO("No valid Ext TMDS info found in BIOS\n"); |
| 1481 | return false; |
| 1482 | } |
| 1483 | |
| 1484 | return true; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1485 | } |
| 1486 | |
| 1487 | bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) |
| 1488 | { |
| 1489 | struct radeon_device *rdev = dev->dev_private; |
| 1490 | struct radeon_i2c_bus_rec ddc_i2c; |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1491 | struct radeon_hpd hpd; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1492 | |
| 1493 | rdev->mode_info.connector_table = radeon_connector_table; |
| 1494 | if (rdev->mode_info.connector_table == CT_NONE) { |
| 1495 | #ifdef CONFIG_PPC_PMAC |
Grant Likely | 71a157e | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 1496 | if (of_machine_is_compatible("PowerBook3,3")) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1497 | /* powerbook with VGA */ |
| 1498 | rdev->mode_info.connector_table = CT_POWERBOOK_VGA; |
Grant Likely | 71a157e | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 1499 | } else if (of_machine_is_compatible("PowerBook3,4") || |
| 1500 | of_machine_is_compatible("PowerBook3,5")) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1501 | /* powerbook with internal tmds */ |
| 1502 | rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; |
Grant Likely | 71a157e | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 1503 | } else if (of_machine_is_compatible("PowerBook5,1") || |
| 1504 | of_machine_is_compatible("PowerBook5,2") || |
| 1505 | of_machine_is_compatible("PowerBook5,3") || |
| 1506 | of_machine_is_compatible("PowerBook5,4") || |
| 1507 | of_machine_is_compatible("PowerBook5,5")) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1508 | /* powerbook with external single link tmds (sil164) */ |
| 1509 | rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; |
Grant Likely | 71a157e | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 1510 | } else if (of_machine_is_compatible("PowerBook5,6")) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1511 | /* powerbook with external dual or single link tmds */ |
| 1512 | rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; |
Grant Likely | 71a157e | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 1513 | } else if (of_machine_is_compatible("PowerBook5,7") || |
| 1514 | of_machine_is_compatible("PowerBook5,8") || |
| 1515 | of_machine_is_compatible("PowerBook5,9")) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1516 | /* PowerBook6,2 ? */ |
| 1517 | /* powerbook with external dual link tmds (sil1178?) */ |
| 1518 | rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; |
Grant Likely | 71a157e | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 1519 | } else if (of_machine_is_compatible("PowerBook4,1") || |
| 1520 | of_machine_is_compatible("PowerBook4,2") || |
| 1521 | of_machine_is_compatible("PowerBook4,3") || |
| 1522 | of_machine_is_compatible("PowerBook6,3") || |
| 1523 | of_machine_is_compatible("PowerBook6,5") || |
| 1524 | of_machine_is_compatible("PowerBook6,7")) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1525 | /* ibook */ |
| 1526 | rdev->mode_info.connector_table = CT_IBOOK; |
Grant Likely | 71a157e | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 1527 | } else if (of_machine_is_compatible("PowerMac4,4")) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1528 | /* emac */ |
| 1529 | rdev->mode_info.connector_table = CT_EMAC; |
Grant Likely | 71a157e | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 1530 | } else if (of_machine_is_compatible("PowerMac10,1")) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1531 | /* mini with internal tmds */ |
| 1532 | rdev->mode_info.connector_table = CT_MINI_INTERNAL; |
Grant Likely | 71a157e | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 1533 | } else if (of_machine_is_compatible("PowerMac10,2")) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1534 | /* mini with external tmds */ |
| 1535 | rdev->mode_info.connector_table = CT_MINI_EXTERNAL; |
Grant Likely | 71a157e | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 1536 | } else if (of_machine_is_compatible("PowerMac12,1")) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1537 | /* PowerMac8,1 ? */ |
| 1538 | /* imac g5 isight */ |
| 1539 | rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; |
Alex Deucher | aa74fbb | 2010-09-07 14:41:30 -0400 | [diff] [blame] | 1540 | } else if ((rdev->pdev->device == 0x4a48) && |
| 1541 | (rdev->pdev->subsystem_vendor == 0x1002) && |
| 1542 | (rdev->pdev->subsystem_device == 0x4a48)) { |
| 1543 | /* Mac X800 */ |
| 1544 | rdev->mode_info.connector_table = CT_MAC_X800; |
Alex Deucher | 9fad321 | 2011-02-07 13:15:28 -0500 | [diff] [blame] | 1545 | } else if ((rdev->pdev->device == 0x4150) && |
| 1546 | (rdev->pdev->subsystem_vendor == 0x1002) && |
| 1547 | (rdev->pdev->subsystem_device == 0x4150)) { |
| 1548 | /* Mac G5 9600 */ |
| 1549 | rdev->mode_info.connector_table = CT_MAC_G5_9600; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1550 | } else |
| 1551 | #endif /* CONFIG_PPC_PMAC */ |
Dave Airlie | 76a7142 | 2010-06-11 01:09:05 -0400 | [diff] [blame] | 1552 | #ifdef CONFIG_PPC64 |
| 1553 | if (ASIC_IS_RN50(rdev)) |
| 1554 | rdev->mode_info.connector_table = CT_RN50_POWER; |
| 1555 | else |
| 1556 | #endif |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1557 | rdev->mode_info.connector_table = CT_GENERIC; |
| 1558 | } |
| 1559 | |
| 1560 | switch (rdev->mode_info.connector_table) { |
| 1561 | case CT_GENERIC: |
| 1562 | DRM_INFO("Connector Table: %d (generic)\n", |
| 1563 | rdev->mode_info.connector_table); |
| 1564 | /* these are the most common settings */ |
| 1565 | if (rdev->flags & RADEON_SINGLE_CRTC) { |
| 1566 | /* VGA - primary dac */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1567 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1568 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1569 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1570 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1571 | ATOM_DEVICE_CRT1_SUPPORT, |
| 1572 | 1), |
| 1573 | ATOM_DEVICE_CRT1_SUPPORT); |
| 1574 | radeon_add_legacy_connector(dev, 0, |
| 1575 | ATOM_DEVICE_CRT1_SUPPORT, |
| 1576 | DRM_MODE_CONNECTOR_VGA, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1577 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1578 | CONNECTOR_OBJECT_ID_VGA, |
| 1579 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1580 | } else if (rdev->flags & RADEON_IS_MOBILITY) { |
| 1581 | /* LVDS */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1582 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_NONE_DETECTED, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1583 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1584 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1585 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1586 | ATOM_DEVICE_LCD1_SUPPORT, |
| 1587 | 0), |
| 1588 | ATOM_DEVICE_LCD1_SUPPORT); |
| 1589 | radeon_add_legacy_connector(dev, 0, |
| 1590 | ATOM_DEVICE_LCD1_SUPPORT, |
| 1591 | DRM_MODE_CONNECTOR_LVDS, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1592 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1593 | CONNECTOR_OBJECT_ID_LVDS, |
| 1594 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1595 | |
| 1596 | /* VGA - primary dac */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1597 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1598 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1599 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1600 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1601 | ATOM_DEVICE_CRT1_SUPPORT, |
| 1602 | 1), |
| 1603 | ATOM_DEVICE_CRT1_SUPPORT); |
| 1604 | radeon_add_legacy_connector(dev, 1, |
| 1605 | ATOM_DEVICE_CRT1_SUPPORT, |
| 1606 | DRM_MODE_CONNECTOR_VGA, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1607 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1608 | CONNECTOR_OBJECT_ID_VGA, |
| 1609 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1610 | } else { |
| 1611 | /* DVI-I - tv dac, int tmds */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1612 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1613 | hpd.hpd = RADEON_HPD_1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1614 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1615 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1616 | ATOM_DEVICE_DFP1_SUPPORT, |
| 1617 | 0), |
| 1618 | ATOM_DEVICE_DFP1_SUPPORT); |
| 1619 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1620 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1621 | ATOM_DEVICE_CRT2_SUPPORT, |
| 1622 | 2), |
| 1623 | ATOM_DEVICE_CRT2_SUPPORT); |
| 1624 | radeon_add_legacy_connector(dev, 0, |
| 1625 | ATOM_DEVICE_DFP1_SUPPORT | |
| 1626 | ATOM_DEVICE_CRT2_SUPPORT, |
| 1627 | DRM_MODE_CONNECTOR_DVII, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1628 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1629 | CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, |
| 1630 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1631 | |
| 1632 | /* VGA - primary dac */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1633 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1634 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1635 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1636 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1637 | ATOM_DEVICE_CRT1_SUPPORT, |
| 1638 | 1), |
| 1639 | ATOM_DEVICE_CRT1_SUPPORT); |
| 1640 | radeon_add_legacy_connector(dev, 1, |
| 1641 | ATOM_DEVICE_CRT1_SUPPORT, |
| 1642 | DRM_MODE_CONNECTOR_VGA, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1643 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1644 | CONNECTOR_OBJECT_ID_VGA, |
| 1645 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1646 | } |
| 1647 | |
| 1648 | if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { |
| 1649 | /* TV - tv dac */ |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1650 | ddc_i2c.valid = false; |
| 1651 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1652 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1653 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1654 | ATOM_DEVICE_TV1_SUPPORT, |
| 1655 | 2), |
| 1656 | ATOM_DEVICE_TV1_SUPPORT); |
| 1657 | radeon_add_legacy_connector(dev, 2, |
| 1658 | ATOM_DEVICE_TV1_SUPPORT, |
| 1659 | DRM_MODE_CONNECTOR_SVIDEO, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1660 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1661 | CONNECTOR_OBJECT_ID_SVIDEO, |
| 1662 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1663 | } |
| 1664 | break; |
| 1665 | case CT_IBOOK: |
| 1666 | DRM_INFO("Connector Table: %d (ibook)\n", |
| 1667 | rdev->mode_info.connector_table); |
| 1668 | /* LVDS */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1669 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1670 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1671 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1672 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1673 | ATOM_DEVICE_LCD1_SUPPORT, |
| 1674 | 0), |
| 1675 | ATOM_DEVICE_LCD1_SUPPORT); |
| 1676 | radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1677 | DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1678 | CONNECTOR_OBJECT_ID_LVDS, |
| 1679 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1680 | /* VGA - TV DAC */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1681 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1682 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1683 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1684 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1685 | ATOM_DEVICE_CRT2_SUPPORT, |
| 1686 | 2), |
| 1687 | ATOM_DEVICE_CRT2_SUPPORT); |
| 1688 | radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1689 | DRM_MODE_CONNECTOR_VGA, &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1690 | CONNECTOR_OBJECT_ID_VGA, |
| 1691 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1692 | /* TV - TV DAC */ |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1693 | ddc_i2c.valid = false; |
| 1694 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1695 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1696 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1697 | ATOM_DEVICE_TV1_SUPPORT, |
| 1698 | 2), |
| 1699 | ATOM_DEVICE_TV1_SUPPORT); |
| 1700 | radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, |
| 1701 | DRM_MODE_CONNECTOR_SVIDEO, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1702 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1703 | CONNECTOR_OBJECT_ID_SVIDEO, |
| 1704 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1705 | break; |
| 1706 | case CT_POWERBOOK_EXTERNAL: |
| 1707 | DRM_INFO("Connector Table: %d (powerbook external tmds)\n", |
| 1708 | rdev->mode_info.connector_table); |
| 1709 | /* LVDS */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1710 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1711 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1712 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1713 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1714 | ATOM_DEVICE_LCD1_SUPPORT, |
| 1715 | 0), |
| 1716 | ATOM_DEVICE_LCD1_SUPPORT); |
| 1717 | radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1718 | DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1719 | CONNECTOR_OBJECT_ID_LVDS, |
| 1720 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1721 | /* DVI-I - primary dac, ext tmds */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1722 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1723 | hpd.hpd = RADEON_HPD_2; /* ??? */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1724 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1725 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1726 | ATOM_DEVICE_DFP2_SUPPORT, |
| 1727 | 0), |
| 1728 | ATOM_DEVICE_DFP2_SUPPORT); |
| 1729 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1730 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1731 | ATOM_DEVICE_CRT1_SUPPORT, |
| 1732 | 1), |
| 1733 | ATOM_DEVICE_CRT1_SUPPORT); |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1734 | /* XXX some are SL */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1735 | radeon_add_legacy_connector(dev, 1, |
| 1736 | ATOM_DEVICE_DFP2_SUPPORT | |
| 1737 | ATOM_DEVICE_CRT1_SUPPORT, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1738 | DRM_MODE_CONNECTOR_DVII, &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1739 | CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, |
| 1740 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1741 | /* TV - TV DAC */ |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1742 | ddc_i2c.valid = false; |
| 1743 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1744 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1745 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1746 | ATOM_DEVICE_TV1_SUPPORT, |
| 1747 | 2), |
| 1748 | ATOM_DEVICE_TV1_SUPPORT); |
| 1749 | radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, |
| 1750 | DRM_MODE_CONNECTOR_SVIDEO, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1751 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1752 | CONNECTOR_OBJECT_ID_SVIDEO, |
| 1753 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1754 | break; |
| 1755 | case CT_POWERBOOK_INTERNAL: |
| 1756 | DRM_INFO("Connector Table: %d (powerbook internal tmds)\n", |
| 1757 | rdev->mode_info.connector_table); |
| 1758 | /* LVDS */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1759 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1760 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1761 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1762 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1763 | ATOM_DEVICE_LCD1_SUPPORT, |
| 1764 | 0), |
| 1765 | ATOM_DEVICE_LCD1_SUPPORT); |
| 1766 | radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1767 | DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1768 | CONNECTOR_OBJECT_ID_LVDS, |
| 1769 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1770 | /* DVI-I - primary dac, int tmds */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1771 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1772 | hpd.hpd = RADEON_HPD_1; /* ??? */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1773 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1774 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1775 | ATOM_DEVICE_DFP1_SUPPORT, |
| 1776 | 0), |
| 1777 | ATOM_DEVICE_DFP1_SUPPORT); |
| 1778 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1779 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1780 | ATOM_DEVICE_CRT1_SUPPORT, |
| 1781 | 1), |
| 1782 | ATOM_DEVICE_CRT1_SUPPORT); |
| 1783 | radeon_add_legacy_connector(dev, 1, |
| 1784 | ATOM_DEVICE_DFP1_SUPPORT | |
| 1785 | ATOM_DEVICE_CRT1_SUPPORT, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1786 | DRM_MODE_CONNECTOR_DVII, &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1787 | CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, |
| 1788 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1789 | /* TV - TV DAC */ |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1790 | ddc_i2c.valid = false; |
| 1791 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1792 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1793 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1794 | ATOM_DEVICE_TV1_SUPPORT, |
| 1795 | 2), |
| 1796 | ATOM_DEVICE_TV1_SUPPORT); |
| 1797 | radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, |
| 1798 | DRM_MODE_CONNECTOR_SVIDEO, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1799 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1800 | CONNECTOR_OBJECT_ID_SVIDEO, |
| 1801 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1802 | break; |
| 1803 | case CT_POWERBOOK_VGA: |
| 1804 | DRM_INFO("Connector Table: %d (powerbook vga)\n", |
| 1805 | rdev->mode_info.connector_table); |
| 1806 | /* LVDS */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1807 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1808 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1809 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1810 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1811 | ATOM_DEVICE_LCD1_SUPPORT, |
| 1812 | 0), |
| 1813 | ATOM_DEVICE_LCD1_SUPPORT); |
| 1814 | radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1815 | DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1816 | CONNECTOR_OBJECT_ID_LVDS, |
| 1817 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1818 | /* VGA - primary dac */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1819 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1820 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1821 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1822 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1823 | ATOM_DEVICE_CRT1_SUPPORT, |
| 1824 | 1), |
| 1825 | ATOM_DEVICE_CRT1_SUPPORT); |
| 1826 | radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1827 | DRM_MODE_CONNECTOR_VGA, &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1828 | CONNECTOR_OBJECT_ID_VGA, |
| 1829 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1830 | /* TV - TV DAC */ |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1831 | ddc_i2c.valid = false; |
| 1832 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1833 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1834 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1835 | ATOM_DEVICE_TV1_SUPPORT, |
| 1836 | 2), |
| 1837 | ATOM_DEVICE_TV1_SUPPORT); |
| 1838 | radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, |
| 1839 | DRM_MODE_CONNECTOR_SVIDEO, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1840 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1841 | CONNECTOR_OBJECT_ID_SVIDEO, |
| 1842 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1843 | break; |
| 1844 | case CT_MINI_EXTERNAL: |
| 1845 | DRM_INFO("Connector Table: %d (mini external tmds)\n", |
| 1846 | rdev->mode_info.connector_table); |
| 1847 | /* DVI-I - tv dac, ext tmds */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1848 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1849 | hpd.hpd = RADEON_HPD_2; /* ??? */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1850 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1851 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1852 | ATOM_DEVICE_DFP2_SUPPORT, |
| 1853 | 0), |
| 1854 | ATOM_DEVICE_DFP2_SUPPORT); |
| 1855 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1856 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1857 | ATOM_DEVICE_CRT2_SUPPORT, |
| 1858 | 2), |
| 1859 | ATOM_DEVICE_CRT2_SUPPORT); |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1860 | /* XXX are any DL? */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1861 | radeon_add_legacy_connector(dev, 0, |
| 1862 | ATOM_DEVICE_DFP2_SUPPORT | |
| 1863 | ATOM_DEVICE_CRT2_SUPPORT, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1864 | DRM_MODE_CONNECTOR_DVII, &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1865 | CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, |
| 1866 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1867 | /* TV - TV DAC */ |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1868 | ddc_i2c.valid = false; |
| 1869 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1870 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1871 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1872 | ATOM_DEVICE_TV1_SUPPORT, |
| 1873 | 2), |
| 1874 | ATOM_DEVICE_TV1_SUPPORT); |
| 1875 | radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, |
| 1876 | DRM_MODE_CONNECTOR_SVIDEO, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1877 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1878 | CONNECTOR_OBJECT_ID_SVIDEO, |
| 1879 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1880 | break; |
| 1881 | case CT_MINI_INTERNAL: |
| 1882 | DRM_INFO("Connector Table: %d (mini internal tmds)\n", |
| 1883 | rdev->mode_info.connector_table); |
| 1884 | /* DVI-I - tv dac, int tmds */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1885 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1886 | hpd.hpd = RADEON_HPD_1; /* ??? */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1887 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1888 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1889 | ATOM_DEVICE_DFP1_SUPPORT, |
| 1890 | 0), |
| 1891 | ATOM_DEVICE_DFP1_SUPPORT); |
| 1892 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1893 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1894 | ATOM_DEVICE_CRT2_SUPPORT, |
| 1895 | 2), |
| 1896 | ATOM_DEVICE_CRT2_SUPPORT); |
| 1897 | radeon_add_legacy_connector(dev, 0, |
| 1898 | ATOM_DEVICE_DFP1_SUPPORT | |
| 1899 | ATOM_DEVICE_CRT2_SUPPORT, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1900 | DRM_MODE_CONNECTOR_DVII, &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1901 | CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, |
| 1902 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1903 | /* TV - TV DAC */ |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1904 | ddc_i2c.valid = false; |
| 1905 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1906 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1907 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1908 | ATOM_DEVICE_TV1_SUPPORT, |
| 1909 | 2), |
| 1910 | ATOM_DEVICE_TV1_SUPPORT); |
| 1911 | radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, |
| 1912 | DRM_MODE_CONNECTOR_SVIDEO, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1913 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1914 | CONNECTOR_OBJECT_ID_SVIDEO, |
| 1915 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1916 | break; |
| 1917 | case CT_IMAC_G5_ISIGHT: |
| 1918 | DRM_INFO("Connector Table: %d (imac g5 isight)\n", |
| 1919 | rdev->mode_info.connector_table); |
| 1920 | /* DVI-D - int tmds */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1921 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1922 | hpd.hpd = RADEON_HPD_1; /* ??? */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1923 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1924 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1925 | ATOM_DEVICE_DFP1_SUPPORT, |
| 1926 | 0), |
| 1927 | ATOM_DEVICE_DFP1_SUPPORT); |
| 1928 | radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1929 | DRM_MODE_CONNECTOR_DVID, &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1930 | CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, |
| 1931 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1932 | /* VGA - tv dac */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1933 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1934 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1935 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1936 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1937 | ATOM_DEVICE_CRT2_SUPPORT, |
| 1938 | 2), |
| 1939 | ATOM_DEVICE_CRT2_SUPPORT); |
| 1940 | radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1941 | DRM_MODE_CONNECTOR_VGA, &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1942 | CONNECTOR_OBJECT_ID_VGA, |
| 1943 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1944 | /* TV - TV DAC */ |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1945 | ddc_i2c.valid = false; |
| 1946 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1947 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1948 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1949 | ATOM_DEVICE_TV1_SUPPORT, |
| 1950 | 2), |
| 1951 | ATOM_DEVICE_TV1_SUPPORT); |
| 1952 | radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, |
| 1953 | DRM_MODE_CONNECTOR_SVIDEO, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1954 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1955 | CONNECTOR_OBJECT_ID_SVIDEO, |
| 1956 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1957 | break; |
| 1958 | case CT_EMAC: |
| 1959 | DRM_INFO("Connector Table: %d (emac)\n", |
| 1960 | rdev->mode_info.connector_table); |
| 1961 | /* VGA - primary dac */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1962 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1963 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1964 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1965 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1966 | ATOM_DEVICE_CRT1_SUPPORT, |
| 1967 | 1), |
| 1968 | ATOM_DEVICE_CRT1_SUPPORT); |
| 1969 | radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1970 | DRM_MODE_CONNECTOR_VGA, &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1971 | CONNECTOR_OBJECT_ID_VGA, |
| 1972 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1973 | /* VGA - tv dac */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 1974 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1975 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1976 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1977 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1978 | ATOM_DEVICE_CRT2_SUPPORT, |
| 1979 | 2), |
| 1980 | ATOM_DEVICE_CRT2_SUPPORT); |
| 1981 | radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1982 | DRM_MODE_CONNECTOR_VGA, &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1983 | CONNECTOR_OBJECT_ID_VGA, |
| 1984 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1985 | /* TV - TV DAC */ |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1986 | ddc_i2c.valid = false; |
| 1987 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1988 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1989 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1990 | ATOM_DEVICE_TV1_SUPPORT, |
| 1991 | 2), |
| 1992 | ATOM_DEVICE_TV1_SUPPORT); |
| 1993 | radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, |
| 1994 | DRM_MODE_CONNECTOR_SVIDEO, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1995 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1996 | CONNECTOR_OBJECT_ID_SVIDEO, |
| 1997 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1998 | break; |
Dave Airlie | 76a7142 | 2010-06-11 01:09:05 -0400 | [diff] [blame] | 1999 | case CT_RN50_POWER: |
| 2000 | DRM_INFO("Connector Table: %d (rn50-power)\n", |
| 2001 | rdev->mode_info.connector_table); |
| 2002 | /* VGA - primary dac */ |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 2003 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); |
Dave Airlie | 76a7142 | 2010-06-11 01:09:05 -0400 | [diff] [blame] | 2004 | hpd.hpd = RADEON_HPD_NONE; |
| 2005 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2006 | radeon_get_encoder_enum(dev, |
Dave Airlie | 76a7142 | 2010-06-11 01:09:05 -0400 | [diff] [blame] | 2007 | ATOM_DEVICE_CRT1_SUPPORT, |
| 2008 | 1), |
| 2009 | ATOM_DEVICE_CRT1_SUPPORT); |
| 2010 | radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, |
| 2011 | DRM_MODE_CONNECTOR_VGA, &ddc_i2c, |
| 2012 | CONNECTOR_OBJECT_ID_VGA, |
| 2013 | &hpd); |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 2014 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); |
Dave Airlie | 76a7142 | 2010-06-11 01:09:05 -0400 | [diff] [blame] | 2015 | hpd.hpd = RADEON_HPD_NONE; |
| 2016 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2017 | radeon_get_encoder_enum(dev, |
Dave Airlie | 76a7142 | 2010-06-11 01:09:05 -0400 | [diff] [blame] | 2018 | ATOM_DEVICE_CRT2_SUPPORT, |
| 2019 | 2), |
| 2020 | ATOM_DEVICE_CRT2_SUPPORT); |
| 2021 | radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, |
| 2022 | DRM_MODE_CONNECTOR_VGA, &ddc_i2c, |
| 2023 | CONNECTOR_OBJECT_ID_VGA, |
| 2024 | &hpd); |
| 2025 | break; |
Alex Deucher | aa74fbb | 2010-09-07 14:41:30 -0400 | [diff] [blame] | 2026 | case CT_MAC_X800: |
| 2027 | DRM_INFO("Connector Table: %d (mac x800)\n", |
| 2028 | rdev->mode_info.connector_table); |
| 2029 | /* DVI - primary dac, internal tmds */ |
| 2030 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); |
| 2031 | hpd.hpd = RADEON_HPD_1; /* ??? */ |
| 2032 | radeon_add_legacy_encoder(dev, |
| 2033 | radeon_get_encoder_enum(dev, |
| 2034 | ATOM_DEVICE_DFP1_SUPPORT, |
| 2035 | 0), |
| 2036 | ATOM_DEVICE_DFP1_SUPPORT); |
| 2037 | radeon_add_legacy_encoder(dev, |
| 2038 | radeon_get_encoder_enum(dev, |
| 2039 | ATOM_DEVICE_CRT1_SUPPORT, |
| 2040 | 1), |
| 2041 | ATOM_DEVICE_CRT1_SUPPORT); |
| 2042 | radeon_add_legacy_connector(dev, 0, |
| 2043 | ATOM_DEVICE_DFP1_SUPPORT | |
| 2044 | ATOM_DEVICE_CRT1_SUPPORT, |
| 2045 | DRM_MODE_CONNECTOR_DVII, &ddc_i2c, |
| 2046 | CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, |
| 2047 | &hpd); |
| 2048 | /* DVI - tv dac, dvo */ |
| 2049 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); |
| 2050 | hpd.hpd = RADEON_HPD_2; /* ??? */ |
| 2051 | radeon_add_legacy_encoder(dev, |
| 2052 | radeon_get_encoder_enum(dev, |
| 2053 | ATOM_DEVICE_DFP2_SUPPORT, |
| 2054 | 0), |
| 2055 | ATOM_DEVICE_DFP2_SUPPORT); |
| 2056 | radeon_add_legacy_encoder(dev, |
| 2057 | radeon_get_encoder_enum(dev, |
| 2058 | ATOM_DEVICE_CRT2_SUPPORT, |
| 2059 | 2), |
| 2060 | ATOM_DEVICE_CRT2_SUPPORT); |
| 2061 | radeon_add_legacy_connector(dev, 1, |
| 2062 | ATOM_DEVICE_DFP2_SUPPORT | |
| 2063 | ATOM_DEVICE_CRT2_SUPPORT, |
| 2064 | DRM_MODE_CONNECTOR_DVII, &ddc_i2c, |
| 2065 | CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, |
| 2066 | &hpd); |
| 2067 | break; |
Alex Deucher | 9fad321 | 2011-02-07 13:15:28 -0500 | [diff] [blame] | 2068 | case CT_MAC_G5_9600: |
| 2069 | DRM_INFO("Connector Table: %d (mac g5 9600)\n", |
| 2070 | rdev->mode_info.connector_table); |
| 2071 | /* DVI - tv dac, dvo */ |
| 2072 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); |
| 2073 | hpd.hpd = RADEON_HPD_1; /* ??? */ |
| 2074 | radeon_add_legacy_encoder(dev, |
| 2075 | radeon_get_encoder_enum(dev, |
| 2076 | ATOM_DEVICE_DFP2_SUPPORT, |
| 2077 | 0), |
| 2078 | ATOM_DEVICE_DFP2_SUPPORT); |
| 2079 | radeon_add_legacy_encoder(dev, |
| 2080 | radeon_get_encoder_enum(dev, |
| 2081 | ATOM_DEVICE_CRT2_SUPPORT, |
| 2082 | 2), |
| 2083 | ATOM_DEVICE_CRT2_SUPPORT); |
| 2084 | radeon_add_legacy_connector(dev, 0, |
| 2085 | ATOM_DEVICE_DFP2_SUPPORT | |
| 2086 | ATOM_DEVICE_CRT2_SUPPORT, |
| 2087 | DRM_MODE_CONNECTOR_DVII, &ddc_i2c, |
| 2088 | CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, |
| 2089 | &hpd); |
| 2090 | /* ADC - primary dac, internal tmds */ |
| 2091 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); |
| 2092 | hpd.hpd = RADEON_HPD_2; /* ??? */ |
| 2093 | radeon_add_legacy_encoder(dev, |
| 2094 | radeon_get_encoder_enum(dev, |
| 2095 | ATOM_DEVICE_DFP1_SUPPORT, |
| 2096 | 0), |
| 2097 | ATOM_DEVICE_DFP1_SUPPORT); |
| 2098 | radeon_add_legacy_encoder(dev, |
| 2099 | radeon_get_encoder_enum(dev, |
| 2100 | ATOM_DEVICE_CRT1_SUPPORT, |
| 2101 | 1), |
| 2102 | ATOM_DEVICE_CRT1_SUPPORT); |
| 2103 | radeon_add_legacy_connector(dev, 1, |
| 2104 | ATOM_DEVICE_DFP1_SUPPORT | |
| 2105 | ATOM_DEVICE_CRT1_SUPPORT, |
| 2106 | DRM_MODE_CONNECTOR_DVII, &ddc_i2c, |
| 2107 | CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, |
| 2108 | &hpd); |
Alex Deucher | beb4727 | 2011-04-02 09:09:08 -0400 | [diff] [blame] | 2109 | /* TV - TV DAC */ |
| 2110 | ddc_i2c.valid = false; |
| 2111 | hpd.hpd = RADEON_HPD_NONE; |
| 2112 | radeon_add_legacy_encoder(dev, |
| 2113 | radeon_get_encoder_enum(dev, |
| 2114 | ATOM_DEVICE_TV1_SUPPORT, |
| 2115 | 2), |
| 2116 | ATOM_DEVICE_TV1_SUPPORT); |
| 2117 | radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, |
| 2118 | DRM_MODE_CONNECTOR_SVIDEO, |
| 2119 | &ddc_i2c, |
| 2120 | CONNECTOR_OBJECT_ID_SVIDEO, |
| 2121 | &hpd); |
Alex Deucher | 9fad321 | 2011-02-07 13:15:28 -0500 | [diff] [blame] | 2122 | break; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2123 | default: |
| 2124 | DRM_INFO("Connector table: %d (invalid)\n", |
| 2125 | rdev->mode_info.connector_table); |
| 2126 | return false; |
| 2127 | } |
| 2128 | |
| 2129 | radeon_link_encoder_connector(dev); |
| 2130 | |
| 2131 | return true; |
| 2132 | } |
| 2133 | |
| 2134 | static bool radeon_apply_legacy_quirks(struct drm_device *dev, |
| 2135 | int bios_index, |
| 2136 | enum radeon_combios_connector |
| 2137 | *legacy_connector, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2138 | struct radeon_i2c_bus_rec *ddc_i2c, |
| 2139 | struct radeon_hpd *hpd) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2140 | { |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 2141 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2142 | /* Certain IBM chipset RN50s have a BIOS reporting two VGAs, |
| 2143 | one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */ |
| 2144 | if (dev->pdev->device == 0x515e && |
| 2145 | dev->pdev->subsystem_vendor == 0x1014) { |
| 2146 | if (*legacy_connector == CONNECTOR_CRT_LEGACY && |
| 2147 | ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) |
| 2148 | return false; |
| 2149 | } |
| 2150 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2151 | /* X300 card with extra non-existent DVI port */ |
| 2152 | if (dev->pdev->device == 0x5B60 && |
| 2153 | dev->pdev->subsystem_vendor == 0x17af && |
| 2154 | dev->pdev->subsystem_device == 0x201e && bios_index == 2) { |
| 2155 | if (*legacy_connector == CONNECTOR_DVI_I_LEGACY) |
| 2156 | return false; |
| 2157 | } |
| 2158 | |
| 2159 | return true; |
| 2160 | } |
| 2161 | |
Alex Deucher | 790cfb3 | 2009-10-15 23:26:09 -0400 | [diff] [blame] | 2162 | static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev) |
| 2163 | { |
| 2164 | /* Acer 5102 has non-existent TV port */ |
| 2165 | if (dev->pdev->device == 0x5975 && |
| 2166 | dev->pdev->subsystem_vendor == 0x1025 && |
| 2167 | dev->pdev->subsystem_device == 0x009f) |
| 2168 | return false; |
| 2169 | |
Alex Deucher | fc7f711 | 2009-10-28 01:46:54 -0400 | [diff] [blame] | 2170 | /* HP dc5750 has non-existent TV port */ |
| 2171 | if (dev->pdev->device == 0x5974 && |
| 2172 | dev->pdev->subsystem_vendor == 0x103c && |
| 2173 | dev->pdev->subsystem_device == 0x280a) |
| 2174 | return false; |
| 2175 | |
Alex Deucher | fd874ad | 2009-11-16 18:33:51 -0500 | [diff] [blame] | 2176 | /* MSI S270 has non-existent TV port */ |
| 2177 | if (dev->pdev->device == 0x5955 && |
| 2178 | dev->pdev->subsystem_vendor == 0x1462 && |
| 2179 | dev->pdev->subsystem_device == 0x0131) |
| 2180 | return false; |
| 2181 | |
Alex Deucher | 790cfb3 | 2009-10-15 23:26:09 -0400 | [diff] [blame] | 2182 | return true; |
| 2183 | } |
| 2184 | |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2185 | static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d) |
| 2186 | { |
| 2187 | struct radeon_device *rdev = dev->dev_private; |
| 2188 | uint32_t ext_tmds_info; |
| 2189 | |
| 2190 | if (rdev->flags & RADEON_IS_IGP) { |
| 2191 | if (is_dvi_d) |
| 2192 | return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; |
| 2193 | else |
| 2194 | return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; |
| 2195 | } |
| 2196 | ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); |
| 2197 | if (ext_tmds_info) { |
| 2198 | uint8_t rev = RBIOS8(ext_tmds_info); |
| 2199 | uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5); |
| 2200 | if (rev >= 3) { |
| 2201 | if (is_dvi_d) |
| 2202 | return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; |
| 2203 | else |
| 2204 | return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; |
| 2205 | } else { |
| 2206 | if (flags & 1) { |
| 2207 | if (is_dvi_d) |
| 2208 | return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; |
| 2209 | else |
| 2210 | return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; |
| 2211 | } |
| 2212 | } |
| 2213 | } |
| 2214 | if (is_dvi_d) |
| 2215 | return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; |
| 2216 | else |
| 2217 | return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; |
| 2218 | } |
| 2219 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2220 | bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) |
| 2221 | { |
| 2222 | struct radeon_device *rdev = dev->dev_private; |
| 2223 | uint32_t conn_info, entry, devices; |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2224 | uint16_t tmp, connector_object_id; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2225 | enum radeon_combios_ddc ddc_type; |
| 2226 | enum radeon_combios_connector connector; |
| 2227 | int i = 0; |
| 2228 | struct radeon_i2c_bus_rec ddc_i2c; |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2229 | struct radeon_hpd hpd; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2230 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2231 | conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE); |
| 2232 | if (conn_info) { |
| 2233 | for (i = 0; i < 4; i++) { |
| 2234 | entry = conn_info + 2 + i * 2; |
| 2235 | |
| 2236 | if (!RBIOS16(entry)) |
| 2237 | break; |
| 2238 | |
| 2239 | tmp = RBIOS16(entry); |
| 2240 | |
| 2241 | connector = (tmp >> 12) & 0xf; |
| 2242 | |
| 2243 | ddc_type = (tmp >> 8) & 0xf; |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 2244 | ddc_i2c = combios_setup_i2c_bus(rdev, ddc_type, 0, 0); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2245 | |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2246 | switch (connector) { |
| 2247 | case CONNECTOR_PROPRIETARY_LEGACY: |
| 2248 | case CONNECTOR_DVI_I_LEGACY: |
| 2249 | case CONNECTOR_DVI_D_LEGACY: |
| 2250 | if ((tmp >> 4) & 0x1) |
| 2251 | hpd.hpd = RADEON_HPD_2; |
| 2252 | else |
| 2253 | hpd.hpd = RADEON_HPD_1; |
| 2254 | break; |
| 2255 | default: |
| 2256 | hpd.hpd = RADEON_HPD_NONE; |
| 2257 | break; |
| 2258 | } |
| 2259 | |
Alex Deucher | 2d152c6 | 2009-10-15 23:08:05 -0400 | [diff] [blame] | 2260 | if (!radeon_apply_legacy_quirks(dev, i, &connector, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2261 | &ddc_i2c, &hpd)) |
Alex Deucher | 2d152c6 | 2009-10-15 23:08:05 -0400 | [diff] [blame] | 2262 | continue; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2263 | |
| 2264 | switch (connector) { |
| 2265 | case CONNECTOR_PROPRIETARY_LEGACY: |
| 2266 | if ((tmp >> 4) & 0x1) |
| 2267 | devices = ATOM_DEVICE_DFP2_SUPPORT; |
| 2268 | else |
| 2269 | devices = ATOM_DEVICE_DFP1_SUPPORT; |
| 2270 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2271 | radeon_get_encoder_enum |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2272 | (dev, devices, 0), |
| 2273 | devices); |
| 2274 | radeon_add_legacy_connector(dev, i, devices, |
| 2275 | legacy_connector_convert |
| 2276 | [connector], |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2277 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2278 | CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, |
| 2279 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2280 | break; |
| 2281 | case CONNECTOR_CRT_LEGACY: |
| 2282 | if (tmp & 0x1) { |
| 2283 | devices = ATOM_DEVICE_CRT2_SUPPORT; |
| 2284 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2285 | radeon_get_encoder_enum |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2286 | (dev, |
| 2287 | ATOM_DEVICE_CRT2_SUPPORT, |
| 2288 | 2), |
| 2289 | ATOM_DEVICE_CRT2_SUPPORT); |
| 2290 | } else { |
| 2291 | devices = ATOM_DEVICE_CRT1_SUPPORT; |
| 2292 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2293 | radeon_get_encoder_enum |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2294 | (dev, |
| 2295 | ATOM_DEVICE_CRT1_SUPPORT, |
| 2296 | 1), |
| 2297 | ATOM_DEVICE_CRT1_SUPPORT); |
| 2298 | } |
| 2299 | radeon_add_legacy_connector(dev, |
| 2300 | i, |
| 2301 | devices, |
| 2302 | legacy_connector_convert |
| 2303 | [connector], |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2304 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2305 | CONNECTOR_OBJECT_ID_VGA, |
| 2306 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2307 | break; |
| 2308 | case CONNECTOR_DVI_I_LEGACY: |
| 2309 | devices = 0; |
| 2310 | if (tmp & 0x1) { |
| 2311 | devices |= ATOM_DEVICE_CRT2_SUPPORT; |
| 2312 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2313 | radeon_get_encoder_enum |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2314 | (dev, |
| 2315 | ATOM_DEVICE_CRT2_SUPPORT, |
| 2316 | 2), |
| 2317 | ATOM_DEVICE_CRT2_SUPPORT); |
| 2318 | } else { |
| 2319 | devices |= ATOM_DEVICE_CRT1_SUPPORT; |
| 2320 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2321 | radeon_get_encoder_enum |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2322 | (dev, |
| 2323 | ATOM_DEVICE_CRT1_SUPPORT, |
| 2324 | 1), |
| 2325 | ATOM_DEVICE_CRT1_SUPPORT); |
| 2326 | } |
| 2327 | if ((tmp >> 4) & 0x1) { |
| 2328 | devices |= ATOM_DEVICE_DFP2_SUPPORT; |
| 2329 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2330 | radeon_get_encoder_enum |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2331 | (dev, |
| 2332 | ATOM_DEVICE_DFP2_SUPPORT, |
| 2333 | 0), |
| 2334 | ATOM_DEVICE_DFP2_SUPPORT); |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2335 | connector_object_id = combios_check_dl_dvi(dev, 0); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2336 | } else { |
| 2337 | devices |= ATOM_DEVICE_DFP1_SUPPORT; |
| 2338 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2339 | radeon_get_encoder_enum |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2340 | (dev, |
| 2341 | ATOM_DEVICE_DFP1_SUPPORT, |
| 2342 | 0), |
| 2343 | ATOM_DEVICE_DFP1_SUPPORT); |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2344 | connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2345 | } |
| 2346 | radeon_add_legacy_connector(dev, |
| 2347 | i, |
| 2348 | devices, |
| 2349 | legacy_connector_convert |
| 2350 | [connector], |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2351 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2352 | connector_object_id, |
| 2353 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2354 | break; |
| 2355 | case CONNECTOR_DVI_D_LEGACY: |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2356 | if ((tmp >> 4) & 0x1) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2357 | devices = ATOM_DEVICE_DFP2_SUPPORT; |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2358 | connector_object_id = combios_check_dl_dvi(dev, 1); |
| 2359 | } else { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2360 | devices = ATOM_DEVICE_DFP1_SUPPORT; |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2361 | connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; |
| 2362 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2363 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2364 | radeon_get_encoder_enum |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2365 | (dev, devices, 0), |
| 2366 | devices); |
| 2367 | radeon_add_legacy_connector(dev, i, devices, |
| 2368 | legacy_connector_convert |
| 2369 | [connector], |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2370 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2371 | connector_object_id, |
| 2372 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2373 | break; |
| 2374 | case CONNECTOR_CTV_LEGACY: |
| 2375 | case CONNECTOR_STV_LEGACY: |
| 2376 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2377 | radeon_get_encoder_enum |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2378 | (dev, |
| 2379 | ATOM_DEVICE_TV1_SUPPORT, |
| 2380 | 2), |
| 2381 | ATOM_DEVICE_TV1_SUPPORT); |
| 2382 | radeon_add_legacy_connector(dev, i, |
| 2383 | ATOM_DEVICE_TV1_SUPPORT, |
| 2384 | legacy_connector_convert |
| 2385 | [connector], |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2386 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2387 | CONNECTOR_OBJECT_ID_SVIDEO, |
| 2388 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2389 | break; |
| 2390 | default: |
| 2391 | DRM_ERROR("Unknown connector type: %d\n", |
| 2392 | connector); |
| 2393 | continue; |
| 2394 | } |
| 2395 | |
| 2396 | } |
| 2397 | } else { |
| 2398 | uint16_t tmds_info = |
| 2399 | combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); |
| 2400 | if (tmds_info) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2401 | DRM_DEBUG_KMS("Found DFP table, assuming DVI connector\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2402 | |
| 2403 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2404 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2405 | ATOM_DEVICE_CRT1_SUPPORT, |
| 2406 | 1), |
| 2407 | ATOM_DEVICE_CRT1_SUPPORT); |
| 2408 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2409 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2410 | ATOM_DEVICE_DFP1_SUPPORT, |
| 2411 | 0), |
| 2412 | ATOM_DEVICE_DFP1_SUPPORT); |
| 2413 | |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 2414 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); |
Alex Deucher | 8e36ed0 | 2010-05-18 19:26:47 -0400 | [diff] [blame] | 2415 | hpd.hpd = RADEON_HPD_1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2416 | radeon_add_legacy_connector(dev, |
| 2417 | 0, |
| 2418 | ATOM_DEVICE_CRT1_SUPPORT | |
| 2419 | ATOM_DEVICE_DFP1_SUPPORT, |
| 2420 | DRM_MODE_CONNECTOR_DVII, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2421 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2422 | CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, |
| 2423 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2424 | } else { |
Alex Deucher | d0c403e | 2009-10-15 23:38:32 -0400 | [diff] [blame] | 2425 | uint16_t crt_info = |
| 2426 | combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2427 | DRM_DEBUG_KMS("Found CRT table, assuming VGA connector\n"); |
Alex Deucher | d0c403e | 2009-10-15 23:38:32 -0400 | [diff] [blame] | 2428 | if (crt_info) { |
| 2429 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2430 | radeon_get_encoder_enum(dev, |
Alex Deucher | d0c403e | 2009-10-15 23:38:32 -0400 | [diff] [blame] | 2431 | ATOM_DEVICE_CRT1_SUPPORT, |
| 2432 | 1), |
| 2433 | ATOM_DEVICE_CRT1_SUPPORT); |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 2434 | ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2435 | hpd.hpd = RADEON_HPD_NONE; |
Alex Deucher | d0c403e | 2009-10-15 23:38:32 -0400 | [diff] [blame] | 2436 | radeon_add_legacy_connector(dev, |
| 2437 | 0, |
| 2438 | ATOM_DEVICE_CRT1_SUPPORT, |
| 2439 | DRM_MODE_CONNECTOR_VGA, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2440 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2441 | CONNECTOR_OBJECT_ID_VGA, |
| 2442 | &hpd); |
Alex Deucher | d0c403e | 2009-10-15 23:38:32 -0400 | [diff] [blame] | 2443 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2444 | DRM_DEBUG_KMS("No connector info found\n"); |
Alex Deucher | d0c403e | 2009-10-15 23:38:32 -0400 | [diff] [blame] | 2445 | return false; |
| 2446 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2447 | } |
| 2448 | } |
| 2449 | |
| 2450 | if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) { |
| 2451 | uint16_t lcd_info = |
| 2452 | combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); |
| 2453 | if (lcd_info) { |
| 2454 | uint16_t lcd_ddc_info = |
| 2455 | combios_get_table_offset(dev, |
| 2456 | COMBIOS_LCD_DDC_INFO_TABLE); |
| 2457 | |
| 2458 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2459 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2460 | ATOM_DEVICE_LCD1_SUPPORT, |
| 2461 | 0), |
| 2462 | ATOM_DEVICE_LCD1_SUPPORT); |
| 2463 | |
| 2464 | if (lcd_ddc_info) { |
| 2465 | ddc_type = RBIOS8(lcd_ddc_info + 2); |
| 2466 | switch (ddc_type) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2467 | case DDC_LCD: |
| 2468 | ddc_i2c = |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 2469 | combios_setup_i2c_bus(rdev, |
| 2470 | DDC_LCD, |
| 2471 | RBIOS32(lcd_ddc_info + 3), |
| 2472 | RBIOS32(lcd_ddc_info + 7)); |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 2473 | radeon_i2c_add(rdev, &ddc_i2c, "LCD"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2474 | break; |
| 2475 | case DDC_GPIO: |
| 2476 | ddc_i2c = |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 2477 | combios_setup_i2c_bus(rdev, |
| 2478 | DDC_GPIO, |
| 2479 | RBIOS32(lcd_ddc_info + 3), |
| 2480 | RBIOS32(lcd_ddc_info + 7)); |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 2481 | radeon_i2c_add(rdev, &ddc_i2c, "LCD"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2482 | break; |
| 2483 | default: |
Alex Deucher | 179e807 | 2010-08-05 21:21:17 -0400 | [diff] [blame] | 2484 | ddc_i2c = |
| 2485 | combios_setup_i2c_bus(rdev, ddc_type, 0, 0); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2486 | break; |
| 2487 | } |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2488 | DRM_DEBUG_KMS("LCD DDC Info Table found!\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2489 | } else |
| 2490 | ddc_i2c.valid = false; |
| 2491 | |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2492 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2493 | radeon_add_legacy_connector(dev, |
| 2494 | 5, |
| 2495 | ATOM_DEVICE_LCD1_SUPPORT, |
| 2496 | DRM_MODE_CONNECTOR_LVDS, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2497 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2498 | CONNECTOR_OBJECT_ID_LVDS, |
| 2499 | &hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2500 | } |
| 2501 | } |
| 2502 | |
| 2503 | /* check TV table */ |
| 2504 | if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { |
| 2505 | uint32_t tv_info = |
| 2506 | combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); |
| 2507 | if (tv_info) { |
| 2508 | if (RBIOS8(tv_info + 6) == 'T') { |
Alex Deucher | 790cfb3 | 2009-10-15 23:26:09 -0400 | [diff] [blame] | 2509 | if (radeon_apply_legacy_tv_quirks(dev)) { |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2510 | hpd.hpd = RADEON_HPD_NONE; |
Dave Airlie | d294ed6 | 2010-06-08 13:04:50 +1000 | [diff] [blame] | 2511 | ddc_i2c.valid = false; |
Alex Deucher | 790cfb3 | 2009-10-15 23:26:09 -0400 | [diff] [blame] | 2512 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 2513 | radeon_get_encoder_enum |
Alex Deucher | 790cfb3 | 2009-10-15 23:26:09 -0400 | [diff] [blame] | 2514 | (dev, |
| 2515 | ATOM_DEVICE_TV1_SUPPORT, |
| 2516 | 2), |
| 2517 | ATOM_DEVICE_TV1_SUPPORT); |
| 2518 | radeon_add_legacy_connector(dev, 6, |
| 2519 | ATOM_DEVICE_TV1_SUPPORT, |
| 2520 | DRM_MODE_CONNECTOR_SVIDEO, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 2521 | &ddc_i2c, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 2522 | CONNECTOR_OBJECT_ID_SVIDEO, |
| 2523 | &hpd); |
Alex Deucher | 790cfb3 | 2009-10-15 23:26:09 -0400 | [diff] [blame] | 2524 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2525 | } |
| 2526 | } |
| 2527 | } |
| 2528 | |
| 2529 | radeon_link_encoder_connector(dev); |
| 2530 | |
| 2531 | return true; |
| 2532 | } |
| 2533 | |
Alex Deucher | 63f7d98 | 2011-05-03 12:44:54 -0400 | [diff] [blame] | 2534 | static const char *thermal_controller_names[] = { |
| 2535 | "NONE", |
| 2536 | "lm63", |
| 2537 | "adm1032", |
| 2538 | }; |
| 2539 | |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2540 | void radeon_combios_get_power_modes(struct radeon_device *rdev) |
| 2541 | { |
| 2542 | struct drm_device *dev = rdev->ddev; |
| 2543 | u16 offset, misc, misc2 = 0; |
| 2544 | u8 rev, blocks, tmp; |
| 2545 | int state_index = 0; |
| 2546 | |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 2547 | rdev->pm.default_power_state_index = -1; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2548 | |
Alex Deucher | 0975b16 | 2011-02-02 18:42:03 -0500 | [diff] [blame] | 2549 | /* allocate 2 power states */ |
| 2550 | rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * 2, GFP_KERNEL); |
| 2551 | if (!rdev->pm.power_state) { |
| 2552 | rdev->pm.default_power_state_index = state_index; |
| 2553 | rdev->pm.num_power_states = 0; |
| 2554 | |
| 2555 | rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; |
| 2556 | rdev->pm.current_clock_mode_index = 0; |
| 2557 | return; |
| 2558 | } |
| 2559 | |
Alex Deucher | 63f7d98 | 2011-05-03 12:44:54 -0400 | [diff] [blame] | 2560 | /* check for a thermal chip */ |
| 2561 | offset = combios_get_table_offset(dev, COMBIOS_OVERDRIVE_INFO_TABLE); |
| 2562 | if (offset) { |
| 2563 | u8 thermal_controller = 0, gpio = 0, i2c_addr = 0, clk_bit = 0, data_bit = 0; |
| 2564 | struct radeon_i2c_bus_rec i2c_bus; |
| 2565 | |
| 2566 | rev = RBIOS8(offset); |
| 2567 | |
| 2568 | if (rev == 0) { |
| 2569 | thermal_controller = RBIOS8(offset + 3); |
| 2570 | gpio = RBIOS8(offset + 4) & 0x3f; |
| 2571 | i2c_addr = RBIOS8(offset + 5); |
| 2572 | } else if (rev == 1) { |
| 2573 | thermal_controller = RBIOS8(offset + 4); |
| 2574 | gpio = RBIOS8(offset + 5) & 0x3f; |
| 2575 | i2c_addr = RBIOS8(offset + 6); |
| 2576 | } else if (rev == 2) { |
| 2577 | thermal_controller = RBIOS8(offset + 4); |
| 2578 | gpio = RBIOS8(offset + 5) & 0x3f; |
| 2579 | i2c_addr = RBIOS8(offset + 6); |
| 2580 | clk_bit = RBIOS8(offset + 0xa); |
| 2581 | data_bit = RBIOS8(offset + 0xb); |
| 2582 | } |
| 2583 | if ((thermal_controller > 0) && (thermal_controller < 3)) { |
| 2584 | DRM_INFO("Possible %s thermal controller at 0x%02x\n", |
| 2585 | thermal_controller_names[thermal_controller], |
| 2586 | i2c_addr >> 1); |
| 2587 | if (gpio == DDC_LCD) { |
| 2588 | /* MM i2c */ |
| 2589 | i2c_bus.valid = true; |
| 2590 | i2c_bus.hw_capable = true; |
| 2591 | i2c_bus.mm_i2c = true; |
| 2592 | i2c_bus.i2c_id = 0xa0; |
| 2593 | } else if (gpio == DDC_GPIO) |
| 2594 | i2c_bus = combios_setup_i2c_bus(rdev, gpio, 1 << clk_bit, 1 << data_bit); |
| 2595 | else |
| 2596 | i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0); |
| 2597 | rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); |
| 2598 | if (rdev->pm.i2c_bus) { |
| 2599 | struct i2c_board_info info = { }; |
| 2600 | const char *name = thermal_controller_names[thermal_controller]; |
| 2601 | info.addr = i2c_addr >> 1; |
| 2602 | strlcpy(info.type, name, sizeof(info.type)); |
| 2603 | i2c_new_device(&rdev->pm.i2c_bus->adapter, &info); |
| 2604 | } |
| 2605 | } |
| 2606 | } |
| 2607 | |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2608 | if (rdev->flags & RADEON_IS_MOBILITY) { |
| 2609 | offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE); |
| 2610 | if (offset) { |
| 2611 | rev = RBIOS8(offset); |
| 2612 | blocks = RBIOS8(offset + 0x2); |
| 2613 | /* power mode 0 tends to be the only valid one */ |
| 2614 | rdev->pm.power_state[state_index].num_clock_modes = 1; |
| 2615 | rdev->pm.power_state[state_index].clock_info[0].mclk = RBIOS32(offset + 0x5 + 0x2); |
| 2616 | rdev->pm.power_state[state_index].clock_info[0].sclk = RBIOS32(offset + 0x5 + 0x6); |
| 2617 | if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) || |
| 2618 | (rdev->pm.power_state[state_index].clock_info[0].sclk == 0)) |
| 2619 | goto default_mode; |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 2620 | rdev->pm.power_state[state_index].type = |
| 2621 | POWER_STATE_TYPE_BATTERY; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2622 | misc = RBIOS16(offset + 0x5 + 0x0); |
| 2623 | if (rev > 4) |
| 2624 | misc2 = RBIOS16(offset + 0x5 + 0xe); |
Alex Deucher | 79daedc | 2010-04-22 14:25:19 -0400 | [diff] [blame] | 2625 | rdev->pm.power_state[state_index].misc = misc; |
| 2626 | rdev->pm.power_state[state_index].misc2 = misc2; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2627 | if (misc & 0x4) { |
| 2628 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_GPIO; |
| 2629 | if (misc & 0x8) |
| 2630 | rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = |
| 2631 | true; |
| 2632 | else |
| 2633 | rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = |
| 2634 | false; |
| 2635 | rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = true; |
| 2636 | if (rev < 6) { |
| 2637 | rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = |
| 2638 | RBIOS16(offset + 0x5 + 0xb) * 4; |
| 2639 | tmp = RBIOS8(offset + 0x5 + 0xd); |
| 2640 | rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); |
| 2641 | } else { |
| 2642 | u8 entries = RBIOS8(offset + 0x5 + 0xb); |
| 2643 | u16 voltage_table_offset = RBIOS16(offset + 0x5 + 0xc); |
| 2644 | if (entries && voltage_table_offset) { |
| 2645 | rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = |
| 2646 | RBIOS16(voltage_table_offset) * 4; |
| 2647 | tmp = RBIOS8(voltage_table_offset + 0x2); |
| 2648 | rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); |
| 2649 | } else |
| 2650 | rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = false; |
| 2651 | } |
| 2652 | switch ((misc2 & 0x700) >> 8) { |
| 2653 | case 0: |
| 2654 | default: |
| 2655 | rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 0; |
| 2656 | break; |
| 2657 | case 1: |
| 2658 | rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 33; |
| 2659 | break; |
| 2660 | case 2: |
| 2661 | rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 66; |
| 2662 | break; |
| 2663 | case 3: |
| 2664 | rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 99; |
| 2665 | break; |
| 2666 | case 4: |
| 2667 | rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 132; |
| 2668 | break; |
| 2669 | } |
| 2670 | } else |
| 2671 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; |
| 2672 | if (rev > 6) |
Alex Deucher | 79daedc | 2010-04-22 14:25:19 -0400 | [diff] [blame] | 2673 | rdev->pm.power_state[state_index].pcie_lanes = |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2674 | RBIOS8(offset + 0x5 + 0x10); |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 2675 | rdev->pm.power_state[state_index].flags = RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2676 | state_index++; |
| 2677 | } else { |
| 2678 | /* XXX figure out some good default low power mode for mobility cards w/out power tables */ |
| 2679 | } |
| 2680 | } else { |
| 2681 | /* XXX figure out some good default low power mode for desktop cards */ |
| 2682 | } |
| 2683 | |
| 2684 | default_mode: |
| 2685 | /* add the default mode */ |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 2686 | rdev->pm.power_state[state_index].type = |
| 2687 | POWER_STATE_TYPE_DEFAULT; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2688 | rdev->pm.power_state[state_index].num_clock_modes = 1; |
| 2689 | rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk; |
| 2690 | rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk; |
| 2691 | rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0]; |
Alex Deucher | 84d88f4 | 2010-05-27 17:01:42 -0400 | [diff] [blame] | 2692 | if ((state_index > 0) && |
Alex Deucher | 8de016e | 2010-06-03 21:28:23 -0400 | [diff] [blame] | 2693 | (rdev->pm.power_state[0].clock_info[0].voltage.type == VOLTAGE_GPIO)) |
Alex Deucher | 84d88f4 | 2010-05-27 17:01:42 -0400 | [diff] [blame] | 2694 | rdev->pm.power_state[state_index].clock_info[0].voltage = |
| 2695 | rdev->pm.power_state[0].clock_info[0].voltage; |
| 2696 | else |
| 2697 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; |
Alex Deucher | 79daedc | 2010-04-22 14:25:19 -0400 | [diff] [blame] | 2698 | rdev->pm.power_state[state_index].pcie_lanes = 16; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 2699 | rdev->pm.power_state[state_index].flags = 0; |
| 2700 | rdev->pm.default_power_state_index = state_index; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2701 | rdev->pm.num_power_states = state_index + 1; |
Rafał Miłecki | 9038dfd | 2010-02-20 23:15:04 +0000 | [diff] [blame] | 2702 | |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 2703 | rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; |
| 2704 | rdev->pm.current_clock_mode_index = 0; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2705 | } |
| 2706 | |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 2707 | void radeon_external_tmds_setup(struct drm_encoder *encoder) |
| 2708 | { |
| 2709 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 2710 | struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; |
| 2711 | |
| 2712 | if (!tmds) |
| 2713 | return; |
| 2714 | |
| 2715 | switch (tmds->dvo_chip) { |
| 2716 | case DVO_SIL164: |
| 2717 | /* sil 164 */ |
Alex Deucher | 5a6f98f | 2009-12-22 15:04:48 -0500 | [diff] [blame] | 2718 | radeon_i2c_put_byte(tmds->i2c_bus, |
| 2719 | tmds->slave_addr, |
| 2720 | 0x08, 0x30); |
| 2721 | radeon_i2c_put_byte(tmds->i2c_bus, |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 2722 | tmds->slave_addr, |
| 2723 | 0x09, 0x00); |
Alex Deucher | 5a6f98f | 2009-12-22 15:04:48 -0500 | [diff] [blame] | 2724 | radeon_i2c_put_byte(tmds->i2c_bus, |
| 2725 | tmds->slave_addr, |
| 2726 | 0x0a, 0x90); |
| 2727 | radeon_i2c_put_byte(tmds->i2c_bus, |
| 2728 | tmds->slave_addr, |
| 2729 | 0x0c, 0x89); |
| 2730 | radeon_i2c_put_byte(tmds->i2c_bus, |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 2731 | tmds->slave_addr, |
| 2732 | 0x08, 0x3b); |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 2733 | break; |
| 2734 | case DVO_SIL1178: |
| 2735 | /* sil 1178 - untested */ |
| 2736 | /* |
| 2737 | * 0x0f, 0x44 |
| 2738 | * 0x0f, 0x4c |
| 2739 | * 0x0e, 0x01 |
| 2740 | * 0x0a, 0x80 |
| 2741 | * 0x09, 0x30 |
| 2742 | * 0x0c, 0xc9 |
| 2743 | * 0x0d, 0x70 |
| 2744 | * 0x08, 0x32 |
| 2745 | * 0x08, 0x33 |
| 2746 | */ |
| 2747 | break; |
| 2748 | default: |
| 2749 | break; |
| 2750 | } |
| 2751 | |
| 2752 | } |
| 2753 | |
| 2754 | bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder) |
| 2755 | { |
| 2756 | struct drm_device *dev = encoder->dev; |
| 2757 | struct radeon_device *rdev = dev->dev_private; |
| 2758 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 2759 | uint16_t offset; |
| 2760 | uint8_t blocks, slave_addr, rev; |
| 2761 | uint32_t index, id; |
| 2762 | uint32_t reg, val, and_mask, or_mask; |
| 2763 | struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; |
| 2764 | |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 2765 | if (!tmds) |
| 2766 | return false; |
| 2767 | |
| 2768 | if (rdev->flags & RADEON_IS_IGP) { |
| 2769 | offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE); |
| 2770 | rev = RBIOS8(offset); |
| 2771 | if (offset) { |
| 2772 | rev = RBIOS8(offset); |
| 2773 | if (rev > 1) { |
| 2774 | blocks = RBIOS8(offset + 3); |
| 2775 | index = offset + 4; |
| 2776 | while (blocks > 0) { |
| 2777 | id = RBIOS16(index); |
| 2778 | index += 2; |
| 2779 | switch (id >> 13) { |
| 2780 | case 0: |
| 2781 | reg = (id & 0x1fff) * 4; |
| 2782 | val = RBIOS32(index); |
| 2783 | index += 4; |
| 2784 | WREG32(reg, val); |
| 2785 | break; |
| 2786 | case 2: |
| 2787 | reg = (id & 0x1fff) * 4; |
| 2788 | and_mask = RBIOS32(index); |
| 2789 | index += 4; |
| 2790 | or_mask = RBIOS32(index); |
| 2791 | index += 4; |
| 2792 | val = RREG32(reg); |
| 2793 | val = (val & and_mask) | or_mask; |
| 2794 | WREG32(reg, val); |
| 2795 | break; |
| 2796 | case 3: |
| 2797 | val = RBIOS16(index); |
| 2798 | index += 2; |
| 2799 | udelay(val); |
| 2800 | break; |
| 2801 | case 4: |
| 2802 | val = RBIOS16(index); |
| 2803 | index += 2; |
| 2804 | udelay(val * 1000); |
| 2805 | break; |
| 2806 | case 6: |
| 2807 | slave_addr = id & 0xff; |
| 2808 | slave_addr >>= 1; /* 7 bit addressing */ |
| 2809 | index++; |
| 2810 | reg = RBIOS8(index); |
| 2811 | index++; |
| 2812 | val = RBIOS8(index); |
| 2813 | index++; |
Alex Deucher | 5a6f98f | 2009-12-22 15:04:48 -0500 | [diff] [blame] | 2814 | radeon_i2c_put_byte(tmds->i2c_bus, |
| 2815 | slave_addr, |
| 2816 | reg, val); |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 2817 | break; |
| 2818 | default: |
| 2819 | DRM_ERROR("Unknown id %d\n", id >> 13); |
| 2820 | break; |
| 2821 | } |
| 2822 | blocks--; |
| 2823 | } |
| 2824 | return true; |
| 2825 | } |
| 2826 | } |
| 2827 | } else { |
| 2828 | offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); |
| 2829 | if (offset) { |
| 2830 | index = offset + 10; |
| 2831 | id = RBIOS16(index); |
| 2832 | while (id != 0xffff) { |
| 2833 | index += 2; |
| 2834 | switch (id >> 13) { |
| 2835 | case 0: |
| 2836 | reg = (id & 0x1fff) * 4; |
| 2837 | val = RBIOS32(index); |
| 2838 | WREG32(reg, val); |
| 2839 | break; |
| 2840 | case 2: |
| 2841 | reg = (id & 0x1fff) * 4; |
| 2842 | and_mask = RBIOS32(index); |
| 2843 | index += 4; |
| 2844 | or_mask = RBIOS32(index); |
| 2845 | index += 4; |
| 2846 | val = RREG32(reg); |
| 2847 | val = (val & and_mask) | or_mask; |
| 2848 | WREG32(reg, val); |
| 2849 | break; |
| 2850 | case 4: |
| 2851 | val = RBIOS16(index); |
| 2852 | index += 2; |
| 2853 | udelay(val); |
| 2854 | break; |
| 2855 | case 5: |
| 2856 | reg = id & 0x1fff; |
| 2857 | and_mask = RBIOS32(index); |
| 2858 | index += 4; |
| 2859 | or_mask = RBIOS32(index); |
| 2860 | index += 4; |
| 2861 | val = RREG32_PLL(reg); |
| 2862 | val = (val & and_mask) | or_mask; |
| 2863 | WREG32_PLL(reg, val); |
| 2864 | break; |
| 2865 | case 6: |
| 2866 | reg = id & 0x1fff; |
| 2867 | val = RBIOS8(index); |
| 2868 | index += 1; |
Alex Deucher | 5a6f98f | 2009-12-22 15:04:48 -0500 | [diff] [blame] | 2869 | radeon_i2c_put_byte(tmds->i2c_bus, |
| 2870 | tmds->slave_addr, |
| 2871 | reg, val); |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 2872 | break; |
| 2873 | default: |
| 2874 | DRM_ERROR("Unknown id %d\n", id >> 13); |
| 2875 | break; |
| 2876 | } |
| 2877 | id = RBIOS16(index); |
| 2878 | } |
| 2879 | return true; |
| 2880 | } |
| 2881 | } |
| 2882 | return false; |
| 2883 | } |
| 2884 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2885 | static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset) |
| 2886 | { |
| 2887 | struct radeon_device *rdev = dev->dev_private; |
| 2888 | |
| 2889 | if (offset) { |
| 2890 | while (RBIOS16(offset)) { |
| 2891 | uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13); |
| 2892 | uint32_t addr = (RBIOS16(offset) & 0x1fff); |
| 2893 | uint32_t val, and_mask, or_mask; |
| 2894 | uint32_t tmp; |
| 2895 | |
| 2896 | offset += 2; |
| 2897 | switch (cmd) { |
| 2898 | case 0: |
| 2899 | val = RBIOS32(offset); |
| 2900 | offset += 4; |
| 2901 | WREG32(addr, val); |
| 2902 | break; |
| 2903 | case 1: |
| 2904 | val = RBIOS32(offset); |
| 2905 | offset += 4; |
| 2906 | WREG32(addr, val); |
| 2907 | break; |
| 2908 | case 2: |
| 2909 | and_mask = RBIOS32(offset); |
| 2910 | offset += 4; |
| 2911 | or_mask = RBIOS32(offset); |
| 2912 | offset += 4; |
| 2913 | tmp = RREG32(addr); |
| 2914 | tmp &= and_mask; |
| 2915 | tmp |= or_mask; |
| 2916 | WREG32(addr, tmp); |
| 2917 | break; |
| 2918 | case 3: |
| 2919 | and_mask = RBIOS32(offset); |
| 2920 | offset += 4; |
| 2921 | or_mask = RBIOS32(offset); |
| 2922 | offset += 4; |
| 2923 | tmp = RREG32(addr); |
| 2924 | tmp &= and_mask; |
| 2925 | tmp |= or_mask; |
| 2926 | WREG32(addr, tmp); |
| 2927 | break; |
| 2928 | case 4: |
| 2929 | val = RBIOS16(offset); |
| 2930 | offset += 2; |
| 2931 | udelay(val); |
| 2932 | break; |
| 2933 | case 5: |
| 2934 | val = RBIOS16(offset); |
| 2935 | offset += 2; |
| 2936 | switch (addr) { |
| 2937 | case 8: |
| 2938 | while (val--) { |
| 2939 | if (! |
| 2940 | (RREG32_PLL |
| 2941 | (RADEON_CLK_PWRMGT_CNTL) & |
| 2942 | RADEON_MC_BUSY)) |
| 2943 | break; |
| 2944 | } |
| 2945 | break; |
| 2946 | case 9: |
| 2947 | while (val--) { |
| 2948 | if ((RREG32(RADEON_MC_STATUS) & |
| 2949 | RADEON_MC_IDLE)) |
| 2950 | break; |
| 2951 | } |
| 2952 | break; |
| 2953 | default: |
| 2954 | break; |
| 2955 | } |
| 2956 | break; |
| 2957 | default: |
| 2958 | break; |
| 2959 | } |
| 2960 | } |
| 2961 | } |
| 2962 | } |
| 2963 | |
| 2964 | static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset) |
| 2965 | { |
| 2966 | struct radeon_device *rdev = dev->dev_private; |
| 2967 | |
| 2968 | if (offset) { |
| 2969 | while (RBIOS8(offset)) { |
| 2970 | uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6); |
| 2971 | uint8_t addr = (RBIOS8(offset) & 0x3f); |
| 2972 | uint32_t val, shift, tmp; |
| 2973 | uint32_t and_mask, or_mask; |
| 2974 | |
| 2975 | offset++; |
| 2976 | switch (cmd) { |
| 2977 | case 0: |
| 2978 | val = RBIOS32(offset); |
| 2979 | offset += 4; |
| 2980 | WREG32_PLL(addr, val); |
| 2981 | break; |
| 2982 | case 1: |
| 2983 | shift = RBIOS8(offset) * 8; |
| 2984 | offset++; |
| 2985 | and_mask = RBIOS8(offset) << shift; |
| 2986 | and_mask |= ~(0xff << shift); |
| 2987 | offset++; |
| 2988 | or_mask = RBIOS8(offset) << shift; |
| 2989 | offset++; |
| 2990 | tmp = RREG32_PLL(addr); |
| 2991 | tmp &= and_mask; |
| 2992 | tmp |= or_mask; |
| 2993 | WREG32_PLL(addr, tmp); |
| 2994 | break; |
| 2995 | case 2: |
| 2996 | case 3: |
| 2997 | tmp = 1000; |
| 2998 | switch (addr) { |
| 2999 | case 1: |
| 3000 | udelay(150); |
| 3001 | break; |
| 3002 | case 2: |
| 3003 | udelay(1000); |
| 3004 | break; |
| 3005 | case 3: |
| 3006 | while (tmp--) { |
| 3007 | if (! |
| 3008 | (RREG32_PLL |
| 3009 | (RADEON_CLK_PWRMGT_CNTL) & |
| 3010 | RADEON_MC_BUSY)) |
| 3011 | break; |
| 3012 | } |
| 3013 | break; |
| 3014 | case 4: |
| 3015 | while (tmp--) { |
| 3016 | if (RREG32_PLL |
| 3017 | (RADEON_CLK_PWRMGT_CNTL) & |
| 3018 | RADEON_DLL_READY) |
| 3019 | break; |
| 3020 | } |
| 3021 | break; |
| 3022 | case 5: |
| 3023 | tmp = |
| 3024 | RREG32_PLL(RADEON_CLK_PWRMGT_CNTL); |
| 3025 | if (tmp & RADEON_CG_NO1_DEBUG_0) { |
| 3026 | #if 0 |
| 3027 | uint32_t mclk_cntl = |
| 3028 | RREG32_PLL |
| 3029 | (RADEON_MCLK_CNTL); |
| 3030 | mclk_cntl &= 0xffff0000; |
| 3031 | /*mclk_cntl |= 0x00001111;*//* ??? */ |
| 3032 | WREG32_PLL(RADEON_MCLK_CNTL, |
| 3033 | mclk_cntl); |
| 3034 | udelay(10000); |
| 3035 | #endif |
| 3036 | WREG32_PLL |
| 3037 | (RADEON_CLK_PWRMGT_CNTL, |
| 3038 | tmp & |
| 3039 | ~RADEON_CG_NO1_DEBUG_0); |
| 3040 | udelay(10000); |
| 3041 | } |
| 3042 | break; |
| 3043 | default: |
| 3044 | break; |
| 3045 | } |
| 3046 | break; |
| 3047 | default: |
| 3048 | break; |
| 3049 | } |
| 3050 | } |
| 3051 | } |
| 3052 | } |
| 3053 | |
| 3054 | static void combios_parse_ram_reset_table(struct drm_device *dev, |
| 3055 | uint16_t offset) |
| 3056 | { |
| 3057 | struct radeon_device *rdev = dev->dev_private; |
| 3058 | uint32_t tmp; |
| 3059 | |
| 3060 | if (offset) { |
| 3061 | uint8_t val = RBIOS8(offset); |
| 3062 | while (val != 0xff) { |
| 3063 | offset++; |
| 3064 | |
| 3065 | if (val == 0x0f) { |
| 3066 | uint32_t channel_complete_mask; |
| 3067 | |
| 3068 | if (ASIC_IS_R300(rdev)) |
| 3069 | channel_complete_mask = |
| 3070 | R300_MEM_PWRUP_COMPLETE; |
| 3071 | else |
| 3072 | channel_complete_mask = |
| 3073 | RADEON_MEM_PWRUP_COMPLETE; |
| 3074 | tmp = 20000; |
| 3075 | while (tmp--) { |
| 3076 | if ((RREG32(RADEON_MEM_STR_CNTL) & |
| 3077 | channel_complete_mask) == |
| 3078 | channel_complete_mask) |
| 3079 | break; |
| 3080 | } |
| 3081 | } else { |
| 3082 | uint32_t or_mask = RBIOS16(offset); |
| 3083 | offset += 2; |
| 3084 | |
| 3085 | tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); |
| 3086 | tmp &= RADEON_SDRAM_MODE_MASK; |
| 3087 | tmp |= or_mask; |
| 3088 | WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); |
| 3089 | |
| 3090 | or_mask = val << 24; |
| 3091 | tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); |
| 3092 | tmp &= RADEON_B3MEM_RESET_MASK; |
| 3093 | tmp |= or_mask; |
| 3094 | WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); |
| 3095 | } |
| 3096 | val = RBIOS8(offset); |
| 3097 | } |
| 3098 | } |
| 3099 | } |
| 3100 | |
| 3101 | static uint32_t combios_detect_ram(struct drm_device *dev, int ram, |
| 3102 | int mem_addr_mapping) |
| 3103 | { |
| 3104 | struct radeon_device *rdev = dev->dev_private; |
| 3105 | uint32_t mem_cntl; |
| 3106 | uint32_t mem_size; |
| 3107 | uint32_t addr = 0; |
| 3108 | |
| 3109 | mem_cntl = RREG32(RADEON_MEM_CNTL); |
| 3110 | if (mem_cntl & RV100_HALF_MODE) |
| 3111 | ram /= 2; |
| 3112 | mem_size = ram; |
| 3113 | mem_cntl &= ~(0xff << 8); |
| 3114 | mem_cntl |= (mem_addr_mapping & 0xff) << 8; |
| 3115 | WREG32(RADEON_MEM_CNTL, mem_cntl); |
| 3116 | RREG32(RADEON_MEM_CNTL); |
| 3117 | |
| 3118 | /* sdram reset ? */ |
| 3119 | |
| 3120 | /* something like this???? */ |
| 3121 | while (ram--) { |
| 3122 | addr = ram * 1024 * 1024; |
| 3123 | /* write to each page */ |
| 3124 | WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); |
| 3125 | WREG32(RADEON_MM_DATA, 0xdeadbeef); |
| 3126 | /* read back and verify */ |
| 3127 | WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); |
| 3128 | if (RREG32(RADEON_MM_DATA) != 0xdeadbeef) |
| 3129 | return 0; |
| 3130 | } |
| 3131 | |
| 3132 | return mem_size; |
| 3133 | } |
| 3134 | |
| 3135 | static void combios_write_ram_size(struct drm_device *dev) |
| 3136 | { |
| 3137 | struct radeon_device *rdev = dev->dev_private; |
| 3138 | uint8_t rev; |
| 3139 | uint16_t offset; |
| 3140 | uint32_t mem_size = 0; |
| 3141 | uint32_t mem_cntl = 0; |
| 3142 | |
| 3143 | /* should do something smarter here I guess... */ |
| 3144 | if (rdev->flags & RADEON_IS_IGP) |
| 3145 | return; |
| 3146 | |
| 3147 | /* first check detected mem table */ |
| 3148 | offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE); |
| 3149 | if (offset) { |
| 3150 | rev = RBIOS8(offset); |
| 3151 | if (rev < 3) { |
| 3152 | mem_cntl = RBIOS32(offset + 1); |
| 3153 | mem_size = RBIOS16(offset + 5); |
Alex Deucher | 4ce9198 | 2010-06-30 12:13:55 -0400 | [diff] [blame] | 3154 | if ((rdev->family < CHIP_R200) && |
| 3155 | !ASIC_IS_RN50(rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3156 | WREG32(RADEON_MEM_CNTL, mem_cntl); |
| 3157 | } |
| 3158 | } |
| 3159 | |
| 3160 | if (!mem_size) { |
| 3161 | offset = |
| 3162 | combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); |
| 3163 | if (offset) { |
| 3164 | rev = RBIOS8(offset - 1); |
| 3165 | if (rev < 1) { |
Alex Deucher | 4ce9198 | 2010-06-30 12:13:55 -0400 | [diff] [blame] | 3166 | if ((rdev->family < CHIP_R200) |
| 3167 | && !ASIC_IS_RN50(rdev)) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3168 | int ram = 0; |
| 3169 | int mem_addr_mapping = 0; |
| 3170 | |
| 3171 | while (RBIOS8(offset)) { |
| 3172 | ram = RBIOS8(offset); |
| 3173 | mem_addr_mapping = |
| 3174 | RBIOS8(offset + 1); |
| 3175 | if (mem_addr_mapping != 0x25) |
| 3176 | ram *= 2; |
| 3177 | mem_size = |
| 3178 | combios_detect_ram(dev, ram, |
| 3179 | mem_addr_mapping); |
| 3180 | if (mem_size) |
| 3181 | break; |
| 3182 | offset += 2; |
| 3183 | } |
| 3184 | } else |
| 3185 | mem_size = RBIOS8(offset); |
| 3186 | } else { |
| 3187 | mem_size = RBIOS8(offset); |
| 3188 | mem_size *= 2; /* convert to MB */ |
| 3189 | } |
| 3190 | } |
| 3191 | } |
| 3192 | |
| 3193 | mem_size *= (1024 * 1024); /* convert to bytes */ |
| 3194 | WREG32(RADEON_CONFIG_MEMSIZE, mem_size); |
| 3195 | } |
| 3196 | |
| 3197 | void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable) |
| 3198 | { |
| 3199 | uint16_t dyn_clk_info = |
| 3200 | combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); |
| 3201 | |
| 3202 | if (dyn_clk_info) |
| 3203 | combios_parse_pll_table(dev, dyn_clk_info); |
| 3204 | } |
| 3205 | |
| 3206 | void radeon_combios_asic_init(struct drm_device *dev) |
| 3207 | { |
| 3208 | struct radeon_device *rdev = dev->dev_private; |
| 3209 | uint16_t table; |
| 3210 | |
| 3211 | /* port hardcoded mac stuff from radeonfb */ |
| 3212 | if (rdev->bios == NULL) |
| 3213 | return; |
| 3214 | |
| 3215 | /* ASIC INIT 1 */ |
| 3216 | table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE); |
| 3217 | if (table) |
| 3218 | combios_parse_mmio_table(dev, table); |
| 3219 | |
| 3220 | /* PLL INIT */ |
| 3221 | table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE); |
| 3222 | if (table) |
| 3223 | combios_parse_pll_table(dev, table); |
| 3224 | |
| 3225 | /* ASIC INIT 2 */ |
| 3226 | table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE); |
| 3227 | if (table) |
| 3228 | combios_parse_mmio_table(dev, table); |
| 3229 | |
| 3230 | if (!(rdev->flags & RADEON_IS_IGP)) { |
| 3231 | /* ASIC INIT 4 */ |
| 3232 | table = |
| 3233 | combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE); |
| 3234 | if (table) |
| 3235 | combios_parse_mmio_table(dev, table); |
| 3236 | |
| 3237 | /* RAM RESET */ |
| 3238 | table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE); |
| 3239 | if (table) |
| 3240 | combios_parse_ram_reset_table(dev, table); |
| 3241 | |
| 3242 | /* ASIC INIT 3 */ |
| 3243 | table = |
| 3244 | combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE); |
| 3245 | if (table) |
| 3246 | combios_parse_mmio_table(dev, table); |
| 3247 | |
| 3248 | /* write CONFIG_MEMSIZE */ |
| 3249 | combios_write_ram_size(dev); |
| 3250 | } |
| 3251 | |
Dave Airlie | 580b4ff | 2010-06-30 13:26:11 +1000 | [diff] [blame] | 3252 | /* quirk for rs4xx HP nx6125 laptop to make it resume |
| 3253 | * - it hangs on resume inside the dynclk 1 table. |
| 3254 | */ |
| 3255 | if (rdev->family == CHIP_RS480 && |
| 3256 | rdev->pdev->subsystem_vendor == 0x103c && |
| 3257 | rdev->pdev->subsystem_device == 0x308b) |
| 3258 | return; |
| 3259 | |
Alex Deucher | 52fa2bb | 2010-07-21 23:54:35 -0400 | [diff] [blame] | 3260 | /* quirk for rs4xx HP dv5000 laptop to make it resume |
| 3261 | * - it hangs on resume inside the dynclk 1 table. |
| 3262 | */ |
| 3263 | if (rdev->family == CHIP_RS480 && |
| 3264 | rdev->pdev->subsystem_vendor == 0x103c && |
| 3265 | rdev->pdev->subsystem_device == 0x30a4) |
| 3266 | return; |
| 3267 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3268 | /* DYN CLK 1 */ |
| 3269 | table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); |
| 3270 | if (table) |
| 3271 | combios_parse_pll_table(dev, table); |
| 3272 | |
| 3273 | } |
| 3274 | |
| 3275 | void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev) |
| 3276 | { |
| 3277 | struct radeon_device *rdev = dev->dev_private; |
| 3278 | uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch; |
| 3279 | |
| 3280 | bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); |
| 3281 | bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); |
| 3282 | bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH); |
| 3283 | |
| 3284 | /* let the bios control the backlight */ |
| 3285 | bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN; |
| 3286 | |
| 3287 | /* tell the bios not to handle mode switching */ |
| 3288 | bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS | |
| 3289 | RADEON_ACC_MODE_CHANGE); |
| 3290 | |
| 3291 | /* tell the bios a driver is loaded */ |
| 3292 | bios_7_scratch |= RADEON_DRV_LOADED; |
| 3293 | |
| 3294 | WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch); |
| 3295 | WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); |
| 3296 | WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch); |
| 3297 | } |
| 3298 | |
| 3299 | void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock) |
| 3300 | { |
| 3301 | struct drm_device *dev = encoder->dev; |
| 3302 | struct radeon_device *rdev = dev->dev_private; |
| 3303 | uint32_t bios_6_scratch; |
| 3304 | |
| 3305 | bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); |
| 3306 | |
| 3307 | if (lock) |
| 3308 | bios_6_scratch |= RADEON_DRIVER_CRITICAL; |
| 3309 | else |
| 3310 | bios_6_scratch &= ~RADEON_DRIVER_CRITICAL; |
| 3311 | |
| 3312 | WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); |
| 3313 | } |
| 3314 | |
| 3315 | void |
| 3316 | radeon_combios_connected_scratch_regs(struct drm_connector *connector, |
| 3317 | struct drm_encoder *encoder, |
| 3318 | bool connected) |
| 3319 | { |
| 3320 | struct drm_device *dev = connector->dev; |
| 3321 | struct radeon_device *rdev = dev->dev_private; |
| 3322 | struct radeon_connector *radeon_connector = |
| 3323 | to_radeon_connector(connector); |
| 3324 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 3325 | uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH); |
| 3326 | uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); |
| 3327 | |
| 3328 | if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) && |
| 3329 | (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) { |
| 3330 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 3331 | DRM_DEBUG_KMS("TV1 connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3332 | /* fix me */ |
| 3333 | bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO; |
| 3334 | /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */ |
| 3335 | bios_5_scratch |= RADEON_TV1_ON; |
| 3336 | bios_5_scratch |= RADEON_ACC_REQ_TV1; |
| 3337 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 3338 | DRM_DEBUG_KMS("TV1 disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3339 | bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK; |
| 3340 | bios_5_scratch &= ~RADEON_TV1_ON; |
| 3341 | bios_5_scratch &= ~RADEON_ACC_REQ_TV1; |
| 3342 | } |
| 3343 | } |
| 3344 | if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) && |
| 3345 | (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) { |
| 3346 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 3347 | DRM_DEBUG_KMS("LCD1 connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3348 | bios_4_scratch |= RADEON_LCD1_ATTACHED; |
| 3349 | bios_5_scratch |= RADEON_LCD1_ON; |
| 3350 | bios_5_scratch |= RADEON_ACC_REQ_LCD1; |
| 3351 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 3352 | DRM_DEBUG_KMS("LCD1 disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3353 | bios_4_scratch &= ~RADEON_LCD1_ATTACHED; |
| 3354 | bios_5_scratch &= ~RADEON_LCD1_ON; |
| 3355 | bios_5_scratch &= ~RADEON_ACC_REQ_LCD1; |
| 3356 | } |
| 3357 | } |
| 3358 | if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) && |
| 3359 | (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) { |
| 3360 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 3361 | DRM_DEBUG_KMS("CRT1 connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3362 | bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR; |
| 3363 | bios_5_scratch |= RADEON_CRT1_ON; |
| 3364 | bios_5_scratch |= RADEON_ACC_REQ_CRT1; |
| 3365 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 3366 | DRM_DEBUG_KMS("CRT1 disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3367 | bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK; |
| 3368 | bios_5_scratch &= ~RADEON_CRT1_ON; |
| 3369 | bios_5_scratch &= ~RADEON_ACC_REQ_CRT1; |
| 3370 | } |
| 3371 | } |
| 3372 | if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) && |
| 3373 | (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) { |
| 3374 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 3375 | DRM_DEBUG_KMS("CRT2 connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3376 | bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR; |
| 3377 | bios_5_scratch |= RADEON_CRT2_ON; |
| 3378 | bios_5_scratch |= RADEON_ACC_REQ_CRT2; |
| 3379 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 3380 | DRM_DEBUG_KMS("CRT2 disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3381 | bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK; |
| 3382 | bios_5_scratch &= ~RADEON_CRT2_ON; |
| 3383 | bios_5_scratch &= ~RADEON_ACC_REQ_CRT2; |
| 3384 | } |
| 3385 | } |
| 3386 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) && |
| 3387 | (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) { |
| 3388 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 3389 | DRM_DEBUG_KMS("DFP1 connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3390 | bios_4_scratch |= RADEON_DFP1_ATTACHED; |
| 3391 | bios_5_scratch |= RADEON_DFP1_ON; |
| 3392 | bios_5_scratch |= RADEON_ACC_REQ_DFP1; |
| 3393 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 3394 | DRM_DEBUG_KMS("DFP1 disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3395 | bios_4_scratch &= ~RADEON_DFP1_ATTACHED; |
| 3396 | bios_5_scratch &= ~RADEON_DFP1_ON; |
| 3397 | bios_5_scratch &= ~RADEON_ACC_REQ_DFP1; |
| 3398 | } |
| 3399 | } |
| 3400 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) && |
| 3401 | (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) { |
| 3402 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 3403 | DRM_DEBUG_KMS("DFP2 connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3404 | bios_4_scratch |= RADEON_DFP2_ATTACHED; |
| 3405 | bios_5_scratch |= RADEON_DFP2_ON; |
| 3406 | bios_5_scratch |= RADEON_ACC_REQ_DFP2; |
| 3407 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 3408 | DRM_DEBUG_KMS("DFP2 disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3409 | bios_4_scratch &= ~RADEON_DFP2_ATTACHED; |
| 3410 | bios_5_scratch &= ~RADEON_DFP2_ON; |
| 3411 | bios_5_scratch &= ~RADEON_ACC_REQ_DFP2; |
| 3412 | } |
| 3413 | } |
| 3414 | WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch); |
| 3415 | WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); |
| 3416 | } |
| 3417 | |
| 3418 | void |
| 3419 | radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc) |
| 3420 | { |
| 3421 | struct drm_device *dev = encoder->dev; |
| 3422 | struct radeon_device *rdev = dev->dev_private; |
| 3423 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 3424 | uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); |
| 3425 | |
| 3426 | if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { |
| 3427 | bios_5_scratch &= ~RADEON_TV1_CRTC_MASK; |
| 3428 | bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT); |
| 3429 | } |
| 3430 | if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { |
| 3431 | bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK; |
| 3432 | bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT); |
| 3433 | } |
| 3434 | if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { |
| 3435 | bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK; |
| 3436 | bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT); |
| 3437 | } |
| 3438 | if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { |
| 3439 | bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK; |
| 3440 | bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT); |
| 3441 | } |
| 3442 | if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { |
| 3443 | bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK; |
| 3444 | bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT); |
| 3445 | } |
| 3446 | if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { |
| 3447 | bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK; |
| 3448 | bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT); |
| 3449 | } |
| 3450 | WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); |
| 3451 | } |
| 3452 | |
| 3453 | void |
| 3454 | radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on) |
| 3455 | { |
| 3456 | struct drm_device *dev = encoder->dev; |
| 3457 | struct radeon_device *rdev = dev->dev_private; |
| 3458 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 3459 | uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); |
| 3460 | |
| 3461 | if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { |
| 3462 | if (on) |
| 3463 | bios_6_scratch |= RADEON_TV_DPMS_ON; |
| 3464 | else |
| 3465 | bios_6_scratch &= ~RADEON_TV_DPMS_ON; |
| 3466 | } |
| 3467 | if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) { |
| 3468 | if (on) |
| 3469 | bios_6_scratch |= RADEON_CRT_DPMS_ON; |
| 3470 | else |
| 3471 | bios_6_scratch &= ~RADEON_CRT_DPMS_ON; |
| 3472 | } |
| 3473 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
| 3474 | if (on) |
| 3475 | bios_6_scratch |= RADEON_LCD_DPMS_ON; |
| 3476 | else |
| 3477 | bios_6_scratch &= ~RADEON_LCD_DPMS_ON; |
| 3478 | } |
| 3479 | if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { |
| 3480 | if (on) |
| 3481 | bios_6_scratch |= RADEON_DFP_DPMS_ON; |
| 3482 | else |
| 3483 | bios_6_scratch &= ~RADEON_DFP_DPMS_ON; |
| 3484 | } |
| 3485 | WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); |
| 3486 | } |