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