1771fe6b9SJerome Glisse /* 2771fe6b9SJerome Glisse * Copyright 2004 ATI Technologies Inc., Markham, Ontario 3771fe6b9SJerome Glisse * Copyright 2007-8 Advanced Micro Devices, Inc. 4771fe6b9SJerome Glisse * Copyright 2008 Red Hat Inc. 5771fe6b9SJerome Glisse * 6771fe6b9SJerome Glisse * Permission is hereby granted, free of charge, to any person obtaining a 7771fe6b9SJerome Glisse * copy of this software and associated documentation files (the "Software"), 8771fe6b9SJerome Glisse * to deal in the Software without restriction, including without limitation 9771fe6b9SJerome Glisse * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10771fe6b9SJerome Glisse * and/or sell copies of the Software, and to permit persons to whom the 11771fe6b9SJerome Glisse * Software is furnished to do so, subject to the following conditions: 12771fe6b9SJerome Glisse * 13771fe6b9SJerome Glisse * The above copyright notice and this permission notice shall be included in 14771fe6b9SJerome Glisse * all copies or substantial portions of the Software. 15771fe6b9SJerome Glisse * 16771fe6b9SJerome Glisse * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17771fe6b9SJerome Glisse * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18771fe6b9SJerome Glisse * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19771fe6b9SJerome Glisse * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20771fe6b9SJerome Glisse * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21771fe6b9SJerome Glisse * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22771fe6b9SJerome Glisse * OTHER DEALINGS IN THE SOFTWARE. 23771fe6b9SJerome Glisse * 24771fe6b9SJerome Glisse * Authors: Dave Airlie 25771fe6b9SJerome Glisse * Alex Deucher 26771fe6b9SJerome Glisse */ 27760285e7SDavid Howells #include <drm/drmP.h> 28760285e7SDavid Howells #include <drm/radeon_drm.h> 29771fe6b9SJerome Glisse #include "radeon.h" 30771fe6b9SJerome Glisse #include "atom.h" 31771fe6b9SJerome Glisse 32771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 33771fe6b9SJerome Glisse /* not sure which of these are needed */ 34771fe6b9SJerome Glisse #include <asm/machdep.h> 35771fe6b9SJerome Glisse #include <asm/pmac_feature.h> 36771fe6b9SJerome Glisse #include <asm/prom.h> 37771fe6b9SJerome Glisse #include <asm/pci-bridge.h> 38771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 39771fe6b9SJerome Glisse 40771fe6b9SJerome Glisse /* from radeon_legacy_encoder.c */ 41771fe6b9SJerome Glisse extern void 425137ee94SAlex Deucher radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_enum, 43771fe6b9SJerome Glisse uint32_t supported_device); 44771fe6b9SJerome Glisse 45771fe6b9SJerome Glisse /* old legacy ATI BIOS routines */ 46771fe6b9SJerome Glisse 47771fe6b9SJerome Glisse /* COMBIOS table offsets */ 48771fe6b9SJerome Glisse enum radeon_combios_table_offset { 49771fe6b9SJerome Glisse /* absolute offset tables */ 50771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_1_TABLE, 51771fe6b9SJerome Glisse COMBIOS_BIOS_SUPPORT_TABLE, 52771fe6b9SJerome Glisse COMBIOS_DAC_PROGRAMMING_TABLE, 53771fe6b9SJerome Glisse COMBIOS_MAX_COLOR_DEPTH_TABLE, 54771fe6b9SJerome Glisse COMBIOS_CRTC_INFO_TABLE, 55771fe6b9SJerome Glisse COMBIOS_PLL_INFO_TABLE, 56771fe6b9SJerome Glisse COMBIOS_TV_INFO_TABLE, 57771fe6b9SJerome Glisse COMBIOS_DFP_INFO_TABLE, 58771fe6b9SJerome Glisse COMBIOS_HW_CONFIG_INFO_TABLE, 59771fe6b9SJerome Glisse COMBIOS_MULTIMEDIA_INFO_TABLE, 60771fe6b9SJerome Glisse COMBIOS_TV_STD_PATCH_TABLE, 61771fe6b9SJerome Glisse COMBIOS_LCD_INFO_TABLE, 62771fe6b9SJerome Glisse COMBIOS_MOBILE_INFO_TABLE, 63771fe6b9SJerome Glisse COMBIOS_PLL_INIT_TABLE, 64771fe6b9SJerome Glisse COMBIOS_MEM_CONFIG_TABLE, 65771fe6b9SJerome Glisse COMBIOS_SAVE_MASK_TABLE, 66771fe6b9SJerome Glisse COMBIOS_HARDCODED_EDID_TABLE, 67771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_2_TABLE, 68771fe6b9SJerome Glisse COMBIOS_CONNECTOR_INFO_TABLE, 69771fe6b9SJerome Glisse COMBIOS_DYN_CLK_1_TABLE, 70771fe6b9SJerome Glisse COMBIOS_RESERVED_MEM_TABLE, 71771fe6b9SJerome Glisse COMBIOS_EXT_TMDS_INFO_TABLE, 72771fe6b9SJerome Glisse COMBIOS_MEM_CLK_INFO_TABLE, 73771fe6b9SJerome Glisse COMBIOS_EXT_DAC_INFO_TABLE, 74771fe6b9SJerome Glisse COMBIOS_MISC_INFO_TABLE, 75771fe6b9SJerome Glisse COMBIOS_CRT_INFO_TABLE, 76771fe6b9SJerome Glisse COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE, 77771fe6b9SJerome Glisse COMBIOS_COMPONENT_VIDEO_INFO_TABLE, 78771fe6b9SJerome Glisse COMBIOS_FAN_SPEED_INFO_TABLE, 79771fe6b9SJerome Glisse COMBIOS_OVERDRIVE_INFO_TABLE, 80771fe6b9SJerome Glisse COMBIOS_OEM_INFO_TABLE, 81771fe6b9SJerome Glisse COMBIOS_DYN_CLK_2_TABLE, 82771fe6b9SJerome Glisse COMBIOS_POWER_CONNECTOR_INFO_TABLE, 83771fe6b9SJerome Glisse COMBIOS_I2C_INFO_TABLE, 84771fe6b9SJerome Glisse /* relative offset tables */ 85771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_3_TABLE, /* offset from misc info */ 86771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_4_TABLE, /* offset from misc info */ 87771fe6b9SJerome Glisse COMBIOS_DETECTED_MEM_TABLE, /* offset from misc info */ 88771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_5_TABLE, /* offset from misc info */ 89771fe6b9SJerome Glisse COMBIOS_RAM_RESET_TABLE, /* offset from mem config */ 90771fe6b9SJerome Glisse COMBIOS_POWERPLAY_INFO_TABLE, /* offset from mobile info */ 91771fe6b9SJerome Glisse COMBIOS_GPIO_INFO_TABLE, /* offset from mobile info */ 92771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE, /* offset from mobile info */ 93771fe6b9SJerome Glisse COMBIOS_TMDS_POWER_TABLE, /* offset from mobile info */ 94771fe6b9SJerome Glisse COMBIOS_TMDS_POWER_ON_TABLE, /* offset from tmds power */ 95771fe6b9SJerome Glisse COMBIOS_TMDS_POWER_OFF_TABLE, /* offset from tmds power */ 96771fe6b9SJerome Glisse }; 97771fe6b9SJerome Glisse 98771fe6b9SJerome Glisse enum radeon_combios_ddc { 99771fe6b9SJerome Glisse DDC_NONE_DETECTED, 100771fe6b9SJerome Glisse DDC_MONID, 101771fe6b9SJerome Glisse DDC_DVI, 102771fe6b9SJerome Glisse DDC_VGA, 103771fe6b9SJerome Glisse DDC_CRT2, 104771fe6b9SJerome Glisse DDC_LCD, 105771fe6b9SJerome Glisse DDC_GPIO, 106771fe6b9SJerome Glisse }; 107771fe6b9SJerome Glisse 108771fe6b9SJerome Glisse enum radeon_combios_connector { 109771fe6b9SJerome Glisse CONNECTOR_NONE_LEGACY, 110771fe6b9SJerome Glisse CONNECTOR_PROPRIETARY_LEGACY, 111771fe6b9SJerome Glisse CONNECTOR_CRT_LEGACY, 112771fe6b9SJerome Glisse CONNECTOR_DVI_I_LEGACY, 113771fe6b9SJerome Glisse CONNECTOR_DVI_D_LEGACY, 114771fe6b9SJerome Glisse CONNECTOR_CTV_LEGACY, 115771fe6b9SJerome Glisse CONNECTOR_STV_LEGACY, 116771fe6b9SJerome Glisse CONNECTOR_UNSUPPORTED_LEGACY 117771fe6b9SJerome Glisse }; 118771fe6b9SJerome Glisse 119080cbcb4SMichele Curti static const int legacy_connector_convert[] = { 120771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_Unknown, 121771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVID, 122771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 123771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 124771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVID, 125771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_Composite, 126771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 127771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_Unknown, 128771fe6b9SJerome Glisse }; 129771fe6b9SJerome Glisse 130771fe6b9SJerome Glisse static uint16_t combios_get_table_offset(struct drm_device *dev, 131771fe6b9SJerome Glisse enum radeon_combios_table_offset table) 132771fe6b9SJerome Glisse { 133771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 134cef1d00cSMark Kettenis int rev, size; 135771fe6b9SJerome Glisse uint16_t offset = 0, check_offset; 136771fe6b9SJerome Glisse 13703047cdfSMichel Dänzer if (!rdev->bios) 13803047cdfSMichel Dänzer return 0; 13903047cdfSMichel Dänzer 140771fe6b9SJerome Glisse switch (table) { 141771fe6b9SJerome Glisse /* absolute offset tables */ 142771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_1_TABLE: 143cef1d00cSMark Kettenis check_offset = 0xc; 144771fe6b9SJerome Glisse break; 145771fe6b9SJerome Glisse case COMBIOS_BIOS_SUPPORT_TABLE: 146cef1d00cSMark Kettenis check_offset = 0x14; 147771fe6b9SJerome Glisse break; 148771fe6b9SJerome Glisse case COMBIOS_DAC_PROGRAMMING_TABLE: 149cef1d00cSMark Kettenis check_offset = 0x2a; 150771fe6b9SJerome Glisse break; 151771fe6b9SJerome Glisse case COMBIOS_MAX_COLOR_DEPTH_TABLE: 152cef1d00cSMark Kettenis check_offset = 0x2c; 153771fe6b9SJerome Glisse break; 154771fe6b9SJerome Glisse case COMBIOS_CRTC_INFO_TABLE: 155cef1d00cSMark Kettenis check_offset = 0x2e; 156771fe6b9SJerome Glisse break; 157771fe6b9SJerome Glisse case COMBIOS_PLL_INFO_TABLE: 158cef1d00cSMark Kettenis check_offset = 0x30; 159771fe6b9SJerome Glisse break; 160771fe6b9SJerome Glisse case COMBIOS_TV_INFO_TABLE: 161cef1d00cSMark Kettenis check_offset = 0x32; 162771fe6b9SJerome Glisse break; 163771fe6b9SJerome Glisse case COMBIOS_DFP_INFO_TABLE: 164cef1d00cSMark Kettenis check_offset = 0x34; 165771fe6b9SJerome Glisse break; 166771fe6b9SJerome Glisse case COMBIOS_HW_CONFIG_INFO_TABLE: 167cef1d00cSMark Kettenis check_offset = 0x36; 168771fe6b9SJerome Glisse break; 169771fe6b9SJerome Glisse case COMBIOS_MULTIMEDIA_INFO_TABLE: 170cef1d00cSMark Kettenis check_offset = 0x38; 171771fe6b9SJerome Glisse break; 172771fe6b9SJerome Glisse case COMBIOS_TV_STD_PATCH_TABLE: 173cef1d00cSMark Kettenis check_offset = 0x3e; 174771fe6b9SJerome Glisse break; 175771fe6b9SJerome Glisse case COMBIOS_LCD_INFO_TABLE: 176cef1d00cSMark Kettenis check_offset = 0x40; 177771fe6b9SJerome Glisse break; 178771fe6b9SJerome Glisse case COMBIOS_MOBILE_INFO_TABLE: 179cef1d00cSMark Kettenis check_offset = 0x42; 180771fe6b9SJerome Glisse break; 181771fe6b9SJerome Glisse case COMBIOS_PLL_INIT_TABLE: 182cef1d00cSMark Kettenis check_offset = 0x46; 183771fe6b9SJerome Glisse break; 184771fe6b9SJerome Glisse case COMBIOS_MEM_CONFIG_TABLE: 185cef1d00cSMark Kettenis check_offset = 0x48; 186771fe6b9SJerome Glisse break; 187771fe6b9SJerome Glisse case COMBIOS_SAVE_MASK_TABLE: 188cef1d00cSMark Kettenis check_offset = 0x4a; 189771fe6b9SJerome Glisse break; 190771fe6b9SJerome Glisse case COMBIOS_HARDCODED_EDID_TABLE: 191cef1d00cSMark Kettenis check_offset = 0x4c; 192771fe6b9SJerome Glisse break; 193771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_2_TABLE: 194cef1d00cSMark Kettenis check_offset = 0x4e; 195771fe6b9SJerome Glisse break; 196771fe6b9SJerome Glisse case COMBIOS_CONNECTOR_INFO_TABLE: 197cef1d00cSMark Kettenis check_offset = 0x50; 198771fe6b9SJerome Glisse break; 199771fe6b9SJerome Glisse case COMBIOS_DYN_CLK_1_TABLE: 200cef1d00cSMark Kettenis check_offset = 0x52; 201771fe6b9SJerome Glisse break; 202771fe6b9SJerome Glisse case COMBIOS_RESERVED_MEM_TABLE: 203cef1d00cSMark Kettenis check_offset = 0x54; 204771fe6b9SJerome Glisse break; 205771fe6b9SJerome Glisse case COMBIOS_EXT_TMDS_INFO_TABLE: 206cef1d00cSMark Kettenis check_offset = 0x58; 207771fe6b9SJerome Glisse break; 208771fe6b9SJerome Glisse case COMBIOS_MEM_CLK_INFO_TABLE: 209cef1d00cSMark Kettenis check_offset = 0x5a; 210771fe6b9SJerome Glisse break; 211771fe6b9SJerome Glisse case COMBIOS_EXT_DAC_INFO_TABLE: 212cef1d00cSMark Kettenis check_offset = 0x5c; 213771fe6b9SJerome Glisse break; 214771fe6b9SJerome Glisse case COMBIOS_MISC_INFO_TABLE: 215cef1d00cSMark Kettenis check_offset = 0x5e; 216771fe6b9SJerome Glisse break; 217771fe6b9SJerome Glisse case COMBIOS_CRT_INFO_TABLE: 218cef1d00cSMark Kettenis check_offset = 0x60; 219771fe6b9SJerome Glisse break; 220771fe6b9SJerome Glisse case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE: 221cef1d00cSMark Kettenis check_offset = 0x62; 222771fe6b9SJerome Glisse break; 223771fe6b9SJerome Glisse case COMBIOS_COMPONENT_VIDEO_INFO_TABLE: 224cef1d00cSMark Kettenis check_offset = 0x64; 225771fe6b9SJerome Glisse break; 226771fe6b9SJerome Glisse case COMBIOS_FAN_SPEED_INFO_TABLE: 227cef1d00cSMark Kettenis check_offset = 0x66; 228771fe6b9SJerome Glisse break; 229771fe6b9SJerome Glisse case COMBIOS_OVERDRIVE_INFO_TABLE: 230cef1d00cSMark Kettenis check_offset = 0x68; 231771fe6b9SJerome Glisse break; 232771fe6b9SJerome Glisse case COMBIOS_OEM_INFO_TABLE: 233cef1d00cSMark Kettenis check_offset = 0x6a; 234771fe6b9SJerome Glisse break; 235771fe6b9SJerome Glisse case COMBIOS_DYN_CLK_2_TABLE: 236cef1d00cSMark Kettenis check_offset = 0x6c; 237771fe6b9SJerome Glisse break; 238771fe6b9SJerome Glisse case COMBIOS_POWER_CONNECTOR_INFO_TABLE: 239cef1d00cSMark Kettenis check_offset = 0x6e; 240771fe6b9SJerome Glisse break; 241771fe6b9SJerome Glisse case COMBIOS_I2C_INFO_TABLE: 242cef1d00cSMark Kettenis check_offset = 0x70; 243771fe6b9SJerome Glisse break; 244771fe6b9SJerome Glisse /* relative offset tables */ 245771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_3_TABLE: /* offset from misc info */ 246771fe6b9SJerome Glisse check_offset = 247771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 248771fe6b9SJerome Glisse if (check_offset) { 249771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 250771fe6b9SJerome Glisse if (rev > 0) { 251771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x3); 252771fe6b9SJerome Glisse if (check_offset) 253771fe6b9SJerome Glisse offset = check_offset; 254771fe6b9SJerome Glisse } 255771fe6b9SJerome Glisse } 256771fe6b9SJerome Glisse break; 257771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_4_TABLE: /* offset from misc info */ 258771fe6b9SJerome Glisse check_offset = 259771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 260771fe6b9SJerome Glisse if (check_offset) { 261771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 262771fe6b9SJerome Glisse if (rev > 0) { 263771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x5); 264771fe6b9SJerome Glisse if (check_offset) 265771fe6b9SJerome Glisse offset = check_offset; 266771fe6b9SJerome Glisse } 267771fe6b9SJerome Glisse } 268771fe6b9SJerome Glisse break; 269771fe6b9SJerome Glisse case COMBIOS_DETECTED_MEM_TABLE: /* offset from misc info */ 270771fe6b9SJerome Glisse check_offset = 271771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 272771fe6b9SJerome Glisse if (check_offset) { 273771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 274771fe6b9SJerome Glisse if (rev > 0) { 275771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x7); 276771fe6b9SJerome Glisse if (check_offset) 277771fe6b9SJerome Glisse offset = check_offset; 278771fe6b9SJerome Glisse } 279771fe6b9SJerome Glisse } 280771fe6b9SJerome Glisse break; 281771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_5_TABLE: /* offset from misc info */ 282771fe6b9SJerome Glisse check_offset = 283771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 284771fe6b9SJerome Glisse if (check_offset) { 285771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 286771fe6b9SJerome Glisse if (rev == 2) { 287771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x9); 288771fe6b9SJerome Glisse if (check_offset) 289771fe6b9SJerome Glisse offset = check_offset; 290771fe6b9SJerome Glisse } 291771fe6b9SJerome Glisse } 292771fe6b9SJerome Glisse break; 293771fe6b9SJerome Glisse case COMBIOS_RAM_RESET_TABLE: /* offset from mem config */ 294771fe6b9SJerome Glisse check_offset = 295771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 296771fe6b9SJerome Glisse if (check_offset) { 297771fe6b9SJerome Glisse while (RBIOS8(check_offset++)); 298771fe6b9SJerome Glisse check_offset += 2; 299771fe6b9SJerome Glisse if (check_offset) 300771fe6b9SJerome Glisse offset = check_offset; 301771fe6b9SJerome Glisse } 302771fe6b9SJerome Glisse break; 303771fe6b9SJerome Glisse case COMBIOS_POWERPLAY_INFO_TABLE: /* offset from mobile info */ 304771fe6b9SJerome Glisse check_offset = 305771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 306771fe6b9SJerome Glisse if (check_offset) { 307771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x11); 308771fe6b9SJerome Glisse if (check_offset) 309771fe6b9SJerome Glisse offset = check_offset; 310771fe6b9SJerome Glisse } 311771fe6b9SJerome Glisse break; 312771fe6b9SJerome Glisse case COMBIOS_GPIO_INFO_TABLE: /* offset from mobile info */ 313771fe6b9SJerome Glisse check_offset = 314771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 315771fe6b9SJerome Glisse if (check_offset) { 316771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x13); 317771fe6b9SJerome Glisse if (check_offset) 318771fe6b9SJerome Glisse offset = check_offset; 319771fe6b9SJerome Glisse } 320771fe6b9SJerome Glisse break; 321771fe6b9SJerome Glisse case COMBIOS_LCD_DDC_INFO_TABLE: /* offset from mobile info */ 322771fe6b9SJerome Glisse check_offset = 323771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 324771fe6b9SJerome Glisse if (check_offset) { 325771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x15); 326771fe6b9SJerome Glisse if (check_offset) 327771fe6b9SJerome Glisse offset = check_offset; 328771fe6b9SJerome Glisse } 329771fe6b9SJerome Glisse break; 330771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_TABLE: /* offset from mobile info */ 331771fe6b9SJerome Glisse check_offset = 332771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 333771fe6b9SJerome Glisse if (check_offset) { 334771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x17); 335771fe6b9SJerome Glisse if (check_offset) 336771fe6b9SJerome Glisse offset = check_offset; 337771fe6b9SJerome Glisse } 338771fe6b9SJerome Glisse break; 339771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_ON_TABLE: /* offset from tmds power */ 340771fe6b9SJerome Glisse check_offset = 341771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); 342771fe6b9SJerome Glisse if (check_offset) { 343771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x2); 344771fe6b9SJerome Glisse if (check_offset) 345771fe6b9SJerome Glisse offset = check_offset; 346771fe6b9SJerome Glisse } 347771fe6b9SJerome Glisse break; 348771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_OFF_TABLE: /* offset from tmds power */ 349771fe6b9SJerome Glisse check_offset = 350771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); 351771fe6b9SJerome Glisse if (check_offset) { 352771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x4); 353771fe6b9SJerome Glisse if (check_offset) 354771fe6b9SJerome Glisse offset = check_offset; 355771fe6b9SJerome Glisse } 356771fe6b9SJerome Glisse break; 357771fe6b9SJerome Glisse default: 358cef1d00cSMark Kettenis check_offset = 0; 359771fe6b9SJerome Glisse break; 360771fe6b9SJerome Glisse } 361771fe6b9SJerome Glisse 362cef1d00cSMark Kettenis size = RBIOS8(rdev->bios_header_start + 0x6); 363cef1d00cSMark Kettenis /* check absolute offset tables */ 364cef1d00cSMark Kettenis if (table < COMBIOS_ASIC_INIT_3_TABLE && check_offset && check_offset < size) 365cef1d00cSMark Kettenis offset = RBIOS16(rdev->bios_header_start + check_offset); 366771fe6b9SJerome Glisse 367cef1d00cSMark Kettenis return offset; 368771fe6b9SJerome Glisse } 369771fe6b9SJerome Glisse 3703c537889SAlex Deucher bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev) 3713c537889SAlex Deucher { 372fafcf94eSAlex Deucher int edid_info, size; 3733c537889SAlex Deucher struct edid *edid; 3747466f4ccSAdam Jackson unsigned char *raw; 3753c537889SAlex Deucher edid_info = combios_get_table_offset(rdev->ddev, COMBIOS_HARDCODED_EDID_TABLE); 3763c537889SAlex Deucher if (!edid_info) 3773c537889SAlex Deucher return false; 3783c537889SAlex Deucher 3797466f4ccSAdam Jackson raw = rdev->bios + edid_info; 380fafcf94eSAlex Deucher size = EDID_LENGTH * (raw[0x7e] + 1); 381fafcf94eSAlex Deucher edid = kmalloc(size, GFP_KERNEL); 3823c537889SAlex Deucher if (edid == NULL) 3833c537889SAlex Deucher return false; 3843c537889SAlex Deucher 385fafcf94eSAlex Deucher memcpy((unsigned char *)edid, raw, size); 3863c537889SAlex Deucher 3873c537889SAlex Deucher if (!drm_edid_is_valid(edid)) { 3883c537889SAlex Deucher kfree(edid); 3893c537889SAlex Deucher return false; 3903c537889SAlex Deucher } 3913c537889SAlex Deucher 3923c537889SAlex Deucher rdev->mode_info.bios_hardcoded_edid = edid; 393fafcf94eSAlex Deucher rdev->mode_info.bios_hardcoded_edid_size = size; 3943c537889SAlex Deucher return true; 3953c537889SAlex Deucher } 3963c537889SAlex Deucher 397c324acd5SAlex Deucher /* this is used for atom LCDs as well */ 3983c537889SAlex Deucher struct edid * 399c324acd5SAlex Deucher radeon_bios_get_hardcoded_edid(struct radeon_device *rdev) 4003c537889SAlex Deucher { 401fafcf94eSAlex Deucher struct edid *edid; 402fafcf94eSAlex Deucher 403fafcf94eSAlex Deucher if (rdev->mode_info.bios_hardcoded_edid) { 404fafcf94eSAlex Deucher edid = kmalloc(rdev->mode_info.bios_hardcoded_edid_size, GFP_KERNEL); 405fafcf94eSAlex Deucher if (edid) { 406fafcf94eSAlex Deucher memcpy((unsigned char *)edid, 407fafcf94eSAlex Deucher (unsigned char *)rdev->mode_info.bios_hardcoded_edid, 408fafcf94eSAlex Deucher rdev->mode_info.bios_hardcoded_edid_size); 409fafcf94eSAlex Deucher return edid; 410fafcf94eSAlex Deucher } 411fafcf94eSAlex Deucher } 4123c537889SAlex Deucher return NULL; 4133c537889SAlex Deucher } 4143c537889SAlex Deucher 4156a93cb25SAlex Deucher static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev, 416179e8078SAlex Deucher enum radeon_combios_ddc ddc, 417179e8078SAlex Deucher u32 clk_mask, 418179e8078SAlex Deucher u32 data_mask) 419771fe6b9SJerome Glisse { 420771fe6b9SJerome Glisse struct radeon_i2c_bus_rec i2c; 421179e8078SAlex Deucher int ddc_line = 0; 422179e8078SAlex Deucher 423179e8078SAlex Deucher /* ddc id = mask reg 424179e8078SAlex Deucher * DDC_NONE_DETECTED = none 425179e8078SAlex Deucher * DDC_DVI = RADEON_GPIO_DVI_DDC 426179e8078SAlex Deucher * DDC_VGA = RADEON_GPIO_VGA_DDC 427179e8078SAlex Deucher * DDC_LCD = RADEON_GPIOPAD_MASK 428179e8078SAlex Deucher * DDC_GPIO = RADEON_MDGPIO_MASK 429508c8d60SAlex Deucher * r1xx 430179e8078SAlex Deucher * DDC_MONID = RADEON_GPIO_MONID 431179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_CRT2_DDC 432508c8d60SAlex Deucher * r200 433179e8078SAlex Deucher * DDC_MONID = RADEON_GPIO_MONID 434179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_DVI_DDC 435508c8d60SAlex Deucher * r300/r350 436508c8d60SAlex Deucher * DDC_MONID = RADEON_GPIO_DVI_DDC 437508c8d60SAlex Deucher * DDC_CRT2 = RADEON_GPIO_DVI_DDC 438508c8d60SAlex Deucher * rv2xx/rv3xx 439508c8d60SAlex Deucher * DDC_MONID = RADEON_GPIO_MONID 440508c8d60SAlex Deucher * DDC_CRT2 = RADEON_GPIO_MONID 441179e8078SAlex Deucher * rs3xx/rs4xx 442179e8078SAlex Deucher * DDC_MONID = RADEON_GPIOPAD_MASK 443179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_MONID 444179e8078SAlex Deucher */ 445179e8078SAlex Deucher switch (ddc) { 446179e8078SAlex Deucher case DDC_NONE_DETECTED: 447179e8078SAlex Deucher default: 448179e8078SAlex Deucher ddc_line = 0; 449179e8078SAlex Deucher break; 450179e8078SAlex Deucher case DDC_DVI: 451179e8078SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 452179e8078SAlex Deucher break; 453179e8078SAlex Deucher case DDC_VGA: 454179e8078SAlex Deucher ddc_line = RADEON_GPIO_VGA_DDC; 455179e8078SAlex Deucher break; 456179e8078SAlex Deucher case DDC_LCD: 457179e8078SAlex Deucher ddc_line = RADEON_GPIOPAD_MASK; 458179e8078SAlex Deucher break; 459179e8078SAlex Deucher case DDC_GPIO: 460179e8078SAlex Deucher ddc_line = RADEON_MDGPIO_MASK; 461179e8078SAlex Deucher break; 462179e8078SAlex Deucher case DDC_MONID: 463179e8078SAlex Deucher if (rdev->family == CHIP_RS300 || 464179e8078SAlex Deucher rdev->family == CHIP_RS400 || 465179e8078SAlex Deucher rdev->family == CHIP_RS480) 466179e8078SAlex Deucher ddc_line = RADEON_GPIOPAD_MASK; 467508c8d60SAlex Deucher else if (rdev->family == CHIP_R300 || 468776f2b7cSAlex Deucher rdev->family == CHIP_R350) { 469508c8d60SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 470776f2b7cSAlex Deucher ddc = DDC_DVI; 471776f2b7cSAlex Deucher } else 472179e8078SAlex Deucher ddc_line = RADEON_GPIO_MONID; 473179e8078SAlex Deucher break; 474179e8078SAlex Deucher case DDC_CRT2: 475508c8d60SAlex Deucher if (rdev->family == CHIP_R200 || 476508c8d60SAlex Deucher rdev->family == CHIP_R300 || 477776f2b7cSAlex Deucher rdev->family == CHIP_R350) { 478179e8078SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 479776f2b7cSAlex Deucher ddc = DDC_DVI; 480776f2b7cSAlex Deucher } else if (rdev->family == CHIP_RS300 || 481776f2b7cSAlex Deucher rdev->family == CHIP_RS400 || 482776f2b7cSAlex Deucher rdev->family == CHIP_RS480) 483508c8d60SAlex Deucher ddc_line = RADEON_GPIO_MONID; 484776f2b7cSAlex Deucher else if (rdev->family >= CHIP_RV350) { 485776f2b7cSAlex Deucher ddc_line = RADEON_GPIO_MONID; 486776f2b7cSAlex Deucher ddc = DDC_MONID; 487776f2b7cSAlex Deucher } else 488179e8078SAlex Deucher ddc_line = RADEON_GPIO_CRT2_DDC; 489179e8078SAlex Deucher break; 490179e8078SAlex Deucher } 491771fe6b9SJerome Glisse 4926a93cb25SAlex Deucher if (ddc_line == RADEON_GPIOPAD_MASK) { 4936a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_GPIOPAD_MASK; 4946a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_GPIOPAD_MASK; 4956a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_GPIOPAD_A; 4966a93cb25SAlex Deucher i2c.a_data_reg = RADEON_GPIOPAD_A; 4976a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_GPIOPAD_EN; 4986a93cb25SAlex Deucher i2c.en_data_reg = RADEON_GPIOPAD_EN; 4996a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_GPIOPAD_Y; 5006a93cb25SAlex Deucher i2c.y_data_reg = RADEON_GPIOPAD_Y; 5016a93cb25SAlex Deucher } else if (ddc_line == RADEON_MDGPIO_MASK) { 5026a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_MDGPIO_MASK; 5036a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_MDGPIO_MASK; 5046a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_MDGPIO_A; 5056a93cb25SAlex Deucher i2c.a_data_reg = RADEON_MDGPIO_A; 5066a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_MDGPIO_EN; 5076a93cb25SAlex Deucher i2c.en_data_reg = RADEON_MDGPIO_EN; 5086a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_MDGPIO_Y; 5096a93cb25SAlex Deucher i2c.y_data_reg = RADEON_MDGPIO_Y; 5106a93cb25SAlex Deucher } else { 511771fe6b9SJerome Glisse i2c.mask_clk_reg = ddc_line; 512771fe6b9SJerome Glisse i2c.mask_data_reg = ddc_line; 513771fe6b9SJerome Glisse i2c.a_clk_reg = ddc_line; 514771fe6b9SJerome Glisse i2c.a_data_reg = ddc_line; 5159b9fe724SAlex Deucher i2c.en_clk_reg = ddc_line; 5169b9fe724SAlex Deucher i2c.en_data_reg = ddc_line; 5179b9fe724SAlex Deucher i2c.y_clk_reg = ddc_line; 5189b9fe724SAlex Deucher i2c.y_data_reg = ddc_line; 519771fe6b9SJerome Glisse } 520771fe6b9SJerome Glisse 521179e8078SAlex Deucher if (clk_mask && data_mask) { 522be663057SAlex Deucher /* system specific masks */ 523179e8078SAlex Deucher i2c.mask_clk_mask = clk_mask; 524179e8078SAlex Deucher i2c.mask_data_mask = data_mask; 525179e8078SAlex Deucher i2c.a_clk_mask = clk_mask; 526179e8078SAlex Deucher i2c.a_data_mask = data_mask; 527179e8078SAlex Deucher i2c.en_clk_mask = clk_mask; 528179e8078SAlex Deucher i2c.en_data_mask = data_mask; 529179e8078SAlex Deucher i2c.y_clk_mask = clk_mask; 530179e8078SAlex Deucher i2c.y_data_mask = data_mask; 531be663057SAlex Deucher } else if ((ddc_line == RADEON_GPIOPAD_MASK) || 532be663057SAlex Deucher (ddc_line == RADEON_MDGPIO_MASK)) { 533be663057SAlex Deucher /* default gpiopad masks */ 534be663057SAlex Deucher i2c.mask_clk_mask = (0x20 << 8); 535be663057SAlex Deucher i2c.mask_data_mask = 0x80; 536be663057SAlex Deucher i2c.a_clk_mask = (0x20 << 8); 537be663057SAlex Deucher i2c.a_data_mask = 0x80; 538be663057SAlex Deucher i2c.en_clk_mask = (0x20 << 8); 539be663057SAlex Deucher i2c.en_data_mask = 0x80; 540be663057SAlex Deucher i2c.y_clk_mask = (0x20 << 8); 541be663057SAlex Deucher i2c.y_data_mask = 0x80; 542179e8078SAlex Deucher } else { 543be663057SAlex Deucher /* default masks for ddc pads */ 544286e0c94SJean Delvare i2c.mask_clk_mask = RADEON_GPIO_MASK_1; 545286e0c94SJean Delvare i2c.mask_data_mask = RADEON_GPIO_MASK_0; 546179e8078SAlex Deucher i2c.a_clk_mask = RADEON_GPIO_A_1; 547179e8078SAlex Deucher i2c.a_data_mask = RADEON_GPIO_A_0; 548179e8078SAlex Deucher i2c.en_clk_mask = RADEON_GPIO_EN_1; 549179e8078SAlex Deucher i2c.en_data_mask = RADEON_GPIO_EN_0; 550179e8078SAlex Deucher i2c.y_clk_mask = RADEON_GPIO_Y_1; 551179e8078SAlex Deucher i2c.y_data_mask = RADEON_GPIO_Y_0; 552179e8078SAlex Deucher } 553179e8078SAlex Deucher 55440bacf16SAlex Deucher switch (rdev->family) { 55540bacf16SAlex Deucher case CHIP_R100: 55640bacf16SAlex Deucher case CHIP_RV100: 55740bacf16SAlex Deucher case CHIP_RS100: 55840bacf16SAlex Deucher case CHIP_RV200: 55940bacf16SAlex Deucher case CHIP_RS200: 56040bacf16SAlex Deucher case CHIP_RS300: 56140bacf16SAlex Deucher switch (ddc_line) { 56240bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 563b28ea411SAlex Deucher i2c.hw_capable = true; 56440bacf16SAlex Deucher break; 56540bacf16SAlex Deucher default: 56640bacf16SAlex Deucher i2c.hw_capable = false; 56740bacf16SAlex Deucher break; 56840bacf16SAlex Deucher } 56940bacf16SAlex Deucher break; 57040bacf16SAlex Deucher case CHIP_R200: 57140bacf16SAlex Deucher switch (ddc_line) { 57240bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 57340bacf16SAlex Deucher case RADEON_GPIO_MONID: 57440bacf16SAlex Deucher i2c.hw_capable = true; 57540bacf16SAlex Deucher break; 57640bacf16SAlex Deucher default: 57740bacf16SAlex Deucher i2c.hw_capable = false; 57840bacf16SAlex Deucher break; 57940bacf16SAlex Deucher } 58040bacf16SAlex Deucher break; 58140bacf16SAlex Deucher case CHIP_RV250: 58240bacf16SAlex Deucher case CHIP_RV280: 58340bacf16SAlex Deucher switch (ddc_line) { 58440bacf16SAlex Deucher case RADEON_GPIO_VGA_DDC: 58540bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 58640bacf16SAlex Deucher case RADEON_GPIO_CRT2_DDC: 58740bacf16SAlex Deucher i2c.hw_capable = true; 58840bacf16SAlex Deucher break; 58940bacf16SAlex Deucher default: 59040bacf16SAlex Deucher i2c.hw_capable = false; 59140bacf16SAlex Deucher break; 59240bacf16SAlex Deucher } 59340bacf16SAlex Deucher break; 59440bacf16SAlex Deucher case CHIP_R300: 59540bacf16SAlex Deucher case CHIP_R350: 59640bacf16SAlex Deucher switch (ddc_line) { 59740bacf16SAlex Deucher case RADEON_GPIO_VGA_DDC: 59840bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 59940bacf16SAlex Deucher i2c.hw_capable = true; 60040bacf16SAlex Deucher break; 60140bacf16SAlex Deucher default: 60240bacf16SAlex Deucher i2c.hw_capable = false; 60340bacf16SAlex Deucher break; 60440bacf16SAlex Deucher } 60540bacf16SAlex Deucher break; 60640bacf16SAlex Deucher case CHIP_RV350: 60740bacf16SAlex Deucher case CHIP_RV380: 60840bacf16SAlex Deucher case CHIP_RS400: 60940bacf16SAlex Deucher case CHIP_RS480: 6106a93cb25SAlex Deucher switch (ddc_line) { 6116a93cb25SAlex Deucher case RADEON_GPIO_VGA_DDC: 6126a93cb25SAlex Deucher case RADEON_GPIO_DVI_DDC: 6136a93cb25SAlex Deucher i2c.hw_capable = true; 6146a93cb25SAlex Deucher break; 6156a93cb25SAlex Deucher case RADEON_GPIO_MONID: 6166a93cb25SAlex Deucher /* hw i2c on RADEON_GPIO_MONID doesn't seem to work 6176a93cb25SAlex Deucher * reliably on some pre-r4xx hardware; not sure why. 6186a93cb25SAlex Deucher */ 6196a93cb25SAlex Deucher i2c.hw_capable = false; 6206a93cb25SAlex Deucher break; 6216a93cb25SAlex Deucher default: 6226a93cb25SAlex Deucher i2c.hw_capable = false; 6236a93cb25SAlex Deucher break; 6246a93cb25SAlex Deucher } 62540bacf16SAlex Deucher break; 62640bacf16SAlex Deucher default: 62740bacf16SAlex Deucher i2c.hw_capable = false; 62840bacf16SAlex Deucher break; 6296a93cb25SAlex Deucher } 6306a93cb25SAlex Deucher i2c.mm_i2c = false; 631f376b94fSAlex Deucher 632179e8078SAlex Deucher i2c.i2c_id = ddc; 6338e36ed00SAlex Deucher i2c.hpd = RADEON_HPD_NONE; 6346a93cb25SAlex Deucher 635771fe6b9SJerome Glisse if (ddc_line) 636771fe6b9SJerome Glisse i2c.valid = true; 637771fe6b9SJerome Glisse else 638771fe6b9SJerome Glisse i2c.valid = false; 639771fe6b9SJerome Glisse 640771fe6b9SJerome Glisse return i2c; 641771fe6b9SJerome Glisse } 642771fe6b9SJerome Glisse 6433d61bd42SAlex Deucher static struct radeon_i2c_bus_rec radeon_combios_get_i2c_info_from_table(struct radeon_device *rdev) 6443d61bd42SAlex Deucher { 6453d61bd42SAlex Deucher struct drm_device *dev = rdev->ddev; 6463d61bd42SAlex Deucher struct radeon_i2c_bus_rec i2c; 6473d61bd42SAlex Deucher u16 offset; 6483d61bd42SAlex Deucher u8 id, blocks, clk, data; 6493d61bd42SAlex Deucher int i; 6503d61bd42SAlex Deucher 6513d61bd42SAlex Deucher i2c.valid = false; 6523d61bd42SAlex Deucher 6533d61bd42SAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE); 6543d61bd42SAlex Deucher if (offset) { 6553d61bd42SAlex Deucher blocks = RBIOS8(offset + 2); 6563d61bd42SAlex Deucher for (i = 0; i < blocks; i++) { 6573d61bd42SAlex Deucher id = RBIOS8(offset + 3 + (i * 5) + 0); 6583d61bd42SAlex Deucher if (id == 136) { 6593d61bd42SAlex Deucher clk = RBIOS8(offset + 3 + (i * 5) + 3); 6603d61bd42SAlex Deucher data = RBIOS8(offset + 3 + (i * 5) + 4); 6613d61bd42SAlex Deucher /* gpiopad */ 6623d61bd42SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 6633d61bd42SAlex Deucher (1 << clk), (1 << data)); 6643d61bd42SAlex Deucher break; 6653d61bd42SAlex Deucher } 6663d61bd42SAlex Deucher } 6673d61bd42SAlex Deucher } 6683d61bd42SAlex Deucher return i2c; 6693d61bd42SAlex Deucher } 6703d61bd42SAlex Deucher 671f376b94fSAlex Deucher void radeon_combios_i2c_init(struct radeon_device *rdev) 672f376b94fSAlex Deucher { 673f376b94fSAlex Deucher struct drm_device *dev = rdev->ddev; 674f376b94fSAlex Deucher struct radeon_i2c_bus_rec i2c; 675f376b94fSAlex Deucher 676508c8d60SAlex Deucher /* actual hw pads 677508c8d60SAlex Deucher * r1xx/rs2xx/rs3xx 678508c8d60SAlex Deucher * 0x60, 0x64, 0x68, 0x6c, gpiopads, mm 679508c8d60SAlex Deucher * r200 680508c8d60SAlex Deucher * 0x60, 0x64, 0x68, mm 681508c8d60SAlex Deucher * r300/r350 682508c8d60SAlex Deucher * 0x60, 0x64, mm 683508c8d60SAlex Deucher * rv2xx/rv3xx/rs4xx 684508c8d60SAlex Deucher * 0x60, 0x64, 0x68, gpiopads, mm 685508c8d60SAlex Deucher */ 686f376b94fSAlex Deucher 687508c8d60SAlex Deucher /* 0x60 */ 688179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 689179e8078SAlex Deucher rdev->i2c_bus[0] = radeon_i2c_create(dev, &i2c, "DVI_DDC"); 690508c8d60SAlex Deucher /* 0x64 */ 691179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 692179e8078SAlex Deucher rdev->i2c_bus[1] = radeon_i2c_create(dev, &i2c, "VGA_DDC"); 693f376b94fSAlex Deucher 694508c8d60SAlex Deucher /* mm i2c */ 695f376b94fSAlex Deucher i2c.valid = true; 696f376b94fSAlex Deucher i2c.hw_capable = true; 697f376b94fSAlex Deucher i2c.mm_i2c = true; 698179e8078SAlex Deucher i2c.i2c_id = 0xa0; 699179e8078SAlex Deucher rdev->i2c_bus[2] = radeon_i2c_create(dev, &i2c, "MM_I2C"); 700179e8078SAlex Deucher 701508c8d60SAlex Deucher if (rdev->family == CHIP_R300 || 702508c8d60SAlex Deucher rdev->family == CHIP_R350) { 703508c8d60SAlex Deucher /* only 2 sw i2c pads */ 704508c8d60SAlex Deucher } else if (rdev->family == CHIP_RS300 || 705179e8078SAlex Deucher rdev->family == CHIP_RS400 || 706179e8078SAlex Deucher rdev->family == CHIP_RS480) { 707508c8d60SAlex Deucher /* 0x68 */ 708179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 709179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 710179e8078SAlex Deucher 711508c8d60SAlex Deucher /* gpiopad */ 7123d61bd42SAlex Deucher i2c = radeon_combios_get_i2c_info_from_table(rdev); 7133d61bd42SAlex Deucher if (i2c.valid) 714179e8078SAlex Deucher rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "GPIOPAD_MASK"); 7156dd66633SAlex Deucher } else if ((rdev->family == CHIP_R200) || 7166dd66633SAlex Deucher (rdev->family >= CHIP_R300)) { 717508c8d60SAlex Deucher /* 0x68 */ 718179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 719179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 720179e8078SAlex Deucher } else { 721508c8d60SAlex Deucher /* 0x68 */ 722179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 723179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 724508c8d60SAlex Deucher /* 0x6c */ 725179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 726179e8078SAlex Deucher rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "CRT2_DDC"); 727179e8078SAlex Deucher } 728f376b94fSAlex Deucher } 729f376b94fSAlex Deucher 730771fe6b9SJerome Glisse bool radeon_combios_get_clock_info(struct drm_device *dev) 731771fe6b9SJerome Glisse { 732771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 733771fe6b9SJerome Glisse uint16_t pll_info; 734771fe6b9SJerome Glisse struct radeon_pll *p1pll = &rdev->clock.p1pll; 735771fe6b9SJerome Glisse struct radeon_pll *p2pll = &rdev->clock.p2pll; 736771fe6b9SJerome Glisse struct radeon_pll *spll = &rdev->clock.spll; 737771fe6b9SJerome Glisse struct radeon_pll *mpll = &rdev->clock.mpll; 738771fe6b9SJerome Glisse int8_t rev; 739771fe6b9SJerome Glisse uint16_t sclk, mclk; 740771fe6b9SJerome Glisse 741771fe6b9SJerome Glisse pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE); 742771fe6b9SJerome Glisse if (pll_info) { 743771fe6b9SJerome Glisse rev = RBIOS8(pll_info); 744771fe6b9SJerome Glisse 745771fe6b9SJerome Glisse /* pixel clocks */ 746771fe6b9SJerome Glisse p1pll->reference_freq = RBIOS16(pll_info + 0xe); 747771fe6b9SJerome Glisse p1pll->reference_div = RBIOS16(pll_info + 0x10); 748771fe6b9SJerome Glisse p1pll->pll_out_min = RBIOS32(pll_info + 0x12); 749771fe6b9SJerome Glisse p1pll->pll_out_max = RBIOS32(pll_info + 0x16); 75086cb2bbfSAlex Deucher p1pll->lcd_pll_out_min = p1pll->pll_out_min; 75186cb2bbfSAlex Deucher p1pll->lcd_pll_out_max = p1pll->pll_out_max; 752771fe6b9SJerome Glisse 753771fe6b9SJerome Glisse if (rev > 9) { 754771fe6b9SJerome Glisse p1pll->pll_in_min = RBIOS32(pll_info + 0x36); 755771fe6b9SJerome Glisse p1pll->pll_in_max = RBIOS32(pll_info + 0x3a); 756771fe6b9SJerome Glisse } else { 757771fe6b9SJerome Glisse p1pll->pll_in_min = 40; 758771fe6b9SJerome Glisse p1pll->pll_in_max = 500; 759771fe6b9SJerome Glisse } 760771fe6b9SJerome Glisse *p2pll = *p1pll; 761771fe6b9SJerome Glisse 762771fe6b9SJerome Glisse /* system clock */ 763771fe6b9SJerome Glisse spll->reference_freq = RBIOS16(pll_info + 0x1a); 764771fe6b9SJerome Glisse spll->reference_div = RBIOS16(pll_info + 0x1c); 765771fe6b9SJerome Glisse spll->pll_out_min = RBIOS32(pll_info + 0x1e); 766771fe6b9SJerome Glisse spll->pll_out_max = RBIOS32(pll_info + 0x22); 767771fe6b9SJerome Glisse 768771fe6b9SJerome Glisse if (rev > 10) { 769771fe6b9SJerome Glisse spll->pll_in_min = RBIOS32(pll_info + 0x48); 770771fe6b9SJerome Glisse spll->pll_in_max = RBIOS32(pll_info + 0x4c); 771771fe6b9SJerome Glisse } else { 772771fe6b9SJerome Glisse /* ??? */ 773771fe6b9SJerome Glisse spll->pll_in_min = 40; 774771fe6b9SJerome Glisse spll->pll_in_max = 500; 775771fe6b9SJerome Glisse } 776771fe6b9SJerome Glisse 777771fe6b9SJerome Glisse /* memory clock */ 778771fe6b9SJerome Glisse mpll->reference_freq = RBIOS16(pll_info + 0x26); 779771fe6b9SJerome Glisse mpll->reference_div = RBIOS16(pll_info + 0x28); 780771fe6b9SJerome Glisse mpll->pll_out_min = RBIOS32(pll_info + 0x2a); 781771fe6b9SJerome Glisse mpll->pll_out_max = RBIOS32(pll_info + 0x2e); 782771fe6b9SJerome Glisse 783771fe6b9SJerome Glisse if (rev > 10) { 784771fe6b9SJerome Glisse mpll->pll_in_min = RBIOS32(pll_info + 0x5a); 785771fe6b9SJerome Glisse mpll->pll_in_max = RBIOS32(pll_info + 0x5e); 786771fe6b9SJerome Glisse } else { 787771fe6b9SJerome Glisse /* ??? */ 788771fe6b9SJerome Glisse mpll->pll_in_min = 40; 789771fe6b9SJerome Glisse mpll->pll_in_max = 500; 790771fe6b9SJerome Glisse } 791771fe6b9SJerome Glisse 792771fe6b9SJerome Glisse /* default sclk/mclk */ 793771fe6b9SJerome Glisse sclk = RBIOS16(pll_info + 0xa); 794771fe6b9SJerome Glisse mclk = RBIOS16(pll_info + 0x8); 795771fe6b9SJerome Glisse if (sclk == 0) 796771fe6b9SJerome Glisse sclk = 200 * 100; 797771fe6b9SJerome Glisse if (mclk == 0) 798771fe6b9SJerome Glisse mclk = 200 * 100; 799771fe6b9SJerome Glisse 800771fe6b9SJerome Glisse rdev->clock.default_sclk = sclk; 801771fe6b9SJerome Glisse rdev->clock.default_mclk = mclk; 802771fe6b9SJerome Glisse 803b20f9befSAlex Deucher if (RBIOS32(pll_info + 0x16)) 804b20f9befSAlex Deucher rdev->clock.max_pixel_clock = RBIOS32(pll_info + 0x16); 805b20f9befSAlex Deucher else 806b20f9befSAlex Deucher rdev->clock.max_pixel_clock = 35000; /* might need something asic specific */ 807b20f9befSAlex Deucher 808771fe6b9SJerome Glisse return true; 809771fe6b9SJerome Glisse } 810771fe6b9SJerome Glisse return false; 811771fe6b9SJerome Glisse } 812771fe6b9SJerome Glisse 81306b6476dSAlex Deucher bool radeon_combios_sideport_present(struct radeon_device *rdev) 81406b6476dSAlex Deucher { 81506b6476dSAlex Deucher struct drm_device *dev = rdev->ddev; 81606b6476dSAlex Deucher u16 igp_info; 81706b6476dSAlex Deucher 8184c70b2eaSAlex Deucher /* sideport is AMD only */ 8194c70b2eaSAlex Deucher if (rdev->family == CHIP_RS400) 8204c70b2eaSAlex Deucher return false; 8214c70b2eaSAlex Deucher 82206b6476dSAlex Deucher igp_info = combios_get_table_offset(dev, COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE); 82306b6476dSAlex Deucher 82406b6476dSAlex Deucher if (igp_info) { 82506b6476dSAlex Deucher if (RBIOS16(igp_info + 0x4)) 82606b6476dSAlex Deucher return true; 82706b6476dSAlex Deucher } 82806b6476dSAlex Deucher return false; 82906b6476dSAlex Deucher } 83006b6476dSAlex Deucher 831246263ccSAlex Deucher static const uint32_t default_primarydac_adj[CHIP_LAST] = { 832246263ccSAlex Deucher 0x00000808, /* r100 */ 833246263ccSAlex Deucher 0x00000808, /* rv100 */ 834246263ccSAlex Deucher 0x00000808, /* rs100 */ 835246263ccSAlex Deucher 0x00000808, /* rv200 */ 836246263ccSAlex Deucher 0x00000808, /* rs200 */ 837246263ccSAlex Deucher 0x00000808, /* r200 */ 838246263ccSAlex Deucher 0x00000808, /* rv250 */ 839246263ccSAlex Deucher 0x00000000, /* rs300 */ 840246263ccSAlex Deucher 0x00000808, /* rv280 */ 841246263ccSAlex Deucher 0x00000808, /* r300 */ 842246263ccSAlex Deucher 0x00000808, /* r350 */ 843246263ccSAlex Deucher 0x00000808, /* rv350 */ 844246263ccSAlex Deucher 0x00000808, /* rv380 */ 845246263ccSAlex Deucher 0x00000808, /* r420 */ 846246263ccSAlex Deucher 0x00000808, /* r423 */ 847246263ccSAlex Deucher 0x00000808, /* rv410 */ 848246263ccSAlex Deucher 0x00000000, /* rs400 */ 849246263ccSAlex Deucher 0x00000000, /* rs480 */ 850246263ccSAlex Deucher }; 851246263ccSAlex Deucher 852246263ccSAlex Deucher static void radeon_legacy_get_primary_dac_info_from_table(struct radeon_device *rdev, 853246263ccSAlex Deucher struct radeon_encoder_primary_dac *p_dac) 854246263ccSAlex Deucher { 855246263ccSAlex Deucher p_dac->ps2_pdac_adj = default_primarydac_adj[rdev->family]; 856246263ccSAlex Deucher return; 857246263ccSAlex Deucher } 858246263ccSAlex Deucher 859771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct 860771fe6b9SJerome Glisse radeon_encoder 861771fe6b9SJerome Glisse *encoder) 862771fe6b9SJerome Glisse { 863771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 864771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 865771fe6b9SJerome Glisse uint16_t dac_info; 866771fe6b9SJerome Glisse uint8_t rev, bg, dac; 867771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *p_dac = NULL; 868246263ccSAlex Deucher int found = 0; 869771fe6b9SJerome Glisse 870246263ccSAlex Deucher p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), 871771fe6b9SJerome Glisse GFP_KERNEL); 872771fe6b9SJerome Glisse 873771fe6b9SJerome Glisse if (!p_dac) 874771fe6b9SJerome Glisse return NULL; 875771fe6b9SJerome Glisse 876246263ccSAlex Deucher /* check CRT table */ 877246263ccSAlex Deucher dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 878246263ccSAlex Deucher if (dac_info) { 879771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 880771fe6b9SJerome Glisse if (rev < 2) { 881771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 882771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf; 883771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 884771fe6b9SJerome Glisse } else { 885771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 886771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x3) & 0xf; 887771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 888771fe6b9SJerome Glisse } 88903ed8cf9SAlex Deucher /* if the values are zeros, use the table */ 89003ed8cf9SAlex Deucher if ((dac == 0) || (bg == 0)) 89103ed8cf9SAlex Deucher found = 0; 89203ed8cf9SAlex Deucher else 893246263ccSAlex Deucher found = 1; 894771fe6b9SJerome Glisse } 895771fe6b9SJerome Glisse 896e8fc4137SAlex Deucher /* quirks */ 897f7929f34SOndrej Zary /* Radeon 7000 (RV100) */ 898f7929f34SOndrej Zary if (((dev->pdev->device == 0x5159) && 899e8fc4137SAlex Deucher (dev->pdev->subsystem_vendor == 0x174B) && 900f7929f34SOndrej Zary (dev->pdev->subsystem_device == 0x7c28)) || 901f7929f34SOndrej Zary /* Radeon 9100 (R200) */ 902f7929f34SOndrej Zary ((dev->pdev->device == 0x514D) && 903f7929f34SOndrej Zary (dev->pdev->subsystem_vendor == 0x174B) && 904f7929f34SOndrej Zary (dev->pdev->subsystem_device == 0x7149))) { 905e8fc4137SAlex Deucher /* vbios value is bad, use the default */ 906e8fc4137SAlex Deucher found = 0; 907e8fc4137SAlex Deucher } 908e8fc4137SAlex Deucher 909246263ccSAlex Deucher if (!found) /* fallback to defaults */ 910246263ccSAlex Deucher radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac); 911246263ccSAlex Deucher 912771fe6b9SJerome Glisse return p_dac; 913771fe6b9SJerome Glisse } 914771fe6b9SJerome Glisse 915d79766faSAlex Deucher enum radeon_tv_std 916d79766faSAlex Deucher radeon_combios_get_tv_info(struct radeon_device *rdev) 917771fe6b9SJerome Glisse { 918d79766faSAlex Deucher struct drm_device *dev = rdev->ddev; 919771fe6b9SJerome Glisse uint16_t tv_info; 920771fe6b9SJerome Glisse enum radeon_tv_std tv_std = TV_STD_NTSC; 921771fe6b9SJerome Glisse 922771fe6b9SJerome Glisse tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 923771fe6b9SJerome Glisse if (tv_info) { 924771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 925771fe6b9SJerome Glisse switch (RBIOS8(tv_info + 7) & 0xf) { 926771fe6b9SJerome Glisse case 1: 927771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 92840f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: NTSC\n"); 929771fe6b9SJerome Glisse break; 930771fe6b9SJerome Glisse case 2: 931771fe6b9SJerome Glisse tv_std = TV_STD_PAL; 93240f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL\n"); 933771fe6b9SJerome Glisse break; 934771fe6b9SJerome Glisse case 3: 935771fe6b9SJerome Glisse tv_std = TV_STD_PAL_M; 93640f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL-M\n"); 937771fe6b9SJerome Glisse break; 938771fe6b9SJerome Glisse case 4: 939771fe6b9SJerome Glisse tv_std = TV_STD_PAL_60; 94040f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL-60\n"); 941771fe6b9SJerome Glisse break; 942771fe6b9SJerome Glisse case 5: 943771fe6b9SJerome Glisse tv_std = TV_STD_NTSC_J; 94440f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: NTSC-J\n"); 945771fe6b9SJerome Glisse break; 946771fe6b9SJerome Glisse case 6: 947771fe6b9SJerome Glisse tv_std = TV_STD_SCART_PAL; 94840f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: SCART-PAL\n"); 949771fe6b9SJerome Glisse break; 950771fe6b9SJerome Glisse default: 951771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 95240f76d81SAlex Deucher DRM_DEBUG_KMS 953771fe6b9SJerome Glisse ("Unknown TV standard; defaulting to NTSC\n"); 954771fe6b9SJerome Glisse break; 955771fe6b9SJerome Glisse } 956771fe6b9SJerome Glisse 957771fe6b9SJerome Glisse switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) { 958771fe6b9SJerome Glisse case 0: 95940f76d81SAlex Deucher DRM_DEBUG_KMS("29.498928713 MHz TV ref clk\n"); 960771fe6b9SJerome Glisse break; 961771fe6b9SJerome Glisse case 1: 96240f76d81SAlex Deucher DRM_DEBUG_KMS("28.636360000 MHz TV ref clk\n"); 963771fe6b9SJerome Glisse break; 964771fe6b9SJerome Glisse case 2: 96540f76d81SAlex Deucher DRM_DEBUG_KMS("14.318180000 MHz TV ref clk\n"); 966771fe6b9SJerome Glisse break; 967771fe6b9SJerome Glisse case 3: 96840f76d81SAlex Deucher DRM_DEBUG_KMS("27.000000000 MHz TV ref clk\n"); 969771fe6b9SJerome Glisse break; 970771fe6b9SJerome Glisse default: 971771fe6b9SJerome Glisse break; 972771fe6b9SJerome Glisse } 973771fe6b9SJerome Glisse } 974771fe6b9SJerome Glisse } 975771fe6b9SJerome Glisse return tv_std; 976771fe6b9SJerome Glisse } 977771fe6b9SJerome Glisse 978771fe6b9SJerome Glisse static const uint32_t default_tvdac_adj[CHIP_LAST] = { 979771fe6b9SJerome Glisse 0x00000000, /* r100 */ 980771fe6b9SJerome Glisse 0x00280000, /* rv100 */ 981771fe6b9SJerome Glisse 0x00000000, /* rs100 */ 982771fe6b9SJerome Glisse 0x00880000, /* rv200 */ 983771fe6b9SJerome Glisse 0x00000000, /* rs200 */ 984771fe6b9SJerome Glisse 0x00000000, /* r200 */ 985771fe6b9SJerome Glisse 0x00770000, /* rv250 */ 986771fe6b9SJerome Glisse 0x00290000, /* rs300 */ 987771fe6b9SJerome Glisse 0x00560000, /* rv280 */ 988771fe6b9SJerome Glisse 0x00780000, /* r300 */ 989771fe6b9SJerome Glisse 0x00770000, /* r350 */ 990771fe6b9SJerome Glisse 0x00780000, /* rv350 */ 991771fe6b9SJerome Glisse 0x00780000, /* rv380 */ 992771fe6b9SJerome Glisse 0x01080000, /* r420 */ 993771fe6b9SJerome Glisse 0x01080000, /* r423 */ 994771fe6b9SJerome Glisse 0x01080000, /* rv410 */ 995771fe6b9SJerome Glisse 0x00780000, /* rs400 */ 996771fe6b9SJerome Glisse 0x00780000, /* rs480 */ 997771fe6b9SJerome Glisse }; 998771fe6b9SJerome Glisse 9996a719e05SDave Airlie static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev, 10006a719e05SDave Airlie struct radeon_encoder_tv_dac *tv_dac) 1001771fe6b9SJerome Glisse { 1002771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; 1003771fe6b9SJerome Glisse if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) 1004771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 0x00880000; 1005771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1006771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10076a719e05SDave Airlie return; 1008771fe6b9SJerome Glisse } 1009771fe6b9SJerome Glisse 1010771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct 1011771fe6b9SJerome Glisse radeon_encoder 1012771fe6b9SJerome Glisse *encoder) 1013771fe6b9SJerome Glisse { 1014771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1015771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1016771fe6b9SJerome Glisse uint16_t dac_info; 1017771fe6b9SJerome Glisse uint8_t rev, bg, dac; 1018771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *tv_dac = NULL; 10196a719e05SDave Airlie int found = 0; 10206a719e05SDave Airlie 10216a719e05SDave Airlie tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); 10226a719e05SDave Airlie if (!tv_dac) 10236a719e05SDave Airlie return NULL; 1024771fe6b9SJerome Glisse 1025771fe6b9SJerome Glisse /* first check TV table */ 1026771fe6b9SJerome Glisse dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 1027771fe6b9SJerome Glisse if (dac_info) { 1028771fe6b9SJerome Glisse rev = RBIOS8(dac_info + 0x3); 1029771fe6b9SJerome Glisse if (rev > 4) { 1030771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 1031771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xd) & 0xf; 1032771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 1033771fe6b9SJerome Glisse 1034771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 1035771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xf) & 0xf; 1036771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 1037771fe6b9SJerome Glisse 1038771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x10) & 0xf; 1039771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x11) & 0xf; 1040771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 10413a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10423a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10436a719e05SDave Airlie found = 1; 1044771fe6b9SJerome Glisse } else if (rev > 1) { 1045771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 1046771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; 1047771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 1048771fe6b9SJerome Glisse 1049771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xd) & 0xf; 1050771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf; 1051771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 1052771fe6b9SJerome Glisse 1053771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 1054771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; 1055771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 10563a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10573a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10586a719e05SDave Airlie found = 1; 1059771fe6b9SJerome Glisse } 1060d79766faSAlex Deucher tv_dac->tv_std = radeon_combios_get_tv_info(rdev); 10616a719e05SDave Airlie } 10626a719e05SDave Airlie if (!found) { 1063771fe6b9SJerome Glisse /* then check CRT table */ 1064771fe6b9SJerome Glisse dac_info = 1065771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 1066771fe6b9SJerome Glisse if (dac_info) { 1067771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 1068771fe6b9SJerome Glisse if (rev < 2) { 1069771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x3) & 0xf; 1070771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf; 1071771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 1072771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 1073771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1074771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10753a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10763a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10776a719e05SDave Airlie found = 1; 1078771fe6b9SJerome Glisse } else { 1079771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x4) & 0xf; 1080771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x5) & 0xf; 1081771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 1082771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 1083771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1084771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10853a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10863a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10876a719e05SDave Airlie found = 1; 1088771fe6b9SJerome Glisse } 10896fe7ac3fSAlex Deucher } else { 10906fe7ac3fSAlex Deucher DRM_INFO("No TV DAC info found in BIOS\n"); 1091771fe6b9SJerome Glisse } 1092771fe6b9SJerome Glisse } 1093771fe6b9SJerome Glisse 10946a719e05SDave Airlie if (!found) /* fallback to defaults */ 10956a719e05SDave Airlie radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac); 10966a719e05SDave Airlie 1097771fe6b9SJerome Glisse return tv_dac; 1098771fe6b9SJerome Glisse } 1099771fe6b9SJerome Glisse 1100771fe6b9SJerome Glisse static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct 1101771fe6b9SJerome Glisse radeon_device 1102771fe6b9SJerome Glisse *rdev) 1103771fe6b9SJerome Glisse { 1104771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 1105771fe6b9SJerome Glisse uint32_t fp_vert_stretch, fp_horz_stretch; 1106771fe6b9SJerome Glisse uint32_t ppll_div_sel, ppll_val; 11078b5c7444SMichel Dänzer uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL); 1108771fe6b9SJerome Glisse 1109771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 1110771fe6b9SJerome Glisse 1111771fe6b9SJerome Glisse if (!lvds) 1112771fe6b9SJerome Glisse return NULL; 1113771fe6b9SJerome Glisse 1114771fe6b9SJerome Glisse fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH); 1115771fe6b9SJerome Glisse fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH); 1116771fe6b9SJerome Glisse 11178b5c7444SMichel Dänzer /* These should be fail-safe defaults, fingers crossed */ 11188b5c7444SMichel Dänzer lvds->panel_pwr_delay = 200; 11198b5c7444SMichel Dänzer lvds->panel_vcc_delay = 2000; 11208b5c7444SMichel Dänzer 11218b5c7444SMichel Dänzer lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL); 11228b5c7444SMichel Dänzer lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf; 11238b5c7444SMichel Dänzer lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf; 11248b5c7444SMichel Dänzer 1125771fe6b9SJerome Glisse if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE) 1126de2103e4SAlex Deucher lvds->native_mode.vdisplay = 1127771fe6b9SJerome Glisse ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >> 1128771fe6b9SJerome Glisse RADEON_VERT_PANEL_SHIFT) + 1; 1129771fe6b9SJerome Glisse else 1130de2103e4SAlex Deucher lvds->native_mode.vdisplay = 1131771fe6b9SJerome Glisse (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1; 1132771fe6b9SJerome Glisse 1133771fe6b9SJerome Glisse if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE) 1134de2103e4SAlex Deucher lvds->native_mode.hdisplay = 1135771fe6b9SJerome Glisse (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >> 1136771fe6b9SJerome Glisse RADEON_HORZ_PANEL_SHIFT) + 1) * 8; 1137771fe6b9SJerome Glisse else 1138de2103e4SAlex Deucher lvds->native_mode.hdisplay = 1139771fe6b9SJerome Glisse ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8; 1140771fe6b9SJerome Glisse 1141de2103e4SAlex Deucher if ((lvds->native_mode.hdisplay < 640) || 1142de2103e4SAlex Deucher (lvds->native_mode.vdisplay < 480)) { 1143de2103e4SAlex Deucher lvds->native_mode.hdisplay = 640; 1144de2103e4SAlex Deucher lvds->native_mode.vdisplay = 480; 1145771fe6b9SJerome Glisse } 1146771fe6b9SJerome Glisse 1147771fe6b9SJerome Glisse ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3; 1148771fe6b9SJerome Glisse ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel); 1149771fe6b9SJerome Glisse if ((ppll_val & 0x000707ff) == 0x1bb) 1150771fe6b9SJerome Glisse lvds->use_bios_dividers = false; 1151771fe6b9SJerome Glisse else { 1152771fe6b9SJerome Glisse lvds->panel_ref_divider = 1153771fe6b9SJerome Glisse RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff; 1154771fe6b9SJerome Glisse lvds->panel_post_divider = (ppll_val >> 16) & 0x7; 1155771fe6b9SJerome Glisse lvds->panel_fb_divider = ppll_val & 0x7ff; 1156771fe6b9SJerome Glisse 1157771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1158771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1159771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1160771fe6b9SJerome Glisse } 1161771fe6b9SJerome Glisse lvds->panel_vcc_delay = 200; 1162771fe6b9SJerome Glisse 1163771fe6b9SJerome Glisse DRM_INFO("Panel info derived from registers\n"); 1164de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1165de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1166771fe6b9SJerome Glisse 1167771fe6b9SJerome Glisse return lvds; 1168771fe6b9SJerome Glisse } 1169771fe6b9SJerome Glisse 1170771fe6b9SJerome Glisse struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder 1171771fe6b9SJerome Glisse *encoder) 1172771fe6b9SJerome Glisse { 1173771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1174771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1175771fe6b9SJerome Glisse uint16_t lcd_info; 1176771fe6b9SJerome Glisse uint32_t panel_setup; 1177771fe6b9SJerome Glisse char stmp[30]; 1178771fe6b9SJerome Glisse int tmp, i; 1179771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 1180771fe6b9SJerome Glisse 1181771fe6b9SJerome Glisse lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 1182771fe6b9SJerome Glisse 1183771fe6b9SJerome Glisse if (lcd_info) { 1184771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 1185771fe6b9SJerome Glisse 1186771fe6b9SJerome Glisse if (!lvds) 1187771fe6b9SJerome Glisse return NULL; 1188771fe6b9SJerome Glisse 1189771fe6b9SJerome Glisse for (i = 0; i < 24; i++) 1190771fe6b9SJerome Glisse stmp[i] = RBIOS8(lcd_info + i + 1); 1191771fe6b9SJerome Glisse stmp[24] = 0; 1192771fe6b9SJerome Glisse 1193771fe6b9SJerome Glisse DRM_INFO("Panel ID String: %s\n", stmp); 1194771fe6b9SJerome Glisse 1195de2103e4SAlex Deucher lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19); 1196de2103e4SAlex Deucher lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b); 1197771fe6b9SJerome Glisse 1198de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1199de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1200771fe6b9SJerome Glisse 1201771fe6b9SJerome Glisse lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c); 120294cf6434SAndrew Morton lvds->panel_vcc_delay = min_t(u16, lvds->panel_vcc_delay, 2000); 1203771fe6b9SJerome Glisse 1204771fe6b9SJerome Glisse lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24); 1205771fe6b9SJerome Glisse lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf; 1206771fe6b9SJerome Glisse lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf; 1207771fe6b9SJerome Glisse 1208771fe6b9SJerome Glisse lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e); 1209771fe6b9SJerome Glisse lvds->panel_post_divider = RBIOS8(lcd_info + 0x30); 1210771fe6b9SJerome Glisse lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31); 1211771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1212771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1213771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1214771fe6b9SJerome Glisse 1215771fe6b9SJerome Glisse panel_setup = RBIOS32(lcd_info + 0x39); 1216771fe6b9SJerome Glisse lvds->lvds_gen_cntl = 0xff00; 1217771fe6b9SJerome Glisse if (panel_setup & 0x1) 1218771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT; 1219771fe6b9SJerome Glisse 1220771fe6b9SJerome Glisse if ((panel_setup >> 4) & 0x1) 1221771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE; 1222771fe6b9SJerome Glisse 1223771fe6b9SJerome Glisse switch ((panel_setup >> 8) & 0x7) { 1224771fe6b9SJerome Glisse case 0: 1225771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM; 1226771fe6b9SJerome Glisse break; 1227771fe6b9SJerome Glisse case 1: 1228771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY; 1229771fe6b9SJerome Glisse break; 1230771fe6b9SJerome Glisse case 2: 1231771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY; 1232771fe6b9SJerome Glisse break; 1233771fe6b9SJerome Glisse default: 1234771fe6b9SJerome Glisse break; 1235771fe6b9SJerome Glisse } 1236771fe6b9SJerome Glisse 1237771fe6b9SJerome Glisse if ((panel_setup >> 16) & 0x1) 1238771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW; 1239771fe6b9SJerome Glisse 1240771fe6b9SJerome Glisse if ((panel_setup >> 17) & 0x1) 1241771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW; 1242771fe6b9SJerome Glisse 1243771fe6b9SJerome Glisse if ((panel_setup >> 18) & 0x1) 1244771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW; 1245771fe6b9SJerome Glisse 1246771fe6b9SJerome Glisse if ((panel_setup >> 23) & 0x1) 1247771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL; 1248771fe6b9SJerome Glisse 1249771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000); 1250771fe6b9SJerome Glisse 1251771fe6b9SJerome Glisse for (i = 0; i < 32; i++) { 1252771fe6b9SJerome Glisse tmp = RBIOS16(lcd_info + 64 + i * 2); 1253771fe6b9SJerome Glisse if (tmp == 0) 1254771fe6b9SJerome Glisse break; 1255771fe6b9SJerome Glisse 1256de2103e4SAlex Deucher if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) && 125768b61a7fSAlex Deucher (RBIOS16(tmp + 2) == lvds->native_mode.vdisplay)) { 1258*0a90a0cfSAlex Deucher u32 hss = (RBIOS16(tmp + 21) - RBIOS16(tmp + 19) - 1) * 8; 1259*0a90a0cfSAlex Deucher 1260*0a90a0cfSAlex Deucher if (hss > lvds->native_mode.hdisplay) 1261*0a90a0cfSAlex Deucher hss = (10 - 1) * 8; 1262*0a90a0cfSAlex Deucher 126368b61a7fSAlex Deucher lvds->native_mode.htotal = lvds->native_mode.hdisplay + 126468b61a7fSAlex Deucher (RBIOS16(tmp + 17) - RBIOS16(tmp + 19)) * 8; 126568b61a7fSAlex Deucher lvds->native_mode.hsync_start = lvds->native_mode.hdisplay + 1266*0a90a0cfSAlex Deucher hss; 126768b61a7fSAlex Deucher lvds->native_mode.hsync_end = lvds->native_mode.hsync_start + 126868b61a7fSAlex Deucher (RBIOS8(tmp + 23) * 8); 1269771fe6b9SJerome Glisse 127068b61a7fSAlex Deucher lvds->native_mode.vtotal = lvds->native_mode.vdisplay + 127168b61a7fSAlex Deucher (RBIOS16(tmp + 24) - RBIOS16(tmp + 26)); 127268b61a7fSAlex Deucher lvds->native_mode.vsync_start = lvds->native_mode.vdisplay + 127368b61a7fSAlex Deucher ((RBIOS16(tmp + 28) & 0x7ff) - RBIOS16(tmp + 26)); 127468b61a7fSAlex Deucher lvds->native_mode.vsync_end = lvds->native_mode.vsync_start + 127568b61a7fSAlex Deucher ((RBIOS16(tmp + 28) & 0xf800) >> 11); 1276de2103e4SAlex Deucher 1277de2103e4SAlex Deucher lvds->native_mode.clock = RBIOS16(tmp + 9) * 10; 1278771fe6b9SJerome Glisse lvds->native_mode.flags = 0; 1279de2103e4SAlex Deucher /* set crtc values */ 1280de2103e4SAlex Deucher drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V); 1281de2103e4SAlex Deucher 1282771fe6b9SJerome Glisse } 1283771fe6b9SJerome Glisse } 12846fe7ac3fSAlex Deucher } else { 1285771fe6b9SJerome Glisse DRM_INFO("No panel info found in BIOS\n"); 12868dfaa8a7SMichel Dänzer lvds = radeon_legacy_get_lvds_info_from_regs(rdev); 12876fe7ac3fSAlex Deucher } 128803047cdfSMichel Dänzer 12898dfaa8a7SMichel Dänzer if (lvds) 12908dfaa8a7SMichel Dänzer encoder->native_mode = lvds->native_mode; 1291771fe6b9SJerome Glisse return lvds; 1292771fe6b9SJerome Glisse } 1293771fe6b9SJerome Glisse 1294771fe6b9SJerome Glisse static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = { 1295771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */ 1296771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */ 1297771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */ 1298771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */ 1299771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */ 1300771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */ 1301771fe6b9SJerome Glisse {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */ 1302771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */ 1303771fe6b9SJerome Glisse {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */ 1304771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */ 1305771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */ 1306771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */ 1307771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */ 1308771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */ 1309771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */ 1310771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */ 1311fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */ 1312fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */ 1313771fe6b9SJerome Glisse }; 1314771fe6b9SJerome Glisse 1315445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder, 1316445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1317771fe6b9SJerome Glisse { 1318445282dbSDave Airlie struct drm_device *dev = encoder->base.dev; 1319445282dbSDave Airlie struct radeon_device *rdev = dev->dev_private; 1320771fe6b9SJerome Glisse int i; 1321771fe6b9SJerome Glisse 1322771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 1323771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1324771fe6b9SJerome Glisse default_tmds_pll[rdev->family][i].value; 1325771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq; 1326771fe6b9SJerome Glisse } 1327771fe6b9SJerome Glisse 1328445282dbSDave Airlie return true; 1329771fe6b9SJerome Glisse } 1330771fe6b9SJerome Glisse 1331445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder, 1332445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1333771fe6b9SJerome Glisse { 1334771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1335771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1336771fe6b9SJerome Glisse uint16_t tmds_info; 1337771fe6b9SJerome Glisse int i, n; 1338771fe6b9SJerome Glisse uint8_t ver; 1339771fe6b9SJerome Glisse 1340771fe6b9SJerome Glisse tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 1341771fe6b9SJerome Glisse 1342771fe6b9SJerome Glisse if (tmds_info) { 1343771fe6b9SJerome Glisse ver = RBIOS8(tmds_info); 134440f76d81SAlex Deucher DRM_DEBUG_KMS("DFP table revision: %d\n", ver); 1345771fe6b9SJerome Glisse if (ver == 3) { 1346771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1347771fe6b9SJerome Glisse if (n > 4) 1348771fe6b9SJerome Glisse n = 4; 1349771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1350771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1351771fe6b9SJerome Glisse RBIOS32(tmds_info + i * 10 + 0x08); 1352771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1353771fe6b9SJerome Glisse RBIOS16(tmds_info + i * 10 + 0x10); 1354d9fdaafbSDave Airlie DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", 1355771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1356771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1357771fe6b9SJerome Glisse } 1358771fe6b9SJerome Glisse } else if (ver == 4) { 1359771fe6b9SJerome Glisse int stride = 0; 1360771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1361771fe6b9SJerome Glisse if (n > 4) 1362771fe6b9SJerome Glisse n = 4; 1363771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1364771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1365771fe6b9SJerome Glisse RBIOS32(tmds_info + stride + 0x08); 1366771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1367771fe6b9SJerome Glisse RBIOS16(tmds_info + stride + 0x10); 1368771fe6b9SJerome Glisse if (i == 0) 1369771fe6b9SJerome Glisse stride += 10; 1370771fe6b9SJerome Glisse else 1371771fe6b9SJerome Glisse stride += 6; 1372d9fdaafbSDave Airlie DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", 1373771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1374771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1375771fe6b9SJerome Glisse } 1376771fe6b9SJerome Glisse } 1377fcec570bSAlex Deucher } else { 1378771fe6b9SJerome Glisse DRM_INFO("No TMDS info found in BIOS\n"); 1379fcec570bSAlex Deucher return false; 1380fcec570bSAlex Deucher } 1381445282dbSDave Airlie return true; 1382445282dbSDave Airlie } 1383445282dbSDave Airlie 1384fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder, 1385fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1386771fe6b9SJerome Glisse { 1387771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1388771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1389fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1390fcec570bSAlex Deucher 1391fcec570bSAlex Deucher /* default for macs */ 1392179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1393f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1394fcec570bSAlex Deucher 1395fcec570bSAlex Deucher /* XXX some macs have duallink chips */ 1396fcec570bSAlex Deucher switch (rdev->mode_info.connector_table) { 1397fcec570bSAlex Deucher case CT_POWERBOOK_EXTERNAL: 1398fcec570bSAlex Deucher case CT_MINI_EXTERNAL: 1399fcec570bSAlex Deucher default: 1400fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1401fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1402fcec570bSAlex Deucher break; 1403fcec570bSAlex Deucher } 1404fcec570bSAlex Deucher 1405fcec570bSAlex Deucher return true; 1406fcec570bSAlex Deucher } 1407fcec570bSAlex Deucher 1408fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder, 1409fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1410fcec570bSAlex Deucher { 1411fcec570bSAlex Deucher struct drm_device *dev = encoder->base.dev; 1412fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 1413fcec570bSAlex Deucher uint16_t offset; 1414179e8078SAlex Deucher uint8_t ver; 1415fcec570bSAlex Deucher enum radeon_combios_ddc gpio; 1416fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1417771fe6b9SJerome Glisse 1418fcec570bSAlex Deucher tmds->i2c_bus = NULL; 1419fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 1420179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1421f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1422fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1423fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1424fcec570bSAlex Deucher } else { 1425fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 1426fcec570bSAlex Deucher if (offset) { 1427fcec570bSAlex Deucher ver = RBIOS8(offset); 142840f76d81SAlex Deucher DRM_DEBUG_KMS("External TMDS Table revision: %d\n", ver); 1429fcec570bSAlex Deucher tmds->slave_addr = RBIOS8(offset + 4 + 2); 1430fcec570bSAlex Deucher tmds->slave_addr >>= 1; /* 7 bit addressing */ 1431fcec570bSAlex Deucher gpio = RBIOS8(offset + 4 + 3); 1432179e8078SAlex Deucher if (gpio == DDC_LCD) { 1433179e8078SAlex Deucher /* MM i2c */ 143440bacf16SAlex Deucher i2c_bus.valid = true; 143540bacf16SAlex Deucher i2c_bus.hw_capable = true; 143640bacf16SAlex Deucher i2c_bus.mm_i2c = true; 1437179e8078SAlex Deucher i2c_bus.i2c_id = 0xa0; 1438179e8078SAlex Deucher } else 1439179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0); 1440f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1441fcec570bSAlex Deucher } 1442fcec570bSAlex Deucher } 1443fcec570bSAlex Deucher 1444fcec570bSAlex Deucher if (!tmds->i2c_bus) { 1445fcec570bSAlex Deucher DRM_INFO("No valid Ext TMDS info found in BIOS\n"); 1446fcec570bSAlex Deucher return false; 1447fcec570bSAlex Deucher } 1448fcec570bSAlex Deucher 1449fcec570bSAlex Deucher return true; 1450fcec570bSAlex Deucher } 1451771fe6b9SJerome Glisse 1452771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) 1453771fe6b9SJerome Glisse { 1454771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1455771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 1456eed45b30SAlex Deucher struct radeon_hpd hpd; 1457771fe6b9SJerome Glisse 1458771fe6b9SJerome Glisse rdev->mode_info.connector_table = radeon_connector_table; 1459771fe6b9SJerome Glisse if (rdev->mode_info.connector_table == CT_NONE) { 1460771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 146171a157e8SGrant Likely if (of_machine_is_compatible("PowerBook3,3")) { 1462771fe6b9SJerome Glisse /* powerbook with VGA */ 1463771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_VGA; 146471a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook3,4") || 146571a157e8SGrant Likely of_machine_is_compatible("PowerBook3,5")) { 1466771fe6b9SJerome Glisse /* powerbook with internal tmds */ 1467771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; 146871a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,1") || 146971a157e8SGrant Likely of_machine_is_compatible("PowerBook5,2") || 147071a157e8SGrant Likely of_machine_is_compatible("PowerBook5,3") || 147171a157e8SGrant Likely of_machine_is_compatible("PowerBook5,4") || 147271a157e8SGrant Likely of_machine_is_compatible("PowerBook5,5")) { 1473771fe6b9SJerome Glisse /* powerbook with external single link tmds (sil164) */ 1474771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 147571a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,6")) { 1476771fe6b9SJerome Glisse /* powerbook with external dual or single link tmds */ 1477771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 147871a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,7") || 147971a157e8SGrant Likely of_machine_is_compatible("PowerBook5,8") || 148071a157e8SGrant Likely of_machine_is_compatible("PowerBook5,9")) { 1481771fe6b9SJerome Glisse /* PowerBook6,2 ? */ 1482771fe6b9SJerome Glisse /* powerbook with external dual link tmds (sil1178?) */ 1483771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 148471a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook4,1") || 148571a157e8SGrant Likely of_machine_is_compatible("PowerBook4,2") || 148671a157e8SGrant Likely of_machine_is_compatible("PowerBook4,3") || 148771a157e8SGrant Likely of_machine_is_compatible("PowerBook6,3") || 148871a157e8SGrant Likely of_machine_is_compatible("PowerBook6,5") || 148971a157e8SGrant Likely of_machine_is_compatible("PowerBook6,7")) { 1490771fe6b9SJerome Glisse /* ibook */ 1491771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IBOOK; 1492cafa59b9SAlex Deucher } else if (of_machine_is_compatible("PowerMac3,5")) { 1493cafa59b9SAlex Deucher /* PowerMac G4 Silver radeon 7500 */ 1494cafa59b9SAlex Deucher rdev->mode_info.connector_table = CT_MAC_G4_SILVER; 149571a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac4,4")) { 1496771fe6b9SJerome Glisse /* emac */ 1497771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_EMAC; 149871a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac10,1")) { 1499771fe6b9SJerome Glisse /* mini with internal tmds */ 1500771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_INTERNAL; 150171a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac10,2")) { 1502771fe6b9SJerome Glisse /* mini with external tmds */ 1503771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_EXTERNAL; 150471a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac12,1")) { 1505771fe6b9SJerome Glisse /* PowerMac8,1 ? */ 1506771fe6b9SJerome Glisse /* imac g5 isight */ 1507771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; 1508aa74fbb4SAlex Deucher } else if ((rdev->pdev->device == 0x4a48) && 1509aa74fbb4SAlex Deucher (rdev->pdev->subsystem_vendor == 0x1002) && 1510aa74fbb4SAlex Deucher (rdev->pdev->subsystem_device == 0x4a48)) { 1511aa74fbb4SAlex Deucher /* Mac X800 */ 1512aa74fbb4SAlex Deucher rdev->mode_info.connector_table = CT_MAC_X800; 15137c88d2b8SAlex Deucher } else if ((of_machine_is_compatible("PowerMac7,2") || 15147c88d2b8SAlex Deucher of_machine_is_compatible("PowerMac7,3")) && 15157c88d2b8SAlex Deucher (rdev->pdev->device == 0x4150) && 15167c88d2b8SAlex Deucher (rdev->pdev->subsystem_vendor == 0x1002) && 15177c88d2b8SAlex Deucher (rdev->pdev->subsystem_device == 0x4150)) { 15187c88d2b8SAlex Deucher /* Mac G5 tower 9600 */ 15199fad321aSAlex Deucher rdev->mode_info.connector_table = CT_MAC_G5_9600; 15206a556039SAlex Deucher } else if ((rdev->pdev->device == 0x4c66) && 15216a556039SAlex Deucher (rdev->pdev->subsystem_vendor == 0x1002) && 15226a556039SAlex Deucher (rdev->pdev->subsystem_device == 0x4c66)) { 15236a556039SAlex Deucher /* SAM440ep RV250 embedded board */ 15246a556039SAlex Deucher rdev->mode_info.connector_table = CT_SAM440EP; 1525771fe6b9SJerome Glisse } else 1526771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 152776a7142aSDave Airlie #ifdef CONFIG_PPC64 152876a7142aSDave Airlie if (ASIC_IS_RN50(rdev)) 152976a7142aSDave Airlie rdev->mode_info.connector_table = CT_RN50_POWER; 153076a7142aSDave Airlie else 153176a7142aSDave Airlie #endif 1532771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_GENERIC; 1533771fe6b9SJerome Glisse } 1534771fe6b9SJerome Glisse 1535771fe6b9SJerome Glisse switch (rdev->mode_info.connector_table) { 1536771fe6b9SJerome Glisse case CT_GENERIC: 1537771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (generic)\n", 1538771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1539771fe6b9SJerome Glisse /* these are the most common settings */ 1540771fe6b9SJerome Glisse if (rdev->flags & RADEON_SINGLE_CRTC) { 1541771fe6b9SJerome Glisse /* VGA - primary dac */ 1542179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1543eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1544771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15455137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1546771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1547771fe6b9SJerome Glisse 1), 1548771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1549771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1550771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1551771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1552b75fad06SAlex Deucher &ddc_i2c, 1553eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1554eed45b30SAlex Deucher &hpd); 1555771fe6b9SJerome Glisse } else if (rdev->flags & RADEON_IS_MOBILITY) { 1556771fe6b9SJerome Glisse /* LVDS */ 1557179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_NONE_DETECTED, 0, 0); 1558eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1559771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15605137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1561771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1562771fe6b9SJerome Glisse 0), 1563771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1564771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1565771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1566771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 1567b75fad06SAlex Deucher &ddc_i2c, 1568eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1569eed45b30SAlex Deucher &hpd); 1570771fe6b9SJerome Glisse 1571771fe6b9SJerome Glisse /* VGA - primary dac */ 1572179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1573eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1574771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15755137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1576771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1577771fe6b9SJerome Glisse 1), 1578771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1579771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1580771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1581771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1582b75fad06SAlex Deucher &ddc_i2c, 1583eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1584eed45b30SAlex Deucher &hpd); 1585771fe6b9SJerome Glisse } else { 1586771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1587179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1588eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 1589771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15905137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1591771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1592771fe6b9SJerome Glisse 0), 1593771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1594771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15955137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1596771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1597771fe6b9SJerome Glisse 2), 1598771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1599771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1600771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1601771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1602771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 1603b75fad06SAlex Deucher &ddc_i2c, 1604eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1605eed45b30SAlex Deucher &hpd); 1606771fe6b9SJerome Glisse 1607771fe6b9SJerome Glisse /* VGA - primary dac */ 1608179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1609eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1610771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16115137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1612771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1613771fe6b9SJerome Glisse 1), 1614771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1615771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1616771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1617771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1618b75fad06SAlex Deucher &ddc_i2c, 1619eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1620eed45b30SAlex Deucher &hpd); 1621771fe6b9SJerome Glisse } 1622771fe6b9SJerome Glisse 1623771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 1624771fe6b9SJerome Glisse /* TV - tv dac */ 1625eed45b30SAlex Deucher ddc_i2c.valid = false; 1626eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1627771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16285137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1629771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1630771fe6b9SJerome Glisse 2), 1631771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1632771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, 1633771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1634771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1635b75fad06SAlex Deucher &ddc_i2c, 1636eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1637eed45b30SAlex Deucher &hpd); 1638771fe6b9SJerome Glisse } 1639771fe6b9SJerome Glisse break; 1640771fe6b9SJerome Glisse case CT_IBOOK: 1641771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (ibook)\n", 1642771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1643771fe6b9SJerome Glisse /* LVDS */ 1644179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1645eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1646771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16475137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1648771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1649771fe6b9SJerome Glisse 0), 1650771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1651771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1652b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1653eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1654eed45b30SAlex Deucher &hpd); 1655771fe6b9SJerome Glisse /* VGA - TV DAC */ 1656179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1657eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1658771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16595137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1660771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1661771fe6b9SJerome Glisse 2), 1662771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1663771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1664b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1665eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1666eed45b30SAlex Deucher &hpd); 1667771fe6b9SJerome Glisse /* TV - TV DAC */ 1668eed45b30SAlex Deucher ddc_i2c.valid = false; 1669eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1670771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16715137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1672771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1673771fe6b9SJerome Glisse 2), 1674771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1675771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1676771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1677b75fad06SAlex Deucher &ddc_i2c, 1678eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1679eed45b30SAlex Deucher &hpd); 1680771fe6b9SJerome Glisse break; 1681771fe6b9SJerome Glisse case CT_POWERBOOK_EXTERNAL: 1682771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook external tmds)\n", 1683771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1684771fe6b9SJerome Glisse /* LVDS */ 1685179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1686eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1687771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16885137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1689771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1690771fe6b9SJerome Glisse 0), 1691771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1692771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1693b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1694eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1695eed45b30SAlex Deucher &hpd); 1696771fe6b9SJerome Glisse /* DVI-I - primary dac, ext tmds */ 1697179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1698eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1699771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17005137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1701771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1702771fe6b9SJerome Glisse 0), 1703771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1704771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17055137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1706771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1707771fe6b9SJerome Glisse 1), 1708771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1709b75fad06SAlex Deucher /* XXX some are SL */ 1710771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1711771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1712771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1713b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1714eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 1715eed45b30SAlex Deucher &hpd); 1716771fe6b9SJerome Glisse /* TV - TV DAC */ 1717eed45b30SAlex Deucher ddc_i2c.valid = false; 1718eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1719771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17205137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1721771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1722771fe6b9SJerome Glisse 2), 1723771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1724771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1725771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1726b75fad06SAlex Deucher &ddc_i2c, 1727eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1728eed45b30SAlex Deucher &hpd); 1729771fe6b9SJerome Glisse break; 1730771fe6b9SJerome Glisse case CT_POWERBOOK_INTERNAL: 1731771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook internal tmds)\n", 1732771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1733771fe6b9SJerome Glisse /* LVDS */ 1734179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1735eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1736771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17375137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1738771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1739771fe6b9SJerome Glisse 0), 1740771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1741771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1742b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1743eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1744eed45b30SAlex Deucher &hpd); 1745771fe6b9SJerome Glisse /* DVI-I - primary dac, int tmds */ 1746179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1747eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1748771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17495137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1750771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1751771fe6b9SJerome Glisse 0), 1752771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1753771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17545137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1755771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1756771fe6b9SJerome Glisse 1), 1757771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1758771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1759771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1760771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1761b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1762eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1763eed45b30SAlex Deucher &hpd); 1764771fe6b9SJerome Glisse /* TV - TV DAC */ 1765eed45b30SAlex Deucher ddc_i2c.valid = false; 1766eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1767771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17685137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1769771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1770771fe6b9SJerome Glisse 2), 1771771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1772771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1773771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1774b75fad06SAlex Deucher &ddc_i2c, 1775eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1776eed45b30SAlex Deucher &hpd); 1777771fe6b9SJerome Glisse break; 1778771fe6b9SJerome Glisse case CT_POWERBOOK_VGA: 1779771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook vga)\n", 1780771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1781771fe6b9SJerome Glisse /* LVDS */ 1782179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1783eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1784771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17855137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1786771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1787771fe6b9SJerome Glisse 0), 1788771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1789771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1790b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1791eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1792eed45b30SAlex Deucher &hpd); 1793771fe6b9SJerome Glisse /* VGA - primary dac */ 1794179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1795eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1796771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17975137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1798771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1799771fe6b9SJerome Glisse 1), 1800771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1801771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT, 1802b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1803eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1804eed45b30SAlex Deucher &hpd); 1805771fe6b9SJerome Glisse /* TV - TV DAC */ 1806eed45b30SAlex Deucher ddc_i2c.valid = false; 1807eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1808771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18095137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1810771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1811771fe6b9SJerome Glisse 2), 1812771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1813771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1814771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1815b75fad06SAlex Deucher &ddc_i2c, 1816eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1817eed45b30SAlex Deucher &hpd); 1818771fe6b9SJerome Glisse break; 1819771fe6b9SJerome Glisse case CT_MINI_EXTERNAL: 1820771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini external tmds)\n", 1821771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1822771fe6b9SJerome Glisse /* DVI-I - tv dac, ext tmds */ 1823179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1824eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1825771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18265137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1827771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1828771fe6b9SJerome Glisse 0), 1829771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1830771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18315137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1832771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1833771fe6b9SJerome Glisse 2), 1834771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1835b75fad06SAlex Deucher /* XXX are any DL? */ 1836771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1837771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1838771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1839b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1840eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1841eed45b30SAlex Deucher &hpd); 1842771fe6b9SJerome Glisse /* TV - TV DAC */ 1843eed45b30SAlex Deucher ddc_i2c.valid = false; 1844eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1845771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18465137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1847771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1848771fe6b9SJerome Glisse 2), 1849771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1850771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1851771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1852b75fad06SAlex Deucher &ddc_i2c, 1853eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1854eed45b30SAlex Deucher &hpd); 1855771fe6b9SJerome Glisse break; 1856771fe6b9SJerome Glisse case CT_MINI_INTERNAL: 1857771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini internal tmds)\n", 1858771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1859771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1860179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1861eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1862771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18635137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1864771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1865771fe6b9SJerome Glisse 0), 1866771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1867771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18685137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1869771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1870771fe6b9SJerome Glisse 2), 1871771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1872771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1873771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1874771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1875b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1876eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1877eed45b30SAlex Deucher &hpd); 1878771fe6b9SJerome Glisse /* TV - TV DAC */ 1879eed45b30SAlex Deucher ddc_i2c.valid = false; 1880eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1881771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18825137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1883771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1884771fe6b9SJerome Glisse 2), 1885771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1886771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1887771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1888b75fad06SAlex Deucher &ddc_i2c, 1889eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1890eed45b30SAlex Deucher &hpd); 1891771fe6b9SJerome Glisse break; 1892771fe6b9SJerome Glisse case CT_IMAC_G5_ISIGHT: 1893771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (imac g5 isight)\n", 1894771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1895771fe6b9SJerome Glisse /* DVI-D - int tmds */ 1896179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1897eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1898771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18995137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1900771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1901771fe6b9SJerome Glisse 0), 1902771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1903771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT, 1904b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVID, &ddc_i2c, 1905eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 1906eed45b30SAlex Deucher &hpd); 1907771fe6b9SJerome Glisse /* VGA - tv dac */ 1908179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1909eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1910771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19115137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1912771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1913771fe6b9SJerome Glisse 2), 1914771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1915771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1916b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1917eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1918eed45b30SAlex Deucher &hpd); 1919771fe6b9SJerome Glisse /* TV - TV DAC */ 1920eed45b30SAlex Deucher ddc_i2c.valid = false; 1921eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1922771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19235137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1924771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1925771fe6b9SJerome Glisse 2), 1926771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1927771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1928771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1929b75fad06SAlex Deucher &ddc_i2c, 1930eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1931eed45b30SAlex Deucher &hpd); 1932771fe6b9SJerome Glisse break; 1933771fe6b9SJerome Glisse case CT_EMAC: 1934771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (emac)\n", 1935771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1936771fe6b9SJerome Glisse /* VGA - primary dac */ 1937179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1938eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1939771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19405137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1941771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1942771fe6b9SJerome Glisse 1), 1943771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1944771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 1945b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1946eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1947eed45b30SAlex Deucher &hpd); 1948771fe6b9SJerome Glisse /* VGA - tv dac */ 1949179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1950eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1951771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19525137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1953771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1954771fe6b9SJerome Glisse 2), 1955771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1956771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1957b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1958eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1959eed45b30SAlex Deucher &hpd); 1960771fe6b9SJerome Glisse /* TV - TV DAC */ 1961eed45b30SAlex Deucher ddc_i2c.valid = false; 1962eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1963771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19645137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1965771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1966771fe6b9SJerome Glisse 2), 1967771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1968771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1969771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1970b75fad06SAlex Deucher &ddc_i2c, 1971eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1972eed45b30SAlex Deucher &hpd); 1973771fe6b9SJerome Glisse break; 197476a7142aSDave Airlie case CT_RN50_POWER: 197576a7142aSDave Airlie DRM_INFO("Connector Table: %d (rn50-power)\n", 197676a7142aSDave Airlie rdev->mode_info.connector_table); 197776a7142aSDave Airlie /* VGA - primary dac */ 1978179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 197976a7142aSDave Airlie hpd.hpd = RADEON_HPD_NONE; 198076a7142aSDave Airlie radeon_add_legacy_encoder(dev, 19815137ee94SAlex Deucher radeon_get_encoder_enum(dev, 198276a7142aSDave Airlie ATOM_DEVICE_CRT1_SUPPORT, 198376a7142aSDave Airlie 1), 198476a7142aSDave Airlie ATOM_DEVICE_CRT1_SUPPORT); 198576a7142aSDave Airlie radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 198676a7142aSDave Airlie DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 198776a7142aSDave Airlie CONNECTOR_OBJECT_ID_VGA, 198876a7142aSDave Airlie &hpd); 1989179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 199076a7142aSDave Airlie hpd.hpd = RADEON_HPD_NONE; 199176a7142aSDave Airlie radeon_add_legacy_encoder(dev, 19925137ee94SAlex Deucher radeon_get_encoder_enum(dev, 199376a7142aSDave Airlie ATOM_DEVICE_CRT2_SUPPORT, 199476a7142aSDave Airlie 2), 199576a7142aSDave Airlie ATOM_DEVICE_CRT2_SUPPORT); 199676a7142aSDave Airlie radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 199776a7142aSDave Airlie DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 199876a7142aSDave Airlie CONNECTOR_OBJECT_ID_VGA, 199976a7142aSDave Airlie &hpd); 200076a7142aSDave Airlie break; 2001aa74fbb4SAlex Deucher case CT_MAC_X800: 2002aa74fbb4SAlex Deucher DRM_INFO("Connector Table: %d (mac x800)\n", 2003aa74fbb4SAlex Deucher rdev->mode_info.connector_table); 2004aa74fbb4SAlex Deucher /* DVI - primary dac, internal tmds */ 2005aa74fbb4SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 2006aa74fbb4SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 2007aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2008aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2009aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 2010aa74fbb4SAlex Deucher 0), 2011aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 2012aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2013aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2014aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2015aa74fbb4SAlex Deucher 1), 2016aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 2017aa74fbb4SAlex Deucher radeon_add_legacy_connector(dev, 0, 2018aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 2019aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2020aa74fbb4SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 2021aa74fbb4SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2022aa74fbb4SAlex Deucher &hpd); 2023aa74fbb4SAlex Deucher /* DVI - tv dac, dvo */ 2024aa74fbb4SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 2025aa74fbb4SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 2026aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2027aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2028aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT, 2029aa74fbb4SAlex Deucher 0), 2030aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT); 2031aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2032aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2033aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2034aa74fbb4SAlex Deucher 2), 2035aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 2036aa74fbb4SAlex Deucher radeon_add_legacy_connector(dev, 1, 2037aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT | 2038aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2039aa74fbb4SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 2040aa74fbb4SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 2041aa74fbb4SAlex Deucher &hpd); 2042aa74fbb4SAlex Deucher break; 20439fad321aSAlex Deucher case CT_MAC_G5_9600: 20449fad321aSAlex Deucher DRM_INFO("Connector Table: %d (mac g5 9600)\n", 20459fad321aSAlex Deucher rdev->mode_info.connector_table); 20469fad321aSAlex Deucher /* DVI - tv dac, dvo */ 20479fad321aSAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 20489fad321aSAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 20499fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20509fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20519fad321aSAlex Deucher ATOM_DEVICE_DFP2_SUPPORT, 20529fad321aSAlex Deucher 0), 20539fad321aSAlex Deucher ATOM_DEVICE_DFP2_SUPPORT); 20549fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20559fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20569fad321aSAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 20579fad321aSAlex Deucher 2), 20589fad321aSAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 20599fad321aSAlex Deucher radeon_add_legacy_connector(dev, 0, 20609fad321aSAlex Deucher ATOM_DEVICE_DFP2_SUPPORT | 20619fad321aSAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 20629fad321aSAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 20639fad321aSAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 20649fad321aSAlex Deucher &hpd); 20659fad321aSAlex Deucher /* ADC - primary dac, internal tmds */ 20669fad321aSAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 20679fad321aSAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 20689fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20699fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20709fad321aSAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 20719fad321aSAlex Deucher 0), 20729fad321aSAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 20739fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20749fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20759fad321aSAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 20769fad321aSAlex Deucher 1), 20779fad321aSAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 20789fad321aSAlex Deucher radeon_add_legacy_connector(dev, 1, 20799fad321aSAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 20809fad321aSAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 20819fad321aSAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 20829fad321aSAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 20839fad321aSAlex Deucher &hpd); 2084beb47274SAlex Deucher /* TV - TV DAC */ 2085beb47274SAlex Deucher ddc_i2c.valid = false; 2086beb47274SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2087beb47274SAlex Deucher radeon_add_legacy_encoder(dev, 2088beb47274SAlex Deucher radeon_get_encoder_enum(dev, 2089beb47274SAlex Deucher ATOM_DEVICE_TV1_SUPPORT, 2090beb47274SAlex Deucher 2), 2091beb47274SAlex Deucher ATOM_DEVICE_TV1_SUPPORT); 2092beb47274SAlex Deucher radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 2093beb47274SAlex Deucher DRM_MODE_CONNECTOR_SVIDEO, 2094beb47274SAlex Deucher &ddc_i2c, 2095beb47274SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2096beb47274SAlex Deucher &hpd); 20979fad321aSAlex Deucher break; 20986a556039SAlex Deucher case CT_SAM440EP: 20996a556039SAlex Deucher DRM_INFO("Connector Table: %d (SAM440ep embedded board)\n", 21006a556039SAlex Deucher rdev->mode_info.connector_table); 21016a556039SAlex Deucher /* LVDS */ 21026a556039SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_NONE_DETECTED, 0, 0); 21036a556039SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 21046a556039SAlex Deucher radeon_add_legacy_encoder(dev, 21056a556039SAlex Deucher radeon_get_encoder_enum(dev, 21066a556039SAlex Deucher ATOM_DEVICE_LCD1_SUPPORT, 21076a556039SAlex Deucher 0), 21086a556039SAlex Deucher ATOM_DEVICE_LCD1_SUPPORT); 21096a556039SAlex Deucher radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 21106a556039SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 21116a556039SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 21126a556039SAlex Deucher &hpd); 21136a556039SAlex Deucher /* DVI-I - secondary dac, int tmds */ 21146a556039SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 21156a556039SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 21166a556039SAlex Deucher radeon_add_legacy_encoder(dev, 21176a556039SAlex Deucher radeon_get_encoder_enum(dev, 21186a556039SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 21196a556039SAlex Deucher 0), 21206a556039SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 21216a556039SAlex Deucher radeon_add_legacy_encoder(dev, 21226a556039SAlex Deucher radeon_get_encoder_enum(dev, 21236a556039SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 21246a556039SAlex Deucher 2), 21256a556039SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 21266a556039SAlex Deucher radeon_add_legacy_connector(dev, 1, 21276a556039SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 21286a556039SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 21296a556039SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 21306a556039SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 21316a556039SAlex Deucher &hpd); 21326a556039SAlex Deucher /* VGA - primary dac */ 21336a556039SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 21346a556039SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 21356a556039SAlex Deucher radeon_add_legacy_encoder(dev, 21366a556039SAlex Deucher radeon_get_encoder_enum(dev, 21376a556039SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 21386a556039SAlex Deucher 1), 21396a556039SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 21406a556039SAlex Deucher radeon_add_legacy_connector(dev, 2, 21416a556039SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 21426a556039SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 21436a556039SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 21446a556039SAlex Deucher &hpd); 21456a556039SAlex Deucher /* TV - TV DAC */ 21466a556039SAlex Deucher ddc_i2c.valid = false; 21476a556039SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 21486a556039SAlex Deucher radeon_add_legacy_encoder(dev, 21496a556039SAlex Deucher radeon_get_encoder_enum(dev, 21506a556039SAlex Deucher ATOM_DEVICE_TV1_SUPPORT, 21516a556039SAlex Deucher 2), 21526a556039SAlex Deucher ATOM_DEVICE_TV1_SUPPORT); 21536a556039SAlex Deucher radeon_add_legacy_connector(dev, 3, ATOM_DEVICE_TV1_SUPPORT, 21546a556039SAlex Deucher DRM_MODE_CONNECTOR_SVIDEO, 21556a556039SAlex Deucher &ddc_i2c, 21566a556039SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 21576a556039SAlex Deucher &hpd); 21586a556039SAlex Deucher break; 2159cafa59b9SAlex Deucher case CT_MAC_G4_SILVER: 2160cafa59b9SAlex Deucher DRM_INFO("Connector Table: %d (mac g4 silver)\n", 2161cafa59b9SAlex Deucher rdev->mode_info.connector_table); 2162cafa59b9SAlex Deucher /* DVI-I - tv dac, int tmds */ 2163cafa59b9SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 2164cafa59b9SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 2165cafa59b9SAlex Deucher radeon_add_legacy_encoder(dev, 2166cafa59b9SAlex Deucher radeon_get_encoder_enum(dev, 2167cafa59b9SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 2168cafa59b9SAlex Deucher 0), 2169cafa59b9SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 2170cafa59b9SAlex Deucher radeon_add_legacy_encoder(dev, 2171cafa59b9SAlex Deucher radeon_get_encoder_enum(dev, 2172cafa59b9SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2173cafa59b9SAlex Deucher 2), 2174cafa59b9SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 2175cafa59b9SAlex Deucher radeon_add_legacy_connector(dev, 0, 2176cafa59b9SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 2177cafa59b9SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2178cafa59b9SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 2179cafa59b9SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2180cafa59b9SAlex Deucher &hpd); 2181cafa59b9SAlex Deucher /* VGA - primary dac */ 2182cafa59b9SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 2183cafa59b9SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2184cafa59b9SAlex Deucher radeon_add_legacy_encoder(dev, 2185cafa59b9SAlex Deucher radeon_get_encoder_enum(dev, 2186cafa59b9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2187cafa59b9SAlex Deucher 1), 2188cafa59b9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 2189cafa59b9SAlex Deucher radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT, 2190cafa59b9SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 2191cafa59b9SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2192cafa59b9SAlex Deucher &hpd); 2193cafa59b9SAlex Deucher /* TV - TV DAC */ 2194cafa59b9SAlex Deucher ddc_i2c.valid = false; 2195cafa59b9SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2196cafa59b9SAlex Deucher radeon_add_legacy_encoder(dev, 2197cafa59b9SAlex Deucher radeon_get_encoder_enum(dev, 2198cafa59b9SAlex Deucher ATOM_DEVICE_TV1_SUPPORT, 2199cafa59b9SAlex Deucher 2), 2200cafa59b9SAlex Deucher ATOM_DEVICE_TV1_SUPPORT); 2201cafa59b9SAlex Deucher radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 2202cafa59b9SAlex Deucher DRM_MODE_CONNECTOR_SVIDEO, 2203cafa59b9SAlex Deucher &ddc_i2c, 2204cafa59b9SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2205cafa59b9SAlex Deucher &hpd); 2206cafa59b9SAlex Deucher break; 2207771fe6b9SJerome Glisse default: 2208771fe6b9SJerome Glisse DRM_INFO("Connector table: %d (invalid)\n", 2209771fe6b9SJerome Glisse rdev->mode_info.connector_table); 2210771fe6b9SJerome Glisse return false; 2211771fe6b9SJerome Glisse } 2212771fe6b9SJerome Glisse 2213771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2214771fe6b9SJerome Glisse 2215771fe6b9SJerome Glisse return true; 2216771fe6b9SJerome Glisse } 2217771fe6b9SJerome Glisse 2218771fe6b9SJerome Glisse static bool radeon_apply_legacy_quirks(struct drm_device *dev, 2219771fe6b9SJerome Glisse int bios_index, 2220771fe6b9SJerome Glisse enum radeon_combios_connector 2221771fe6b9SJerome Glisse *legacy_connector, 2222eed45b30SAlex Deucher struct radeon_i2c_bus_rec *ddc_i2c, 2223eed45b30SAlex Deucher struct radeon_hpd *hpd) 2224771fe6b9SJerome Glisse { 2225fcec570bSAlex Deucher 2226771fe6b9SJerome Glisse /* Certain IBM chipset RN50s have a BIOS reporting two VGAs, 2227771fe6b9SJerome Glisse one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */ 2228771fe6b9SJerome Glisse if (dev->pdev->device == 0x515e && 2229771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x1014) { 2230771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_CRT_LEGACY && 2231771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 2232771fe6b9SJerome Glisse return false; 2233771fe6b9SJerome Glisse } 2234771fe6b9SJerome Glisse 2235771fe6b9SJerome Glisse /* X300 card with extra non-existent DVI port */ 2236771fe6b9SJerome Glisse if (dev->pdev->device == 0x5B60 && 2237771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x17af && 2238771fe6b9SJerome Glisse dev->pdev->subsystem_device == 0x201e && bios_index == 2) { 2239771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_DVI_I_LEGACY) 2240771fe6b9SJerome Glisse return false; 2241771fe6b9SJerome Glisse } 2242771fe6b9SJerome Glisse 2243771fe6b9SJerome Glisse return true; 2244771fe6b9SJerome Glisse } 2245771fe6b9SJerome Glisse 2246790cfb34SAlex Deucher static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev) 2247790cfb34SAlex Deucher { 2248790cfb34SAlex Deucher /* Acer 5102 has non-existent TV port */ 2249790cfb34SAlex Deucher if (dev->pdev->device == 0x5975 && 2250790cfb34SAlex Deucher dev->pdev->subsystem_vendor == 0x1025 && 2251790cfb34SAlex Deucher dev->pdev->subsystem_device == 0x009f) 2252790cfb34SAlex Deucher return false; 2253790cfb34SAlex Deucher 2254fc7f7119SAlex Deucher /* HP dc5750 has non-existent TV port */ 2255fc7f7119SAlex Deucher if (dev->pdev->device == 0x5974 && 2256fc7f7119SAlex Deucher dev->pdev->subsystem_vendor == 0x103c && 2257fc7f7119SAlex Deucher dev->pdev->subsystem_device == 0x280a) 2258fc7f7119SAlex Deucher return false; 2259fc7f7119SAlex Deucher 2260fd874ad0SAlex Deucher /* MSI S270 has non-existent TV port */ 2261fd874ad0SAlex Deucher if (dev->pdev->device == 0x5955 && 2262fd874ad0SAlex Deucher dev->pdev->subsystem_vendor == 0x1462 && 2263fd874ad0SAlex Deucher dev->pdev->subsystem_device == 0x0131) 2264fd874ad0SAlex Deucher return false; 2265fd874ad0SAlex Deucher 2266790cfb34SAlex Deucher return true; 2267790cfb34SAlex Deucher } 2268790cfb34SAlex Deucher 2269b75fad06SAlex Deucher static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d) 2270b75fad06SAlex Deucher { 2271b75fad06SAlex Deucher struct radeon_device *rdev = dev->dev_private; 2272b75fad06SAlex Deucher uint32_t ext_tmds_info; 2273b75fad06SAlex Deucher 2274b75fad06SAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2275b75fad06SAlex Deucher if (is_dvi_d) 2276b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 2277b75fad06SAlex Deucher else 2278b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2279b75fad06SAlex Deucher } 2280b75fad06SAlex Deucher ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2281b75fad06SAlex Deucher if (ext_tmds_info) { 2282b75fad06SAlex Deucher uint8_t rev = RBIOS8(ext_tmds_info); 2283b75fad06SAlex Deucher uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5); 2284b75fad06SAlex Deucher if (rev >= 3) { 2285b75fad06SAlex Deucher if (is_dvi_d) 2286b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 2287b75fad06SAlex Deucher else 2288b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 2289b75fad06SAlex Deucher } else { 2290b75fad06SAlex Deucher if (flags & 1) { 2291b75fad06SAlex Deucher if (is_dvi_d) 2292b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 2293b75fad06SAlex Deucher else 2294b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 2295b75fad06SAlex Deucher } 2296b75fad06SAlex Deucher } 2297b75fad06SAlex Deucher } 2298b75fad06SAlex Deucher if (is_dvi_d) 2299b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 2300b75fad06SAlex Deucher else 2301b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2302b75fad06SAlex Deucher } 2303b75fad06SAlex Deucher 2304771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) 2305771fe6b9SJerome Glisse { 2306771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2307771fe6b9SJerome Glisse uint32_t conn_info, entry, devices; 2308b75fad06SAlex Deucher uint16_t tmp, connector_object_id; 2309771fe6b9SJerome Glisse enum radeon_combios_ddc ddc_type; 2310771fe6b9SJerome Glisse enum radeon_combios_connector connector; 2311771fe6b9SJerome Glisse int i = 0; 2312771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 2313eed45b30SAlex Deucher struct radeon_hpd hpd; 2314771fe6b9SJerome Glisse 2315771fe6b9SJerome Glisse conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE); 2316771fe6b9SJerome Glisse if (conn_info) { 2317771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 2318771fe6b9SJerome Glisse entry = conn_info + 2 + i * 2; 2319771fe6b9SJerome Glisse 2320771fe6b9SJerome Glisse if (!RBIOS16(entry)) 2321771fe6b9SJerome Glisse break; 2322771fe6b9SJerome Glisse 2323771fe6b9SJerome Glisse tmp = RBIOS16(entry); 2324771fe6b9SJerome Glisse 2325771fe6b9SJerome Glisse connector = (tmp >> 12) & 0xf; 2326771fe6b9SJerome Glisse 2327771fe6b9SJerome Glisse ddc_type = (tmp >> 8) & 0xf; 23283d61bd42SAlex Deucher if (ddc_type == 5) 23293d61bd42SAlex Deucher ddc_i2c = radeon_combios_get_i2c_info_from_table(rdev); 23303d61bd42SAlex Deucher else 2331179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, ddc_type, 0, 0); 2332771fe6b9SJerome Glisse 2333eed45b30SAlex Deucher switch (connector) { 2334eed45b30SAlex Deucher case CONNECTOR_PROPRIETARY_LEGACY: 2335eed45b30SAlex Deucher case CONNECTOR_DVI_I_LEGACY: 2336eed45b30SAlex Deucher case CONNECTOR_DVI_D_LEGACY: 2337eed45b30SAlex Deucher if ((tmp >> 4) & 0x1) 2338eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; 2339eed45b30SAlex Deucher else 2340eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 2341eed45b30SAlex Deucher break; 2342eed45b30SAlex Deucher default: 2343eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2344eed45b30SAlex Deucher break; 2345eed45b30SAlex Deucher } 2346eed45b30SAlex Deucher 23472d152c6bSAlex Deucher if (!radeon_apply_legacy_quirks(dev, i, &connector, 2348eed45b30SAlex Deucher &ddc_i2c, &hpd)) 23492d152c6bSAlex Deucher continue; 2350771fe6b9SJerome Glisse 2351771fe6b9SJerome Glisse switch (connector) { 2352771fe6b9SJerome Glisse case CONNECTOR_PROPRIETARY_LEGACY: 2353771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) 2354771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2355771fe6b9SJerome Glisse else 2356771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2357771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23585137ee94SAlex Deucher radeon_get_encoder_enum 2359771fe6b9SJerome Glisse (dev, devices, 0), 2360771fe6b9SJerome Glisse devices); 2361771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2362771fe6b9SJerome Glisse legacy_connector_convert 2363771fe6b9SJerome Glisse [connector], 2364b75fad06SAlex Deucher &ddc_i2c, 2365eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 2366eed45b30SAlex Deucher &hpd); 2367771fe6b9SJerome Glisse break; 2368771fe6b9SJerome Glisse case CONNECTOR_CRT_LEGACY: 2369771fe6b9SJerome Glisse if (tmp & 0x1) { 2370771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT2_SUPPORT; 2371771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23725137ee94SAlex Deucher radeon_get_encoder_enum 2373771fe6b9SJerome Glisse (dev, 2374771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2375771fe6b9SJerome Glisse 2), 2376771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2377771fe6b9SJerome Glisse } else { 2378771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT1_SUPPORT; 2379771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23805137ee94SAlex Deucher radeon_get_encoder_enum 2381771fe6b9SJerome Glisse (dev, 2382771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2383771fe6b9SJerome Glisse 1), 2384771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2385771fe6b9SJerome Glisse } 2386771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2387771fe6b9SJerome Glisse i, 2388771fe6b9SJerome Glisse devices, 2389771fe6b9SJerome Glisse legacy_connector_convert 2390771fe6b9SJerome Glisse [connector], 2391b75fad06SAlex Deucher &ddc_i2c, 2392eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2393eed45b30SAlex Deucher &hpd); 2394771fe6b9SJerome Glisse break; 2395771fe6b9SJerome Glisse case CONNECTOR_DVI_I_LEGACY: 2396771fe6b9SJerome Glisse devices = 0; 2397771fe6b9SJerome Glisse if (tmp & 0x1) { 2398771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT2_SUPPORT; 2399771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24005137ee94SAlex Deucher radeon_get_encoder_enum 2401771fe6b9SJerome Glisse (dev, 2402771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2403771fe6b9SJerome Glisse 2), 2404771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2405771fe6b9SJerome Glisse } else { 2406771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT1_SUPPORT; 2407771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24085137ee94SAlex Deucher radeon_get_encoder_enum 2409771fe6b9SJerome Glisse (dev, 2410771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2411771fe6b9SJerome Glisse 1), 2412771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2413771fe6b9SJerome Glisse } 24149200ee49SAlex Deucher /* RV100 board with external TDMS bit mis-set. 24159200ee49SAlex Deucher * Actually uses internal TMDS, clear the bit. 24169200ee49SAlex Deucher */ 24179200ee49SAlex Deucher if (dev->pdev->device == 0x5159 && 24189200ee49SAlex Deucher dev->pdev->subsystem_vendor == 0x1014 && 24199200ee49SAlex Deucher dev->pdev->subsystem_device == 0x029A) { 24209200ee49SAlex Deucher tmp &= ~(1 << 4); 24219200ee49SAlex Deucher } 2422771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) { 2423771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP2_SUPPORT; 2424771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24255137ee94SAlex Deucher radeon_get_encoder_enum 2426771fe6b9SJerome Glisse (dev, 2427771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 2428771fe6b9SJerome Glisse 0), 2429771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 2430b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 0); 2431771fe6b9SJerome Glisse } else { 2432771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP1_SUPPORT; 2433771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24345137ee94SAlex Deucher radeon_get_encoder_enum 2435771fe6b9SJerome Glisse (dev, 2436771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2437771fe6b9SJerome Glisse 0), 2438771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2439b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2440771fe6b9SJerome Glisse } 2441771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2442771fe6b9SJerome Glisse i, 2443771fe6b9SJerome Glisse devices, 2444771fe6b9SJerome Glisse legacy_connector_convert 2445771fe6b9SJerome Glisse [connector], 2446b75fad06SAlex Deucher &ddc_i2c, 2447eed45b30SAlex Deucher connector_object_id, 2448eed45b30SAlex Deucher &hpd); 2449771fe6b9SJerome Glisse break; 2450771fe6b9SJerome Glisse case CONNECTOR_DVI_D_LEGACY: 2451b75fad06SAlex Deucher if ((tmp >> 4) & 0x1) { 2452771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2453b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 1); 2454b75fad06SAlex Deucher } else { 2455771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2456b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2457b75fad06SAlex Deucher } 2458771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24595137ee94SAlex Deucher radeon_get_encoder_enum 2460771fe6b9SJerome Glisse (dev, devices, 0), 2461771fe6b9SJerome Glisse devices); 2462771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2463771fe6b9SJerome Glisse legacy_connector_convert 2464771fe6b9SJerome Glisse [connector], 2465b75fad06SAlex Deucher &ddc_i2c, 2466eed45b30SAlex Deucher connector_object_id, 2467eed45b30SAlex Deucher &hpd); 2468771fe6b9SJerome Glisse break; 2469771fe6b9SJerome Glisse case CONNECTOR_CTV_LEGACY: 2470771fe6b9SJerome Glisse case CONNECTOR_STV_LEGACY: 2471771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24725137ee94SAlex Deucher radeon_get_encoder_enum 2473771fe6b9SJerome Glisse (dev, 2474771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2475771fe6b9SJerome Glisse 2), 2476771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2477771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, 2478771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2479771fe6b9SJerome Glisse legacy_connector_convert 2480771fe6b9SJerome Glisse [connector], 2481b75fad06SAlex Deucher &ddc_i2c, 2482eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2483eed45b30SAlex Deucher &hpd); 2484771fe6b9SJerome Glisse break; 2485771fe6b9SJerome Glisse default: 2486771fe6b9SJerome Glisse DRM_ERROR("Unknown connector type: %d\n", 2487771fe6b9SJerome Glisse connector); 2488771fe6b9SJerome Glisse continue; 2489771fe6b9SJerome Glisse } 2490771fe6b9SJerome Glisse 2491771fe6b9SJerome Glisse } 2492771fe6b9SJerome Glisse } else { 2493771fe6b9SJerome Glisse uint16_t tmds_info = 2494771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 2495771fe6b9SJerome Glisse if (tmds_info) { 2496d9fdaafbSDave Airlie DRM_DEBUG_KMS("Found DFP table, assuming DVI connector\n"); 2497771fe6b9SJerome Glisse 2498771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24995137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2500771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2501771fe6b9SJerome Glisse 1), 2502771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2503771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 25045137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2505771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2506771fe6b9SJerome Glisse 0), 2507771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2508771fe6b9SJerome Glisse 2509179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 25108e36ed00SAlex Deucher hpd.hpd = RADEON_HPD_1; 2511771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2512771fe6b9SJerome Glisse 0, 2513771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT | 2514771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2515771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 2516b75fad06SAlex Deucher &ddc_i2c, 2517eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2518eed45b30SAlex Deucher &hpd); 2519771fe6b9SJerome Glisse } else { 2520d0c403e9SAlex Deucher uint16_t crt_info = 2521d0c403e9SAlex Deucher combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 2522d9fdaafbSDave Airlie DRM_DEBUG_KMS("Found CRT table, assuming VGA connector\n"); 2523d0c403e9SAlex Deucher if (crt_info) { 2524d0c403e9SAlex Deucher radeon_add_legacy_encoder(dev, 25255137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2526d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2527d0c403e9SAlex Deucher 1), 2528d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 2529179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 2530eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2531d0c403e9SAlex Deucher radeon_add_legacy_connector(dev, 2532d0c403e9SAlex Deucher 0, 2533d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2534d0c403e9SAlex Deucher DRM_MODE_CONNECTOR_VGA, 2535b75fad06SAlex Deucher &ddc_i2c, 2536eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2537eed45b30SAlex Deucher &hpd); 2538d0c403e9SAlex Deucher } else { 2539d9fdaafbSDave Airlie DRM_DEBUG_KMS("No connector info found\n"); 2540771fe6b9SJerome Glisse return false; 2541771fe6b9SJerome Glisse } 2542771fe6b9SJerome Glisse } 2543d0c403e9SAlex Deucher } 2544771fe6b9SJerome Glisse 2545771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) { 2546771fe6b9SJerome Glisse uint16_t lcd_info = 2547771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 2548771fe6b9SJerome Glisse if (lcd_info) { 2549771fe6b9SJerome Glisse uint16_t lcd_ddc_info = 2550771fe6b9SJerome Glisse combios_get_table_offset(dev, 2551771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE); 2552771fe6b9SJerome Glisse 2553771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 25545137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2555771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2556771fe6b9SJerome Glisse 0), 2557771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 2558771fe6b9SJerome Glisse 2559771fe6b9SJerome Glisse if (lcd_ddc_info) { 2560771fe6b9SJerome Glisse ddc_type = RBIOS8(lcd_ddc_info + 2); 2561771fe6b9SJerome Glisse switch (ddc_type) { 2562771fe6b9SJerome Glisse case DDC_LCD: 2563771fe6b9SJerome Glisse ddc_i2c = 2564179e8078SAlex Deucher combios_setup_i2c_bus(rdev, 2565179e8078SAlex Deucher DDC_LCD, 2566179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 3), 2567179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 7)); 2568f376b94fSAlex Deucher radeon_i2c_add(rdev, &ddc_i2c, "LCD"); 2569771fe6b9SJerome Glisse break; 2570771fe6b9SJerome Glisse case DDC_GPIO: 2571771fe6b9SJerome Glisse ddc_i2c = 2572179e8078SAlex Deucher combios_setup_i2c_bus(rdev, 2573179e8078SAlex Deucher DDC_GPIO, 2574179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 3), 2575179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 7)); 2576f376b94fSAlex Deucher radeon_i2c_add(rdev, &ddc_i2c, "LCD"); 2577771fe6b9SJerome Glisse break; 2578771fe6b9SJerome Glisse default: 2579179e8078SAlex Deucher ddc_i2c = 2580179e8078SAlex Deucher combios_setup_i2c_bus(rdev, ddc_type, 0, 0); 2581771fe6b9SJerome Glisse break; 2582771fe6b9SJerome Glisse } 2583d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD DDC Info Table found!\n"); 2584771fe6b9SJerome Glisse } else 2585771fe6b9SJerome Glisse ddc_i2c.valid = false; 2586771fe6b9SJerome Glisse 2587eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2588771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2589771fe6b9SJerome Glisse 5, 2590771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2591771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 2592b75fad06SAlex Deucher &ddc_i2c, 2593eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 2594eed45b30SAlex Deucher &hpd); 2595771fe6b9SJerome Glisse } 2596771fe6b9SJerome Glisse } 2597771fe6b9SJerome Glisse 2598771fe6b9SJerome Glisse /* check TV table */ 2599771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 2600771fe6b9SJerome Glisse uint32_t tv_info = 2601771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 2602771fe6b9SJerome Glisse if (tv_info) { 2603771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 2604790cfb34SAlex Deucher if (radeon_apply_legacy_tv_quirks(dev)) { 2605eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2606d294ed69SDave Airlie ddc_i2c.valid = false; 2607771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 26085137ee94SAlex Deucher radeon_get_encoder_enum 2609771fe6b9SJerome Glisse (dev, 2610771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2611771fe6b9SJerome Glisse 2), 2612771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2613771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 6, 2614771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2615771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 2616b75fad06SAlex Deucher &ddc_i2c, 2617eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2618eed45b30SAlex Deucher &hpd); 2619771fe6b9SJerome Glisse } 2620771fe6b9SJerome Glisse } 2621771fe6b9SJerome Glisse } 2622790cfb34SAlex Deucher } 2623771fe6b9SJerome Glisse 2624771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2625771fe6b9SJerome Glisse 2626771fe6b9SJerome Glisse return true; 2627771fe6b9SJerome Glisse } 2628771fe6b9SJerome Glisse 262963f7d982SAlex Deucher static const char *thermal_controller_names[] = { 263063f7d982SAlex Deucher "NONE", 263163f7d982SAlex Deucher "lm63", 263263f7d982SAlex Deucher "adm1032", 263363f7d982SAlex Deucher }; 263463f7d982SAlex Deucher 263556278a8eSAlex Deucher void radeon_combios_get_power_modes(struct radeon_device *rdev) 263656278a8eSAlex Deucher { 263756278a8eSAlex Deucher struct drm_device *dev = rdev->ddev; 263856278a8eSAlex Deucher u16 offset, misc, misc2 = 0; 263956278a8eSAlex Deucher u8 rev, blocks, tmp; 264056278a8eSAlex Deucher int state_index = 0; 2641c41b9ee9SAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 264256278a8eSAlex Deucher 2643a48b9b4eSAlex Deucher rdev->pm.default_power_state_index = -1; 264456278a8eSAlex Deucher 26450975b162SAlex Deucher /* allocate 2 power states */ 26460975b162SAlex Deucher rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * 2, GFP_KERNEL); 2647a7c36fd8SAlex Deucher if (rdev->pm.power_state) { 2648a7c36fd8SAlex Deucher /* allocate 1 clock mode per state */ 2649a7c36fd8SAlex Deucher rdev->pm.power_state[0].clock_info = 2650a7c36fd8SAlex Deucher kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL); 2651a7c36fd8SAlex Deucher rdev->pm.power_state[1].clock_info = 2652a7c36fd8SAlex Deucher kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL); 2653a7c36fd8SAlex Deucher if (!rdev->pm.power_state[0].clock_info || 2654a7c36fd8SAlex Deucher !rdev->pm.power_state[1].clock_info) 2655a7c36fd8SAlex Deucher goto pm_failed; 2656a7c36fd8SAlex Deucher } else 2657a7c36fd8SAlex Deucher goto pm_failed; 26580975b162SAlex Deucher 265963f7d982SAlex Deucher /* check for a thermal chip */ 266063f7d982SAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_OVERDRIVE_INFO_TABLE); 266163f7d982SAlex Deucher if (offset) { 266263f7d982SAlex Deucher u8 thermal_controller = 0, gpio = 0, i2c_addr = 0, clk_bit = 0, data_bit = 0; 266363f7d982SAlex Deucher 266463f7d982SAlex Deucher rev = RBIOS8(offset); 266563f7d982SAlex Deucher 266663f7d982SAlex Deucher if (rev == 0) { 266763f7d982SAlex Deucher thermal_controller = RBIOS8(offset + 3); 266863f7d982SAlex Deucher gpio = RBIOS8(offset + 4) & 0x3f; 266963f7d982SAlex Deucher i2c_addr = RBIOS8(offset + 5); 267063f7d982SAlex Deucher } else if (rev == 1) { 267163f7d982SAlex Deucher thermal_controller = RBIOS8(offset + 4); 267263f7d982SAlex Deucher gpio = RBIOS8(offset + 5) & 0x3f; 267363f7d982SAlex Deucher i2c_addr = RBIOS8(offset + 6); 267463f7d982SAlex Deucher } else if (rev == 2) { 267563f7d982SAlex Deucher thermal_controller = RBIOS8(offset + 4); 267663f7d982SAlex Deucher gpio = RBIOS8(offset + 5) & 0x3f; 267763f7d982SAlex Deucher i2c_addr = RBIOS8(offset + 6); 267863f7d982SAlex Deucher clk_bit = RBIOS8(offset + 0xa); 267963f7d982SAlex Deucher data_bit = RBIOS8(offset + 0xb); 268063f7d982SAlex Deucher } 268163f7d982SAlex Deucher if ((thermal_controller > 0) && (thermal_controller < 3)) { 268263f7d982SAlex Deucher DRM_INFO("Possible %s thermal controller at 0x%02x\n", 268363f7d982SAlex Deucher thermal_controller_names[thermal_controller], 268463f7d982SAlex Deucher i2c_addr >> 1); 268563f7d982SAlex Deucher if (gpio == DDC_LCD) { 268663f7d982SAlex Deucher /* MM i2c */ 268763f7d982SAlex Deucher i2c_bus.valid = true; 268863f7d982SAlex Deucher i2c_bus.hw_capable = true; 268963f7d982SAlex Deucher i2c_bus.mm_i2c = true; 269063f7d982SAlex Deucher i2c_bus.i2c_id = 0xa0; 269163f7d982SAlex Deucher } else if (gpio == DDC_GPIO) 269263f7d982SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 1 << clk_bit, 1 << data_bit); 269363f7d982SAlex Deucher else 269463f7d982SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0); 269563f7d982SAlex Deucher rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 269663f7d982SAlex Deucher if (rdev->pm.i2c_bus) { 269763f7d982SAlex Deucher struct i2c_board_info info = { }; 269863f7d982SAlex Deucher const char *name = thermal_controller_names[thermal_controller]; 269963f7d982SAlex Deucher info.addr = i2c_addr >> 1; 270063f7d982SAlex Deucher strlcpy(info.type, name, sizeof(info.type)); 270163f7d982SAlex Deucher i2c_new_device(&rdev->pm.i2c_bus->adapter, &info); 270263f7d982SAlex Deucher } 270363f7d982SAlex Deucher } 2704c41b9ee9SAlex Deucher } else { 2705c41b9ee9SAlex Deucher /* boards with a thermal chip, but no overdrive table */ 2706c41b9ee9SAlex Deucher 2707c41b9ee9SAlex Deucher /* Asus 9600xt has an f75375 on the monid bus */ 2708c41b9ee9SAlex Deucher if ((dev->pdev->device == 0x4152) && 2709c41b9ee9SAlex Deucher (dev->pdev->subsystem_vendor == 0x1043) && 2710c41b9ee9SAlex Deucher (dev->pdev->subsystem_device == 0xc002)) { 2711c41b9ee9SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 2712c41b9ee9SAlex Deucher rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 2713c41b9ee9SAlex Deucher if (rdev->pm.i2c_bus) { 2714c41b9ee9SAlex Deucher struct i2c_board_info info = { }; 2715c41b9ee9SAlex Deucher const char *name = "f75375"; 2716c41b9ee9SAlex Deucher info.addr = 0x28; 2717c41b9ee9SAlex Deucher strlcpy(info.type, name, sizeof(info.type)); 2718c41b9ee9SAlex Deucher i2c_new_device(&rdev->pm.i2c_bus->adapter, &info); 2719c41b9ee9SAlex Deucher DRM_INFO("Possible %s thermal controller at 0x%02x\n", 2720c41b9ee9SAlex Deucher name, info.addr); 2721c41b9ee9SAlex Deucher } 2722c41b9ee9SAlex Deucher } 272363f7d982SAlex Deucher } 272463f7d982SAlex Deucher 272556278a8eSAlex Deucher if (rdev->flags & RADEON_IS_MOBILITY) { 272656278a8eSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE); 272756278a8eSAlex Deucher if (offset) { 272856278a8eSAlex Deucher rev = RBIOS8(offset); 272956278a8eSAlex Deucher blocks = RBIOS8(offset + 0x2); 273056278a8eSAlex Deucher /* power mode 0 tends to be the only valid one */ 273156278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 273256278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = RBIOS32(offset + 0x5 + 0x2); 273356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = RBIOS32(offset + 0x5 + 0x6); 273456278a8eSAlex Deucher if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) || 273556278a8eSAlex Deucher (rdev->pm.power_state[state_index].clock_info[0].sclk == 0)) 273656278a8eSAlex Deucher goto default_mode; 27370ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 27380ec0e74fSAlex Deucher POWER_STATE_TYPE_BATTERY; 273956278a8eSAlex Deucher misc = RBIOS16(offset + 0x5 + 0x0); 274056278a8eSAlex Deucher if (rev > 4) 274156278a8eSAlex Deucher misc2 = RBIOS16(offset + 0x5 + 0xe); 274279daedc9SAlex Deucher rdev->pm.power_state[state_index].misc = misc; 274379daedc9SAlex Deucher rdev->pm.power_state[state_index].misc2 = misc2; 274456278a8eSAlex Deucher if (misc & 0x4) { 274556278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_GPIO; 274656278a8eSAlex Deucher if (misc & 0x8) 274756278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 274856278a8eSAlex Deucher true; 274956278a8eSAlex Deucher else 275056278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 275156278a8eSAlex Deucher false; 275256278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = true; 275356278a8eSAlex Deucher if (rev < 6) { 275456278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 275556278a8eSAlex Deucher RBIOS16(offset + 0x5 + 0xb) * 4; 275656278a8eSAlex Deucher tmp = RBIOS8(offset + 0x5 + 0xd); 275756278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 275856278a8eSAlex Deucher } else { 275956278a8eSAlex Deucher u8 entries = RBIOS8(offset + 0x5 + 0xb); 276056278a8eSAlex Deucher u16 voltage_table_offset = RBIOS16(offset + 0x5 + 0xc); 276156278a8eSAlex Deucher if (entries && voltage_table_offset) { 276256278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 276356278a8eSAlex Deucher RBIOS16(voltage_table_offset) * 4; 276456278a8eSAlex Deucher tmp = RBIOS8(voltage_table_offset + 0x2); 276556278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 276656278a8eSAlex Deucher } else 276756278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = false; 276856278a8eSAlex Deucher } 276956278a8eSAlex Deucher switch ((misc2 & 0x700) >> 8) { 277056278a8eSAlex Deucher case 0: 277156278a8eSAlex Deucher default: 277256278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 0; 277356278a8eSAlex Deucher break; 277456278a8eSAlex Deucher case 1: 277556278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 33; 277656278a8eSAlex Deucher break; 277756278a8eSAlex Deucher case 2: 277856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 66; 277956278a8eSAlex Deucher break; 278056278a8eSAlex Deucher case 3: 278156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 99; 278256278a8eSAlex Deucher break; 278356278a8eSAlex Deucher case 4: 278456278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 132; 278556278a8eSAlex Deucher break; 278656278a8eSAlex Deucher } 278756278a8eSAlex Deucher } else 278856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 278956278a8eSAlex Deucher if (rev > 6) 279079daedc9SAlex Deucher rdev->pm.power_state[state_index].pcie_lanes = 279156278a8eSAlex Deucher RBIOS8(offset + 0x5 + 0x10); 2792d7311171SAlex Deucher rdev->pm.power_state[state_index].flags = RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; 279356278a8eSAlex Deucher state_index++; 279456278a8eSAlex Deucher } else { 279556278a8eSAlex Deucher /* XXX figure out some good default low power mode for mobility cards w/out power tables */ 279656278a8eSAlex Deucher } 279756278a8eSAlex Deucher } else { 279856278a8eSAlex Deucher /* XXX figure out some good default low power mode for desktop cards */ 279956278a8eSAlex Deucher } 280056278a8eSAlex Deucher 280156278a8eSAlex Deucher default_mode: 280256278a8eSAlex Deucher /* add the default mode */ 28030ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 28040ec0e74fSAlex Deucher POWER_STATE_TYPE_DEFAULT; 280556278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 280656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk; 280756278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk; 280856278a8eSAlex Deucher rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0]; 280984d88f4cSAlex Deucher if ((state_index > 0) && 28108de016e2SAlex Deucher (rdev->pm.power_state[0].clock_info[0].voltage.type == VOLTAGE_GPIO)) 281184d88f4cSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage = 281284d88f4cSAlex Deucher rdev->pm.power_state[0].clock_info[0].voltage; 281384d88f4cSAlex Deucher else 281456278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 281579daedc9SAlex Deucher rdev->pm.power_state[state_index].pcie_lanes = 16; 2816a48b9b4eSAlex Deucher rdev->pm.power_state[state_index].flags = 0; 2817a48b9b4eSAlex Deucher rdev->pm.default_power_state_index = state_index; 281856278a8eSAlex Deucher rdev->pm.num_power_states = state_index + 1; 28199038dfdfSRafał Miłecki 2820a48b9b4eSAlex Deucher rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; 2821a48b9b4eSAlex Deucher rdev->pm.current_clock_mode_index = 0; 2822a7c36fd8SAlex Deucher return; 2823a7c36fd8SAlex Deucher 2824a7c36fd8SAlex Deucher pm_failed: 2825a7c36fd8SAlex Deucher rdev->pm.default_power_state_index = state_index; 2826a7c36fd8SAlex Deucher rdev->pm.num_power_states = 0; 2827a7c36fd8SAlex Deucher 2828a7c36fd8SAlex Deucher rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; 2829a7c36fd8SAlex Deucher rdev->pm.current_clock_mode_index = 0; 283056278a8eSAlex Deucher } 283156278a8eSAlex Deucher 2832fcec570bSAlex Deucher void radeon_external_tmds_setup(struct drm_encoder *encoder) 2833fcec570bSAlex Deucher { 2834fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2835fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2836fcec570bSAlex Deucher 2837fcec570bSAlex Deucher if (!tmds) 2838fcec570bSAlex Deucher return; 2839fcec570bSAlex Deucher 2840fcec570bSAlex Deucher switch (tmds->dvo_chip) { 2841fcec570bSAlex Deucher case DVO_SIL164: 2842fcec570bSAlex Deucher /* sil 164 */ 28435a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2844fcec570bSAlex Deucher tmds->slave_addr, 2845fcec570bSAlex Deucher 0x08, 0x30); 28465a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2847fcec570bSAlex Deucher tmds->slave_addr, 2848fcec570bSAlex Deucher 0x09, 0x00); 28495a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2850fcec570bSAlex Deucher tmds->slave_addr, 2851fcec570bSAlex Deucher 0x0a, 0x90); 28525a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2853fcec570bSAlex Deucher tmds->slave_addr, 2854fcec570bSAlex Deucher 0x0c, 0x89); 28555a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2856fcec570bSAlex Deucher tmds->slave_addr, 2857fcec570bSAlex Deucher 0x08, 0x3b); 2858fcec570bSAlex Deucher break; 2859fcec570bSAlex Deucher case DVO_SIL1178: 2860fcec570bSAlex Deucher /* sil 1178 - untested */ 2861fcec570bSAlex Deucher /* 2862fcec570bSAlex Deucher * 0x0f, 0x44 2863fcec570bSAlex Deucher * 0x0f, 0x4c 2864fcec570bSAlex Deucher * 0x0e, 0x01 2865fcec570bSAlex Deucher * 0x0a, 0x80 2866fcec570bSAlex Deucher * 0x09, 0x30 2867fcec570bSAlex Deucher * 0x0c, 0xc9 2868fcec570bSAlex Deucher * 0x0d, 0x70 2869fcec570bSAlex Deucher * 0x08, 0x32 2870fcec570bSAlex Deucher * 0x08, 0x33 2871fcec570bSAlex Deucher */ 2872fcec570bSAlex Deucher break; 2873fcec570bSAlex Deucher default: 2874fcec570bSAlex Deucher break; 2875fcec570bSAlex Deucher } 2876fcec570bSAlex Deucher 2877fcec570bSAlex Deucher } 2878fcec570bSAlex Deucher 2879fcec570bSAlex Deucher bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder) 2880fcec570bSAlex Deucher { 2881fcec570bSAlex Deucher struct drm_device *dev = encoder->dev; 2882fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 2883fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2884fcec570bSAlex Deucher uint16_t offset; 2885fcec570bSAlex Deucher uint8_t blocks, slave_addr, rev; 2886fcec570bSAlex Deucher uint32_t index, id; 2887fcec570bSAlex Deucher uint32_t reg, val, and_mask, or_mask; 2888fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2889fcec570bSAlex Deucher 2890fcec570bSAlex Deucher if (!tmds) 2891fcec570bSAlex Deucher return false; 2892fcec570bSAlex Deucher 2893fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2894fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE); 2895fcec570bSAlex Deucher rev = RBIOS8(offset); 2896fcec570bSAlex Deucher if (offset) { 2897fcec570bSAlex Deucher rev = RBIOS8(offset); 2898fcec570bSAlex Deucher if (rev > 1) { 2899fcec570bSAlex Deucher blocks = RBIOS8(offset + 3); 2900fcec570bSAlex Deucher index = offset + 4; 2901fcec570bSAlex Deucher while (blocks > 0) { 2902fcec570bSAlex Deucher id = RBIOS16(index); 2903fcec570bSAlex Deucher index += 2; 2904fcec570bSAlex Deucher switch (id >> 13) { 2905fcec570bSAlex Deucher case 0: 2906fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2907fcec570bSAlex Deucher val = RBIOS32(index); 2908fcec570bSAlex Deucher index += 4; 2909fcec570bSAlex Deucher WREG32(reg, val); 2910fcec570bSAlex Deucher break; 2911fcec570bSAlex Deucher case 2: 2912fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2913fcec570bSAlex Deucher and_mask = RBIOS32(index); 2914fcec570bSAlex Deucher index += 4; 2915fcec570bSAlex Deucher or_mask = RBIOS32(index); 2916fcec570bSAlex Deucher index += 4; 2917fcec570bSAlex Deucher val = RREG32(reg); 2918fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2919fcec570bSAlex Deucher WREG32(reg, val); 2920fcec570bSAlex Deucher break; 2921fcec570bSAlex Deucher case 3: 2922fcec570bSAlex Deucher val = RBIOS16(index); 2923fcec570bSAlex Deucher index += 2; 2924fcec570bSAlex Deucher udelay(val); 2925fcec570bSAlex Deucher break; 2926fcec570bSAlex Deucher case 4: 2927fcec570bSAlex Deucher val = RBIOS16(index); 2928fcec570bSAlex Deucher index += 2; 29294de833c3SArnd Bergmann mdelay(val); 2930fcec570bSAlex Deucher break; 2931fcec570bSAlex Deucher case 6: 2932fcec570bSAlex Deucher slave_addr = id & 0xff; 2933fcec570bSAlex Deucher slave_addr >>= 1; /* 7 bit addressing */ 2934fcec570bSAlex Deucher index++; 2935fcec570bSAlex Deucher reg = RBIOS8(index); 2936fcec570bSAlex Deucher index++; 2937fcec570bSAlex Deucher val = RBIOS8(index); 2938fcec570bSAlex Deucher index++; 29395a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2940fcec570bSAlex Deucher slave_addr, 2941fcec570bSAlex Deucher reg, val); 2942fcec570bSAlex Deucher break; 2943fcec570bSAlex Deucher default: 2944fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2945fcec570bSAlex Deucher break; 2946fcec570bSAlex Deucher } 2947fcec570bSAlex Deucher blocks--; 2948fcec570bSAlex Deucher } 2949fcec570bSAlex Deucher return true; 2950fcec570bSAlex Deucher } 2951fcec570bSAlex Deucher } 2952fcec570bSAlex Deucher } else { 2953fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2954fcec570bSAlex Deucher if (offset) { 2955fcec570bSAlex Deucher index = offset + 10; 2956fcec570bSAlex Deucher id = RBIOS16(index); 2957fcec570bSAlex Deucher while (id != 0xffff) { 2958fcec570bSAlex Deucher index += 2; 2959fcec570bSAlex Deucher switch (id >> 13) { 2960fcec570bSAlex Deucher case 0: 2961fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2962fcec570bSAlex Deucher val = RBIOS32(index); 2963fcec570bSAlex Deucher WREG32(reg, val); 2964fcec570bSAlex Deucher break; 2965fcec570bSAlex Deucher case 2: 2966fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2967fcec570bSAlex Deucher and_mask = RBIOS32(index); 2968fcec570bSAlex Deucher index += 4; 2969fcec570bSAlex Deucher or_mask = RBIOS32(index); 2970fcec570bSAlex Deucher index += 4; 2971fcec570bSAlex Deucher val = RREG32(reg); 2972fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2973fcec570bSAlex Deucher WREG32(reg, val); 2974fcec570bSAlex Deucher break; 2975fcec570bSAlex Deucher case 4: 2976fcec570bSAlex Deucher val = RBIOS16(index); 2977fcec570bSAlex Deucher index += 2; 2978fcec570bSAlex Deucher udelay(val); 2979fcec570bSAlex Deucher break; 2980fcec570bSAlex Deucher case 5: 2981fcec570bSAlex Deucher reg = id & 0x1fff; 2982fcec570bSAlex Deucher and_mask = RBIOS32(index); 2983fcec570bSAlex Deucher index += 4; 2984fcec570bSAlex Deucher or_mask = RBIOS32(index); 2985fcec570bSAlex Deucher index += 4; 2986fcec570bSAlex Deucher val = RREG32_PLL(reg); 2987fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2988fcec570bSAlex Deucher WREG32_PLL(reg, val); 2989fcec570bSAlex Deucher break; 2990fcec570bSAlex Deucher case 6: 2991fcec570bSAlex Deucher reg = id & 0x1fff; 2992fcec570bSAlex Deucher val = RBIOS8(index); 2993fcec570bSAlex Deucher index += 1; 29945a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2995fcec570bSAlex Deucher tmds->slave_addr, 2996fcec570bSAlex Deucher reg, val); 2997fcec570bSAlex Deucher break; 2998fcec570bSAlex Deucher default: 2999fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 3000fcec570bSAlex Deucher break; 3001fcec570bSAlex Deucher } 3002fcec570bSAlex Deucher id = RBIOS16(index); 3003fcec570bSAlex Deucher } 3004fcec570bSAlex Deucher return true; 3005fcec570bSAlex Deucher } 3006fcec570bSAlex Deucher } 3007fcec570bSAlex Deucher return false; 3008fcec570bSAlex Deucher } 3009fcec570bSAlex Deucher 3010771fe6b9SJerome Glisse static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset) 3011771fe6b9SJerome Glisse { 3012771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3013771fe6b9SJerome Glisse 3014771fe6b9SJerome Glisse if (offset) { 3015771fe6b9SJerome Glisse while (RBIOS16(offset)) { 3016771fe6b9SJerome Glisse uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13); 3017771fe6b9SJerome Glisse uint32_t addr = (RBIOS16(offset) & 0x1fff); 3018771fe6b9SJerome Glisse uint32_t val, and_mask, or_mask; 3019771fe6b9SJerome Glisse uint32_t tmp; 3020771fe6b9SJerome Glisse 3021771fe6b9SJerome Glisse offset += 2; 3022771fe6b9SJerome Glisse switch (cmd) { 3023771fe6b9SJerome Glisse case 0: 3024771fe6b9SJerome Glisse val = RBIOS32(offset); 3025771fe6b9SJerome Glisse offset += 4; 3026771fe6b9SJerome Glisse WREG32(addr, val); 3027771fe6b9SJerome Glisse break; 3028771fe6b9SJerome Glisse case 1: 3029771fe6b9SJerome Glisse val = RBIOS32(offset); 3030771fe6b9SJerome Glisse offset += 4; 3031771fe6b9SJerome Glisse WREG32(addr, val); 3032771fe6b9SJerome Glisse break; 3033771fe6b9SJerome Glisse case 2: 3034771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 3035771fe6b9SJerome Glisse offset += 4; 3036771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 3037771fe6b9SJerome Glisse offset += 4; 3038771fe6b9SJerome Glisse tmp = RREG32(addr); 3039771fe6b9SJerome Glisse tmp &= and_mask; 3040771fe6b9SJerome Glisse tmp |= or_mask; 3041771fe6b9SJerome Glisse WREG32(addr, tmp); 3042771fe6b9SJerome Glisse break; 3043771fe6b9SJerome Glisse case 3: 3044771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 3045771fe6b9SJerome Glisse offset += 4; 3046771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 3047771fe6b9SJerome Glisse offset += 4; 3048771fe6b9SJerome Glisse tmp = RREG32(addr); 3049771fe6b9SJerome Glisse tmp &= and_mask; 3050771fe6b9SJerome Glisse tmp |= or_mask; 3051771fe6b9SJerome Glisse WREG32(addr, tmp); 3052771fe6b9SJerome Glisse break; 3053771fe6b9SJerome Glisse case 4: 3054771fe6b9SJerome Glisse val = RBIOS16(offset); 3055771fe6b9SJerome Glisse offset += 2; 3056771fe6b9SJerome Glisse udelay(val); 3057771fe6b9SJerome Glisse break; 3058771fe6b9SJerome Glisse case 5: 3059771fe6b9SJerome Glisse val = RBIOS16(offset); 3060771fe6b9SJerome Glisse offset += 2; 3061771fe6b9SJerome Glisse switch (addr) { 3062771fe6b9SJerome Glisse case 8: 3063771fe6b9SJerome Glisse while (val--) { 3064771fe6b9SJerome Glisse if (! 3065771fe6b9SJerome Glisse (RREG32_PLL 3066771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 3067771fe6b9SJerome Glisse RADEON_MC_BUSY)) 3068771fe6b9SJerome Glisse break; 3069771fe6b9SJerome Glisse } 3070771fe6b9SJerome Glisse break; 3071771fe6b9SJerome Glisse case 9: 3072771fe6b9SJerome Glisse while (val--) { 3073771fe6b9SJerome Glisse if ((RREG32(RADEON_MC_STATUS) & 3074771fe6b9SJerome Glisse RADEON_MC_IDLE)) 3075771fe6b9SJerome Glisse break; 3076771fe6b9SJerome Glisse } 3077771fe6b9SJerome Glisse break; 3078771fe6b9SJerome Glisse default: 3079771fe6b9SJerome Glisse break; 3080771fe6b9SJerome Glisse } 3081771fe6b9SJerome Glisse break; 3082771fe6b9SJerome Glisse default: 3083771fe6b9SJerome Glisse break; 3084771fe6b9SJerome Glisse } 3085771fe6b9SJerome Glisse } 3086771fe6b9SJerome Glisse } 3087771fe6b9SJerome Glisse } 3088771fe6b9SJerome Glisse 3089771fe6b9SJerome Glisse static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset) 3090771fe6b9SJerome Glisse { 3091771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3092771fe6b9SJerome Glisse 3093771fe6b9SJerome Glisse if (offset) { 3094771fe6b9SJerome Glisse while (RBIOS8(offset)) { 3095771fe6b9SJerome Glisse uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6); 3096771fe6b9SJerome Glisse uint8_t addr = (RBIOS8(offset) & 0x3f); 3097771fe6b9SJerome Glisse uint32_t val, shift, tmp; 3098771fe6b9SJerome Glisse uint32_t and_mask, or_mask; 3099771fe6b9SJerome Glisse 3100771fe6b9SJerome Glisse offset++; 3101771fe6b9SJerome Glisse switch (cmd) { 3102771fe6b9SJerome Glisse case 0: 3103771fe6b9SJerome Glisse val = RBIOS32(offset); 3104771fe6b9SJerome Glisse offset += 4; 3105771fe6b9SJerome Glisse WREG32_PLL(addr, val); 3106771fe6b9SJerome Glisse break; 3107771fe6b9SJerome Glisse case 1: 3108771fe6b9SJerome Glisse shift = RBIOS8(offset) * 8; 3109771fe6b9SJerome Glisse offset++; 3110771fe6b9SJerome Glisse and_mask = RBIOS8(offset) << shift; 3111771fe6b9SJerome Glisse and_mask |= ~(0xff << shift); 3112771fe6b9SJerome Glisse offset++; 3113771fe6b9SJerome Glisse or_mask = RBIOS8(offset) << shift; 3114771fe6b9SJerome Glisse offset++; 3115771fe6b9SJerome Glisse tmp = RREG32_PLL(addr); 3116771fe6b9SJerome Glisse tmp &= and_mask; 3117771fe6b9SJerome Glisse tmp |= or_mask; 3118771fe6b9SJerome Glisse WREG32_PLL(addr, tmp); 3119771fe6b9SJerome Glisse break; 3120771fe6b9SJerome Glisse case 2: 3121771fe6b9SJerome Glisse case 3: 3122771fe6b9SJerome Glisse tmp = 1000; 3123771fe6b9SJerome Glisse switch (addr) { 3124771fe6b9SJerome Glisse case 1: 3125771fe6b9SJerome Glisse udelay(150); 3126771fe6b9SJerome Glisse break; 3127771fe6b9SJerome Glisse case 2: 31284de833c3SArnd Bergmann mdelay(1); 3129771fe6b9SJerome Glisse break; 3130771fe6b9SJerome Glisse case 3: 3131771fe6b9SJerome Glisse while (tmp--) { 3132771fe6b9SJerome Glisse if (! 3133771fe6b9SJerome Glisse (RREG32_PLL 3134771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 3135771fe6b9SJerome Glisse RADEON_MC_BUSY)) 3136771fe6b9SJerome Glisse break; 3137771fe6b9SJerome Glisse } 3138771fe6b9SJerome Glisse break; 3139771fe6b9SJerome Glisse case 4: 3140771fe6b9SJerome Glisse while (tmp--) { 3141771fe6b9SJerome Glisse if (RREG32_PLL 3142771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 3143771fe6b9SJerome Glisse RADEON_DLL_READY) 3144771fe6b9SJerome Glisse break; 3145771fe6b9SJerome Glisse } 3146771fe6b9SJerome Glisse break; 3147771fe6b9SJerome Glisse case 5: 3148771fe6b9SJerome Glisse tmp = 3149771fe6b9SJerome Glisse RREG32_PLL(RADEON_CLK_PWRMGT_CNTL); 3150771fe6b9SJerome Glisse if (tmp & RADEON_CG_NO1_DEBUG_0) { 3151771fe6b9SJerome Glisse #if 0 3152771fe6b9SJerome Glisse uint32_t mclk_cntl = 3153771fe6b9SJerome Glisse RREG32_PLL 3154771fe6b9SJerome Glisse (RADEON_MCLK_CNTL); 3155771fe6b9SJerome Glisse mclk_cntl &= 0xffff0000; 3156771fe6b9SJerome Glisse /*mclk_cntl |= 0x00001111;*//* ??? */ 3157771fe6b9SJerome Glisse WREG32_PLL(RADEON_MCLK_CNTL, 3158771fe6b9SJerome Glisse mclk_cntl); 31594de833c3SArnd Bergmann mdelay(10); 3160771fe6b9SJerome Glisse #endif 3161771fe6b9SJerome Glisse WREG32_PLL 3162771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL, 3163771fe6b9SJerome Glisse tmp & 3164771fe6b9SJerome Glisse ~RADEON_CG_NO1_DEBUG_0); 31654de833c3SArnd Bergmann mdelay(10); 3166771fe6b9SJerome Glisse } 3167771fe6b9SJerome Glisse break; 3168771fe6b9SJerome Glisse default: 3169771fe6b9SJerome Glisse break; 3170771fe6b9SJerome Glisse } 3171771fe6b9SJerome Glisse break; 3172771fe6b9SJerome Glisse default: 3173771fe6b9SJerome Glisse break; 3174771fe6b9SJerome Glisse } 3175771fe6b9SJerome Glisse } 3176771fe6b9SJerome Glisse } 3177771fe6b9SJerome Glisse } 3178771fe6b9SJerome Glisse 3179771fe6b9SJerome Glisse static void combios_parse_ram_reset_table(struct drm_device *dev, 3180771fe6b9SJerome Glisse uint16_t offset) 3181771fe6b9SJerome Glisse { 3182771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3183771fe6b9SJerome Glisse uint32_t tmp; 3184771fe6b9SJerome Glisse 3185771fe6b9SJerome Glisse if (offset) { 3186771fe6b9SJerome Glisse uint8_t val = RBIOS8(offset); 3187771fe6b9SJerome Glisse while (val != 0xff) { 3188771fe6b9SJerome Glisse offset++; 3189771fe6b9SJerome Glisse 3190771fe6b9SJerome Glisse if (val == 0x0f) { 3191771fe6b9SJerome Glisse uint32_t channel_complete_mask; 3192771fe6b9SJerome Glisse 3193771fe6b9SJerome Glisse if (ASIC_IS_R300(rdev)) 3194771fe6b9SJerome Glisse channel_complete_mask = 3195771fe6b9SJerome Glisse R300_MEM_PWRUP_COMPLETE; 3196771fe6b9SJerome Glisse else 3197771fe6b9SJerome Glisse channel_complete_mask = 3198771fe6b9SJerome Glisse RADEON_MEM_PWRUP_COMPLETE; 3199771fe6b9SJerome Glisse tmp = 20000; 3200771fe6b9SJerome Glisse while (tmp--) { 3201771fe6b9SJerome Glisse if ((RREG32(RADEON_MEM_STR_CNTL) & 3202771fe6b9SJerome Glisse channel_complete_mask) == 3203771fe6b9SJerome Glisse channel_complete_mask) 3204771fe6b9SJerome Glisse break; 3205771fe6b9SJerome Glisse } 3206771fe6b9SJerome Glisse } else { 3207771fe6b9SJerome Glisse uint32_t or_mask = RBIOS16(offset); 3208771fe6b9SJerome Glisse offset += 2; 3209771fe6b9SJerome Glisse 3210771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 3211771fe6b9SJerome Glisse tmp &= RADEON_SDRAM_MODE_MASK; 3212771fe6b9SJerome Glisse tmp |= or_mask; 3213771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 3214771fe6b9SJerome Glisse 3215771fe6b9SJerome Glisse or_mask = val << 24; 3216771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 3217771fe6b9SJerome Glisse tmp &= RADEON_B3MEM_RESET_MASK; 3218771fe6b9SJerome Glisse tmp |= or_mask; 3219771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 3220771fe6b9SJerome Glisse } 3221771fe6b9SJerome Glisse val = RBIOS8(offset); 3222771fe6b9SJerome Glisse } 3223771fe6b9SJerome Glisse } 3224771fe6b9SJerome Glisse } 3225771fe6b9SJerome Glisse 3226771fe6b9SJerome Glisse static uint32_t combios_detect_ram(struct drm_device *dev, int ram, 3227771fe6b9SJerome Glisse int mem_addr_mapping) 3228771fe6b9SJerome Glisse { 3229771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3230771fe6b9SJerome Glisse uint32_t mem_cntl; 3231771fe6b9SJerome Glisse uint32_t mem_size; 3232771fe6b9SJerome Glisse uint32_t addr = 0; 3233771fe6b9SJerome Glisse 3234771fe6b9SJerome Glisse mem_cntl = RREG32(RADEON_MEM_CNTL); 3235771fe6b9SJerome Glisse if (mem_cntl & RV100_HALF_MODE) 3236771fe6b9SJerome Glisse ram /= 2; 3237771fe6b9SJerome Glisse mem_size = ram; 3238771fe6b9SJerome Glisse mem_cntl &= ~(0xff << 8); 3239771fe6b9SJerome Glisse mem_cntl |= (mem_addr_mapping & 0xff) << 8; 3240771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 3241771fe6b9SJerome Glisse RREG32(RADEON_MEM_CNTL); 3242771fe6b9SJerome Glisse 3243771fe6b9SJerome Glisse /* sdram reset ? */ 3244771fe6b9SJerome Glisse 3245771fe6b9SJerome Glisse /* something like this???? */ 3246771fe6b9SJerome Glisse while (ram--) { 3247771fe6b9SJerome Glisse addr = ram * 1024 * 1024; 3248771fe6b9SJerome Glisse /* write to each page */ 32492ef9bdfeSDaniel Vetter WREG32_IDX((addr) | RADEON_MM_APER, 0xdeadbeef); 3250771fe6b9SJerome Glisse /* read back and verify */ 32512ef9bdfeSDaniel Vetter if (RREG32_IDX((addr) | RADEON_MM_APER) != 0xdeadbeef) 3252771fe6b9SJerome Glisse return 0; 3253771fe6b9SJerome Glisse } 3254771fe6b9SJerome Glisse 3255771fe6b9SJerome Glisse return mem_size; 3256771fe6b9SJerome Glisse } 3257771fe6b9SJerome Glisse 3258771fe6b9SJerome Glisse static void combios_write_ram_size(struct drm_device *dev) 3259771fe6b9SJerome Glisse { 3260771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3261771fe6b9SJerome Glisse uint8_t rev; 3262771fe6b9SJerome Glisse uint16_t offset; 3263771fe6b9SJerome Glisse uint32_t mem_size = 0; 3264771fe6b9SJerome Glisse uint32_t mem_cntl = 0; 3265771fe6b9SJerome Glisse 3266771fe6b9SJerome Glisse /* should do something smarter here I guess... */ 3267771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_IGP) 3268771fe6b9SJerome Glisse return; 3269771fe6b9SJerome Glisse 3270771fe6b9SJerome Glisse /* first check detected mem table */ 3271771fe6b9SJerome Glisse offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE); 3272771fe6b9SJerome Glisse if (offset) { 3273771fe6b9SJerome Glisse rev = RBIOS8(offset); 3274771fe6b9SJerome Glisse if (rev < 3) { 3275771fe6b9SJerome Glisse mem_cntl = RBIOS32(offset + 1); 3276771fe6b9SJerome Glisse mem_size = RBIOS16(offset + 5); 32774ce9198eSAlex Deucher if ((rdev->family < CHIP_R200) && 32784ce9198eSAlex Deucher !ASIC_IS_RN50(rdev)) 3279771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 3280771fe6b9SJerome Glisse } 3281771fe6b9SJerome Glisse } 3282771fe6b9SJerome Glisse 3283771fe6b9SJerome Glisse if (!mem_size) { 3284771fe6b9SJerome Glisse offset = 3285771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 3286771fe6b9SJerome Glisse if (offset) { 3287771fe6b9SJerome Glisse rev = RBIOS8(offset - 1); 3288771fe6b9SJerome Glisse if (rev < 1) { 32894ce9198eSAlex Deucher if ((rdev->family < CHIP_R200) 32904ce9198eSAlex Deucher && !ASIC_IS_RN50(rdev)) { 3291771fe6b9SJerome Glisse int ram = 0; 3292771fe6b9SJerome Glisse int mem_addr_mapping = 0; 3293771fe6b9SJerome Glisse 3294771fe6b9SJerome Glisse while (RBIOS8(offset)) { 3295771fe6b9SJerome Glisse ram = RBIOS8(offset); 3296771fe6b9SJerome Glisse mem_addr_mapping = 3297771fe6b9SJerome Glisse RBIOS8(offset + 1); 3298771fe6b9SJerome Glisse if (mem_addr_mapping != 0x25) 3299771fe6b9SJerome Glisse ram *= 2; 3300771fe6b9SJerome Glisse mem_size = 3301771fe6b9SJerome Glisse combios_detect_ram(dev, ram, 3302771fe6b9SJerome Glisse mem_addr_mapping); 3303771fe6b9SJerome Glisse if (mem_size) 3304771fe6b9SJerome Glisse break; 3305771fe6b9SJerome Glisse offset += 2; 3306771fe6b9SJerome Glisse } 3307771fe6b9SJerome Glisse } else 3308771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 3309771fe6b9SJerome Glisse } else { 3310771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 3311771fe6b9SJerome Glisse mem_size *= 2; /* convert to MB */ 3312771fe6b9SJerome Glisse } 3313771fe6b9SJerome Glisse } 3314771fe6b9SJerome Glisse } 3315771fe6b9SJerome Glisse 3316771fe6b9SJerome Glisse mem_size *= (1024 * 1024); /* convert to bytes */ 3317771fe6b9SJerome Glisse WREG32(RADEON_CONFIG_MEMSIZE, mem_size); 3318771fe6b9SJerome Glisse } 3319771fe6b9SJerome Glisse 3320771fe6b9SJerome Glisse void radeon_combios_asic_init(struct drm_device *dev) 3321771fe6b9SJerome Glisse { 3322771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3323771fe6b9SJerome Glisse uint16_t table; 3324771fe6b9SJerome Glisse 3325771fe6b9SJerome Glisse /* port hardcoded mac stuff from radeonfb */ 3326771fe6b9SJerome Glisse if (rdev->bios == NULL) 3327771fe6b9SJerome Glisse return; 3328771fe6b9SJerome Glisse 3329771fe6b9SJerome Glisse /* ASIC INIT 1 */ 3330771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE); 3331771fe6b9SJerome Glisse if (table) 3332771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3333771fe6b9SJerome Glisse 3334771fe6b9SJerome Glisse /* PLL INIT */ 3335771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE); 3336771fe6b9SJerome Glisse if (table) 3337771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 3338771fe6b9SJerome Glisse 3339771fe6b9SJerome Glisse /* ASIC INIT 2 */ 3340771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE); 3341771fe6b9SJerome Glisse if (table) 3342771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3343771fe6b9SJerome Glisse 3344771fe6b9SJerome Glisse if (!(rdev->flags & RADEON_IS_IGP)) { 3345771fe6b9SJerome Glisse /* ASIC INIT 4 */ 3346771fe6b9SJerome Glisse table = 3347771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE); 3348771fe6b9SJerome Glisse if (table) 3349771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3350771fe6b9SJerome Glisse 3351771fe6b9SJerome Glisse /* RAM RESET */ 3352771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE); 3353771fe6b9SJerome Glisse if (table) 3354771fe6b9SJerome Glisse combios_parse_ram_reset_table(dev, table); 3355771fe6b9SJerome Glisse 3356771fe6b9SJerome Glisse /* ASIC INIT 3 */ 3357771fe6b9SJerome Glisse table = 3358771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE); 3359771fe6b9SJerome Glisse if (table) 3360771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3361771fe6b9SJerome Glisse 3362771fe6b9SJerome Glisse /* write CONFIG_MEMSIZE */ 3363771fe6b9SJerome Glisse combios_write_ram_size(dev); 3364771fe6b9SJerome Glisse } 3365771fe6b9SJerome Glisse 3366580b4fffSDave Airlie /* quirk for rs4xx HP nx6125 laptop to make it resume 3367580b4fffSDave Airlie * - it hangs on resume inside the dynclk 1 table. 3368580b4fffSDave Airlie */ 3369580b4fffSDave Airlie if (rdev->family == CHIP_RS480 && 3370580b4fffSDave Airlie rdev->pdev->subsystem_vendor == 0x103c && 3371580b4fffSDave Airlie rdev->pdev->subsystem_device == 0x308b) 3372580b4fffSDave Airlie return; 3373580b4fffSDave Airlie 337452fa2bbcSAlex Deucher /* quirk for rs4xx HP dv5000 laptop to make it resume 337552fa2bbcSAlex Deucher * - it hangs on resume inside the dynclk 1 table. 337652fa2bbcSAlex Deucher */ 337752fa2bbcSAlex Deucher if (rdev->family == CHIP_RS480 && 337852fa2bbcSAlex Deucher rdev->pdev->subsystem_vendor == 0x103c && 337952fa2bbcSAlex Deucher rdev->pdev->subsystem_device == 0x30a4) 338052fa2bbcSAlex Deucher return; 338152fa2bbcSAlex Deucher 3382302a8e8bSAlex Deucher /* quirk for rs4xx Compaq Presario V5245EU laptop to make it resume 3383302a8e8bSAlex Deucher * - it hangs on resume inside the dynclk 1 table. 3384302a8e8bSAlex Deucher */ 3385302a8e8bSAlex Deucher if (rdev->family == CHIP_RS480 && 3386302a8e8bSAlex Deucher rdev->pdev->subsystem_vendor == 0x103c && 3387302a8e8bSAlex Deucher rdev->pdev->subsystem_device == 0x30ae) 3388302a8e8bSAlex Deucher return; 3389302a8e8bSAlex Deucher 3390771fe6b9SJerome Glisse /* DYN CLK 1 */ 3391771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 3392771fe6b9SJerome Glisse if (table) 3393771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 3394771fe6b9SJerome Glisse 3395771fe6b9SJerome Glisse } 3396771fe6b9SJerome Glisse 3397771fe6b9SJerome Glisse void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev) 3398771fe6b9SJerome Glisse { 3399771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3400771fe6b9SJerome Glisse uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch; 3401771fe6b9SJerome Glisse 3402771fe6b9SJerome Glisse bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); 3403771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3404771fe6b9SJerome Glisse bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH); 3405771fe6b9SJerome Glisse 3406771fe6b9SJerome Glisse /* let the bios control the backlight */ 3407771fe6b9SJerome Glisse bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN; 3408771fe6b9SJerome Glisse 3409771fe6b9SJerome Glisse /* tell the bios not to handle mode switching */ 3410771fe6b9SJerome Glisse bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS | 3411771fe6b9SJerome Glisse RADEON_ACC_MODE_CHANGE); 3412771fe6b9SJerome Glisse 3413771fe6b9SJerome Glisse /* tell the bios a driver is loaded */ 3414771fe6b9SJerome Glisse bios_7_scratch |= RADEON_DRV_LOADED; 3415771fe6b9SJerome Glisse 3416771fe6b9SJerome Glisse WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch); 3417771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3418771fe6b9SJerome Glisse WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch); 3419771fe6b9SJerome Glisse } 3420771fe6b9SJerome Glisse 3421771fe6b9SJerome Glisse void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock) 3422771fe6b9SJerome Glisse { 3423771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3424771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3425771fe6b9SJerome Glisse uint32_t bios_6_scratch; 3426771fe6b9SJerome Glisse 3427771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3428771fe6b9SJerome Glisse 3429771fe6b9SJerome Glisse if (lock) 3430771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DRIVER_CRITICAL; 3431771fe6b9SJerome Glisse else 3432771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DRIVER_CRITICAL; 3433771fe6b9SJerome Glisse 3434771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3435771fe6b9SJerome Glisse } 3436771fe6b9SJerome Glisse 3437771fe6b9SJerome Glisse void 3438771fe6b9SJerome Glisse radeon_combios_connected_scratch_regs(struct drm_connector *connector, 3439771fe6b9SJerome Glisse struct drm_encoder *encoder, 3440771fe6b9SJerome Glisse bool connected) 3441771fe6b9SJerome Glisse { 3442771fe6b9SJerome Glisse struct drm_device *dev = connector->dev; 3443771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3444771fe6b9SJerome Glisse struct radeon_connector *radeon_connector = 3445771fe6b9SJerome Glisse to_radeon_connector(connector); 3446771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3447771fe6b9SJerome Glisse uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH); 3448771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3449771fe6b9SJerome Glisse 3450771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) && 3451771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) { 3452771fe6b9SJerome Glisse if (connected) { 3453d9fdaafbSDave Airlie DRM_DEBUG_KMS("TV1 connected\n"); 3454771fe6b9SJerome Glisse /* fix me */ 3455771fe6b9SJerome Glisse bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO; 3456771fe6b9SJerome Glisse /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */ 3457771fe6b9SJerome Glisse bios_5_scratch |= RADEON_TV1_ON; 3458771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_TV1; 3459771fe6b9SJerome Glisse } else { 3460d9fdaafbSDave Airlie DRM_DEBUG_KMS("TV1 disconnected\n"); 3461771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK; 3462771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_ON; 3463771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_TV1; 3464771fe6b9SJerome Glisse } 3465771fe6b9SJerome Glisse } 3466771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) && 3467771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) { 3468771fe6b9SJerome Glisse if (connected) { 3469d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD1 connected\n"); 3470771fe6b9SJerome Glisse bios_4_scratch |= RADEON_LCD1_ATTACHED; 3471771fe6b9SJerome Glisse bios_5_scratch |= RADEON_LCD1_ON; 3472771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_LCD1; 3473771fe6b9SJerome Glisse } else { 3474d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD1 disconnected\n"); 3475771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_LCD1_ATTACHED; 3476771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_ON; 3477771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_LCD1; 3478771fe6b9SJerome Glisse } 3479771fe6b9SJerome Glisse } 3480771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) && 3481771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) { 3482771fe6b9SJerome Glisse if (connected) { 3483d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT1 connected\n"); 3484771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR; 3485771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT1_ON; 3486771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT1; 3487771fe6b9SJerome Glisse } else { 3488d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT1 disconnected\n"); 3489771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK; 3490771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_ON; 3491771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT1; 3492771fe6b9SJerome Glisse } 3493771fe6b9SJerome Glisse } 3494771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) && 3495771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) { 3496771fe6b9SJerome Glisse if (connected) { 3497d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT2 connected\n"); 3498771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR; 3499771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT2_ON; 3500771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT2; 3501771fe6b9SJerome Glisse } else { 3502d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT2 disconnected\n"); 3503771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK; 3504771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_ON; 3505771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT2; 3506771fe6b9SJerome Glisse } 3507771fe6b9SJerome Glisse } 3508771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) && 3509771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) { 3510771fe6b9SJerome Glisse if (connected) { 3511d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP1 connected\n"); 3512771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP1_ATTACHED; 3513771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP1_ON; 3514771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP1; 3515771fe6b9SJerome Glisse } else { 3516d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP1 disconnected\n"); 3517771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP1_ATTACHED; 3518771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_ON; 3519771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP1; 3520771fe6b9SJerome Glisse } 3521771fe6b9SJerome Glisse } 3522771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) && 3523771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) { 3524771fe6b9SJerome Glisse if (connected) { 3525d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP2 connected\n"); 3526771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP2_ATTACHED; 3527771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP2_ON; 3528771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP2; 3529771fe6b9SJerome Glisse } else { 3530d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP2 disconnected\n"); 3531771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP2_ATTACHED; 3532771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_ON; 3533771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP2; 3534771fe6b9SJerome Glisse } 3535771fe6b9SJerome Glisse } 3536771fe6b9SJerome Glisse WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch); 3537771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3538771fe6b9SJerome Glisse } 3539771fe6b9SJerome Glisse 3540771fe6b9SJerome Glisse void 3541771fe6b9SJerome Glisse radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc) 3542771fe6b9SJerome Glisse { 3543771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3544771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3545771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3546771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3547771fe6b9SJerome Glisse 3548771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { 3549771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_CRTC_MASK; 3550771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT); 3551771fe6b9SJerome Glisse } 3552771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { 3553771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK; 3554771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT); 3555771fe6b9SJerome Glisse } 3556771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { 3557771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK; 3558771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT); 3559771fe6b9SJerome Glisse } 3560771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { 3561771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK; 3562771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT); 3563771fe6b9SJerome Glisse } 3564771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { 3565771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK; 3566771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT); 3567771fe6b9SJerome Glisse } 3568771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { 3569771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK; 3570771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT); 3571771fe6b9SJerome Glisse } 3572771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3573771fe6b9SJerome Glisse } 3574771fe6b9SJerome Glisse 3575771fe6b9SJerome Glisse void 3576771fe6b9SJerome Glisse radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on) 3577771fe6b9SJerome Glisse { 3578771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3579771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3580771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3581771fe6b9SJerome Glisse uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3582771fe6b9SJerome Glisse 3583771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { 3584771fe6b9SJerome Glisse if (on) 3585771fe6b9SJerome Glisse bios_6_scratch |= RADEON_TV_DPMS_ON; 3586771fe6b9SJerome Glisse else 3587771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_TV_DPMS_ON; 3588771fe6b9SJerome Glisse } 3589771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) { 3590771fe6b9SJerome Glisse if (on) 3591771fe6b9SJerome Glisse bios_6_scratch |= RADEON_CRT_DPMS_ON; 3592771fe6b9SJerome Glisse else 3593771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_CRT_DPMS_ON; 3594771fe6b9SJerome Glisse } 3595771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 3596771fe6b9SJerome Glisse if (on) 3597771fe6b9SJerome Glisse bios_6_scratch |= RADEON_LCD_DPMS_ON; 3598771fe6b9SJerome Glisse else 3599771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_LCD_DPMS_ON; 3600771fe6b9SJerome Glisse } 3601771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 3602771fe6b9SJerome Glisse if (on) 3603771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DFP_DPMS_ON; 3604771fe6b9SJerome Glisse else 3605771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DFP_DPMS_ON; 3606771fe6b9SJerome Glisse } 3607771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3608771fe6b9SJerome Glisse } 3609