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 */ 27f9183127SSam Ravnborg 282ef79416SThomas Zimmermann #include <linux/pci.h> 292ef79416SThomas Zimmermann 30f9183127SSam Ravnborg #include <drm/drm_device.h> 31760285e7SDavid Howells #include <drm/radeon_drm.h> 32f9183127SSam Ravnborg 33771fe6b9SJerome Glisse #include "radeon.h" 347ddfba01SLee Jones #include "radeon_legacy_encoders.h" 35771fe6b9SJerome Glisse #include "atom.h" 36771fe6b9SJerome Glisse 37771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 38771fe6b9SJerome Glisse /* not sure which of these are needed */ 39771fe6b9SJerome Glisse #include <asm/machdep.h> 40771fe6b9SJerome Glisse #include <asm/pmac_feature.h> 41771fe6b9SJerome Glisse #include <asm/prom.h> 42771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 43771fe6b9SJerome Glisse 44771fe6b9SJerome Glisse /* old legacy ATI BIOS routines */ 45771fe6b9SJerome Glisse 46771fe6b9SJerome Glisse /* COMBIOS table offsets */ 47771fe6b9SJerome Glisse enum radeon_combios_table_offset { 48771fe6b9SJerome Glisse /* absolute offset tables */ 49771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_1_TABLE, 50771fe6b9SJerome Glisse COMBIOS_BIOS_SUPPORT_TABLE, 51771fe6b9SJerome Glisse COMBIOS_DAC_PROGRAMMING_TABLE, 52771fe6b9SJerome Glisse COMBIOS_MAX_COLOR_DEPTH_TABLE, 53771fe6b9SJerome Glisse COMBIOS_CRTC_INFO_TABLE, 54771fe6b9SJerome Glisse COMBIOS_PLL_INFO_TABLE, 55771fe6b9SJerome Glisse COMBIOS_TV_INFO_TABLE, 56771fe6b9SJerome Glisse COMBIOS_DFP_INFO_TABLE, 57771fe6b9SJerome Glisse COMBIOS_HW_CONFIG_INFO_TABLE, 58771fe6b9SJerome Glisse COMBIOS_MULTIMEDIA_INFO_TABLE, 59771fe6b9SJerome Glisse COMBIOS_TV_STD_PATCH_TABLE, 60771fe6b9SJerome Glisse COMBIOS_LCD_INFO_TABLE, 61771fe6b9SJerome Glisse COMBIOS_MOBILE_INFO_TABLE, 62771fe6b9SJerome Glisse COMBIOS_PLL_INIT_TABLE, 63771fe6b9SJerome Glisse COMBIOS_MEM_CONFIG_TABLE, 64771fe6b9SJerome Glisse COMBIOS_SAVE_MASK_TABLE, 65771fe6b9SJerome Glisse COMBIOS_HARDCODED_EDID_TABLE, 66771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_2_TABLE, 67771fe6b9SJerome Glisse COMBIOS_CONNECTOR_INFO_TABLE, 68771fe6b9SJerome Glisse COMBIOS_DYN_CLK_1_TABLE, 69771fe6b9SJerome Glisse COMBIOS_RESERVED_MEM_TABLE, 70771fe6b9SJerome Glisse COMBIOS_EXT_TMDS_INFO_TABLE, 71771fe6b9SJerome Glisse COMBIOS_MEM_CLK_INFO_TABLE, 72771fe6b9SJerome Glisse COMBIOS_EXT_DAC_INFO_TABLE, 73771fe6b9SJerome Glisse COMBIOS_MISC_INFO_TABLE, 74771fe6b9SJerome Glisse COMBIOS_CRT_INFO_TABLE, 75771fe6b9SJerome Glisse COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE, 76771fe6b9SJerome Glisse COMBIOS_COMPONENT_VIDEO_INFO_TABLE, 77771fe6b9SJerome Glisse COMBIOS_FAN_SPEED_INFO_TABLE, 78771fe6b9SJerome Glisse COMBIOS_OVERDRIVE_INFO_TABLE, 79771fe6b9SJerome Glisse COMBIOS_OEM_INFO_TABLE, 80771fe6b9SJerome Glisse COMBIOS_DYN_CLK_2_TABLE, 81771fe6b9SJerome Glisse COMBIOS_POWER_CONNECTOR_INFO_TABLE, 82771fe6b9SJerome Glisse COMBIOS_I2C_INFO_TABLE, 83771fe6b9SJerome Glisse /* relative offset tables */ 84771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_3_TABLE, /* offset from misc info */ 85771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_4_TABLE, /* offset from misc info */ 86771fe6b9SJerome Glisse COMBIOS_DETECTED_MEM_TABLE, /* offset from misc info */ 87771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_5_TABLE, /* offset from misc info */ 88771fe6b9SJerome Glisse COMBIOS_RAM_RESET_TABLE, /* offset from mem config */ 89771fe6b9SJerome Glisse COMBIOS_POWERPLAY_INFO_TABLE, /* offset from mobile info */ 90771fe6b9SJerome Glisse COMBIOS_GPIO_INFO_TABLE, /* offset from mobile info */ 91771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE, /* offset from mobile info */ 92771fe6b9SJerome Glisse COMBIOS_TMDS_POWER_TABLE, /* offset from mobile info */ 93771fe6b9SJerome Glisse COMBIOS_TMDS_POWER_ON_TABLE, /* offset from tmds power */ 94771fe6b9SJerome Glisse COMBIOS_TMDS_POWER_OFF_TABLE, /* offset from tmds power */ 95771fe6b9SJerome Glisse }; 96771fe6b9SJerome Glisse 97771fe6b9SJerome Glisse enum radeon_combios_ddc { 98771fe6b9SJerome Glisse DDC_NONE_DETECTED, 99771fe6b9SJerome Glisse DDC_MONID, 100771fe6b9SJerome Glisse DDC_DVI, 101771fe6b9SJerome Glisse DDC_VGA, 102771fe6b9SJerome Glisse DDC_CRT2, 103771fe6b9SJerome Glisse DDC_LCD, 104771fe6b9SJerome Glisse DDC_GPIO, 105771fe6b9SJerome Glisse }; 106771fe6b9SJerome Glisse 107771fe6b9SJerome Glisse enum radeon_combios_connector { 108771fe6b9SJerome Glisse CONNECTOR_NONE_LEGACY, 109771fe6b9SJerome Glisse CONNECTOR_PROPRIETARY_LEGACY, 110771fe6b9SJerome Glisse CONNECTOR_CRT_LEGACY, 111771fe6b9SJerome Glisse CONNECTOR_DVI_I_LEGACY, 112771fe6b9SJerome Glisse CONNECTOR_DVI_D_LEGACY, 113771fe6b9SJerome Glisse CONNECTOR_CTV_LEGACY, 114771fe6b9SJerome Glisse CONNECTOR_STV_LEGACY, 115771fe6b9SJerome Glisse CONNECTOR_UNSUPPORTED_LEGACY 116771fe6b9SJerome Glisse }; 117771fe6b9SJerome Glisse 118080cbcb4SMichele Curti static const int legacy_connector_convert[] = { 119771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_Unknown, 120771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVID, 121771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 122771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 123771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVID, 124771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_Composite, 125771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 126771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_Unknown, 127771fe6b9SJerome Glisse }; 128771fe6b9SJerome Glisse 129771fe6b9SJerome Glisse static uint16_t combios_get_table_offset(struct drm_device *dev, 130771fe6b9SJerome Glisse enum radeon_combios_table_offset table) 131771fe6b9SJerome Glisse { 132771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 133cef1d00cSMark Kettenis int rev, size; 134771fe6b9SJerome Glisse uint16_t offset = 0, check_offset; 135771fe6b9SJerome Glisse 13603047cdfSMichel Dänzer if (!rdev->bios) 13703047cdfSMichel Dänzer return 0; 13803047cdfSMichel Dänzer 139771fe6b9SJerome Glisse switch (table) { 140771fe6b9SJerome Glisse /* absolute offset tables */ 141771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_1_TABLE: 142cef1d00cSMark Kettenis check_offset = 0xc; 143771fe6b9SJerome Glisse break; 144771fe6b9SJerome Glisse case COMBIOS_BIOS_SUPPORT_TABLE: 145cef1d00cSMark Kettenis check_offset = 0x14; 146771fe6b9SJerome Glisse break; 147771fe6b9SJerome Glisse case COMBIOS_DAC_PROGRAMMING_TABLE: 148cef1d00cSMark Kettenis check_offset = 0x2a; 149771fe6b9SJerome Glisse break; 150771fe6b9SJerome Glisse case COMBIOS_MAX_COLOR_DEPTH_TABLE: 151cef1d00cSMark Kettenis check_offset = 0x2c; 152771fe6b9SJerome Glisse break; 153771fe6b9SJerome Glisse case COMBIOS_CRTC_INFO_TABLE: 154cef1d00cSMark Kettenis check_offset = 0x2e; 155771fe6b9SJerome Glisse break; 156771fe6b9SJerome Glisse case COMBIOS_PLL_INFO_TABLE: 157cef1d00cSMark Kettenis check_offset = 0x30; 158771fe6b9SJerome Glisse break; 159771fe6b9SJerome Glisse case COMBIOS_TV_INFO_TABLE: 160cef1d00cSMark Kettenis check_offset = 0x32; 161771fe6b9SJerome Glisse break; 162771fe6b9SJerome Glisse case COMBIOS_DFP_INFO_TABLE: 163cef1d00cSMark Kettenis check_offset = 0x34; 164771fe6b9SJerome Glisse break; 165771fe6b9SJerome Glisse case COMBIOS_HW_CONFIG_INFO_TABLE: 166cef1d00cSMark Kettenis check_offset = 0x36; 167771fe6b9SJerome Glisse break; 168771fe6b9SJerome Glisse case COMBIOS_MULTIMEDIA_INFO_TABLE: 169cef1d00cSMark Kettenis check_offset = 0x38; 170771fe6b9SJerome Glisse break; 171771fe6b9SJerome Glisse case COMBIOS_TV_STD_PATCH_TABLE: 172cef1d00cSMark Kettenis check_offset = 0x3e; 173771fe6b9SJerome Glisse break; 174771fe6b9SJerome Glisse case COMBIOS_LCD_INFO_TABLE: 175cef1d00cSMark Kettenis check_offset = 0x40; 176771fe6b9SJerome Glisse break; 177771fe6b9SJerome Glisse case COMBIOS_MOBILE_INFO_TABLE: 178cef1d00cSMark Kettenis check_offset = 0x42; 179771fe6b9SJerome Glisse break; 180771fe6b9SJerome Glisse case COMBIOS_PLL_INIT_TABLE: 181cef1d00cSMark Kettenis check_offset = 0x46; 182771fe6b9SJerome Glisse break; 183771fe6b9SJerome Glisse case COMBIOS_MEM_CONFIG_TABLE: 184cef1d00cSMark Kettenis check_offset = 0x48; 185771fe6b9SJerome Glisse break; 186771fe6b9SJerome Glisse case COMBIOS_SAVE_MASK_TABLE: 187cef1d00cSMark Kettenis check_offset = 0x4a; 188771fe6b9SJerome Glisse break; 189771fe6b9SJerome Glisse case COMBIOS_HARDCODED_EDID_TABLE: 190cef1d00cSMark Kettenis check_offset = 0x4c; 191771fe6b9SJerome Glisse break; 192771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_2_TABLE: 193cef1d00cSMark Kettenis check_offset = 0x4e; 194771fe6b9SJerome Glisse break; 195771fe6b9SJerome Glisse case COMBIOS_CONNECTOR_INFO_TABLE: 196cef1d00cSMark Kettenis check_offset = 0x50; 197771fe6b9SJerome Glisse break; 198771fe6b9SJerome Glisse case COMBIOS_DYN_CLK_1_TABLE: 199cef1d00cSMark Kettenis check_offset = 0x52; 200771fe6b9SJerome Glisse break; 201771fe6b9SJerome Glisse case COMBIOS_RESERVED_MEM_TABLE: 202cef1d00cSMark Kettenis check_offset = 0x54; 203771fe6b9SJerome Glisse break; 204771fe6b9SJerome Glisse case COMBIOS_EXT_TMDS_INFO_TABLE: 205cef1d00cSMark Kettenis check_offset = 0x58; 206771fe6b9SJerome Glisse break; 207771fe6b9SJerome Glisse case COMBIOS_MEM_CLK_INFO_TABLE: 208cef1d00cSMark Kettenis check_offset = 0x5a; 209771fe6b9SJerome Glisse break; 210771fe6b9SJerome Glisse case COMBIOS_EXT_DAC_INFO_TABLE: 211cef1d00cSMark Kettenis check_offset = 0x5c; 212771fe6b9SJerome Glisse break; 213771fe6b9SJerome Glisse case COMBIOS_MISC_INFO_TABLE: 214cef1d00cSMark Kettenis check_offset = 0x5e; 215771fe6b9SJerome Glisse break; 216771fe6b9SJerome Glisse case COMBIOS_CRT_INFO_TABLE: 217cef1d00cSMark Kettenis check_offset = 0x60; 218771fe6b9SJerome Glisse break; 219771fe6b9SJerome Glisse case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE: 220cef1d00cSMark Kettenis check_offset = 0x62; 221771fe6b9SJerome Glisse break; 222771fe6b9SJerome Glisse case COMBIOS_COMPONENT_VIDEO_INFO_TABLE: 223cef1d00cSMark Kettenis check_offset = 0x64; 224771fe6b9SJerome Glisse break; 225771fe6b9SJerome Glisse case COMBIOS_FAN_SPEED_INFO_TABLE: 226cef1d00cSMark Kettenis check_offset = 0x66; 227771fe6b9SJerome Glisse break; 228771fe6b9SJerome Glisse case COMBIOS_OVERDRIVE_INFO_TABLE: 229cef1d00cSMark Kettenis check_offset = 0x68; 230771fe6b9SJerome Glisse break; 231771fe6b9SJerome Glisse case COMBIOS_OEM_INFO_TABLE: 232cef1d00cSMark Kettenis check_offset = 0x6a; 233771fe6b9SJerome Glisse break; 234771fe6b9SJerome Glisse case COMBIOS_DYN_CLK_2_TABLE: 235cef1d00cSMark Kettenis check_offset = 0x6c; 236771fe6b9SJerome Glisse break; 237771fe6b9SJerome Glisse case COMBIOS_POWER_CONNECTOR_INFO_TABLE: 238cef1d00cSMark Kettenis check_offset = 0x6e; 239771fe6b9SJerome Glisse break; 240771fe6b9SJerome Glisse case COMBIOS_I2C_INFO_TABLE: 241cef1d00cSMark Kettenis check_offset = 0x70; 242771fe6b9SJerome Glisse break; 243771fe6b9SJerome Glisse /* relative offset tables */ 244771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_3_TABLE: /* offset from misc info */ 245771fe6b9SJerome Glisse check_offset = 246771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 247771fe6b9SJerome Glisse if (check_offset) { 248771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 249771fe6b9SJerome Glisse if (rev > 0) { 250771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x3); 251771fe6b9SJerome Glisse if (check_offset) 252771fe6b9SJerome Glisse offset = check_offset; 253771fe6b9SJerome Glisse } 254771fe6b9SJerome Glisse } 255771fe6b9SJerome Glisse break; 256771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_4_TABLE: /* offset from misc info */ 257771fe6b9SJerome Glisse check_offset = 258771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 259771fe6b9SJerome Glisse if (check_offset) { 260771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 261771fe6b9SJerome Glisse if (rev > 0) { 262771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x5); 263771fe6b9SJerome Glisse if (check_offset) 264771fe6b9SJerome Glisse offset = check_offset; 265771fe6b9SJerome Glisse } 266771fe6b9SJerome Glisse } 267771fe6b9SJerome Glisse break; 268771fe6b9SJerome Glisse case COMBIOS_DETECTED_MEM_TABLE: /* offset from misc info */ 269771fe6b9SJerome Glisse check_offset = 270771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 271771fe6b9SJerome Glisse if (check_offset) { 272771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 273771fe6b9SJerome Glisse if (rev > 0) { 274771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x7); 275771fe6b9SJerome Glisse if (check_offset) 276771fe6b9SJerome Glisse offset = check_offset; 277771fe6b9SJerome Glisse } 278771fe6b9SJerome Glisse } 279771fe6b9SJerome Glisse break; 280771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_5_TABLE: /* offset from misc info */ 281771fe6b9SJerome Glisse check_offset = 282771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 283771fe6b9SJerome Glisse if (check_offset) { 284771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 285771fe6b9SJerome Glisse if (rev == 2) { 286771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x9); 287771fe6b9SJerome Glisse if (check_offset) 288771fe6b9SJerome Glisse offset = check_offset; 289771fe6b9SJerome Glisse } 290771fe6b9SJerome Glisse } 291771fe6b9SJerome Glisse break; 292771fe6b9SJerome Glisse case COMBIOS_RAM_RESET_TABLE: /* offset from mem config */ 293771fe6b9SJerome Glisse check_offset = 294771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 295771fe6b9SJerome Glisse if (check_offset) { 296771fe6b9SJerome Glisse while (RBIOS8(check_offset++)); 297771fe6b9SJerome Glisse check_offset += 2; 298771fe6b9SJerome Glisse if (check_offset) 299771fe6b9SJerome Glisse offset = check_offset; 300771fe6b9SJerome Glisse } 301771fe6b9SJerome Glisse break; 302771fe6b9SJerome Glisse case COMBIOS_POWERPLAY_INFO_TABLE: /* offset from mobile info */ 303771fe6b9SJerome Glisse check_offset = 304771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 305771fe6b9SJerome Glisse if (check_offset) { 306771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x11); 307771fe6b9SJerome Glisse if (check_offset) 308771fe6b9SJerome Glisse offset = check_offset; 309771fe6b9SJerome Glisse } 310771fe6b9SJerome Glisse break; 311771fe6b9SJerome Glisse case COMBIOS_GPIO_INFO_TABLE: /* offset from mobile info */ 312771fe6b9SJerome Glisse check_offset = 313771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 314771fe6b9SJerome Glisse if (check_offset) { 315771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x13); 316771fe6b9SJerome Glisse if (check_offset) 317771fe6b9SJerome Glisse offset = check_offset; 318771fe6b9SJerome Glisse } 319771fe6b9SJerome Glisse break; 320771fe6b9SJerome Glisse case COMBIOS_LCD_DDC_INFO_TABLE: /* offset from mobile info */ 321771fe6b9SJerome Glisse check_offset = 322771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 323771fe6b9SJerome Glisse if (check_offset) { 324771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x15); 325771fe6b9SJerome Glisse if (check_offset) 326771fe6b9SJerome Glisse offset = check_offset; 327771fe6b9SJerome Glisse } 328771fe6b9SJerome Glisse break; 329771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_TABLE: /* offset from mobile info */ 330771fe6b9SJerome Glisse check_offset = 331771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 332771fe6b9SJerome Glisse if (check_offset) { 333771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x17); 334771fe6b9SJerome Glisse if (check_offset) 335771fe6b9SJerome Glisse offset = check_offset; 336771fe6b9SJerome Glisse } 337771fe6b9SJerome Glisse break; 338771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_ON_TABLE: /* offset from tmds power */ 339771fe6b9SJerome Glisse check_offset = 340771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); 341771fe6b9SJerome Glisse if (check_offset) { 342771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x2); 343771fe6b9SJerome Glisse if (check_offset) 344771fe6b9SJerome Glisse offset = check_offset; 345771fe6b9SJerome Glisse } 346771fe6b9SJerome Glisse break; 347771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_OFF_TABLE: /* offset from tmds power */ 348771fe6b9SJerome Glisse check_offset = 349771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); 350771fe6b9SJerome Glisse if (check_offset) { 351771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x4); 352771fe6b9SJerome Glisse if (check_offset) 353771fe6b9SJerome Glisse offset = check_offset; 354771fe6b9SJerome Glisse } 355771fe6b9SJerome Glisse break; 356771fe6b9SJerome Glisse default: 357cef1d00cSMark Kettenis check_offset = 0; 358771fe6b9SJerome Glisse break; 359771fe6b9SJerome Glisse } 360771fe6b9SJerome Glisse 361cef1d00cSMark Kettenis size = RBIOS8(rdev->bios_header_start + 0x6); 362cef1d00cSMark Kettenis /* check absolute offset tables */ 363cef1d00cSMark Kettenis if (table < COMBIOS_ASIC_INIT_3_TABLE && check_offset && check_offset < size) 364cef1d00cSMark Kettenis offset = RBIOS16(rdev->bios_header_start + check_offset); 365771fe6b9SJerome Glisse 366cef1d00cSMark Kettenis return offset; 367771fe6b9SJerome Glisse } 368771fe6b9SJerome Glisse 3693c537889SAlex Deucher bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev) 3703c537889SAlex Deucher { 371fafcf94eSAlex Deucher int edid_info, size; 3723c537889SAlex Deucher struct edid *edid; 3737466f4ccSAdam Jackson unsigned char *raw; 3743c537889SAlex Deucher edid_info = combios_get_table_offset(rdev->ddev, COMBIOS_HARDCODED_EDID_TABLE); 3753c537889SAlex Deucher if (!edid_info) 3763c537889SAlex Deucher return false; 3773c537889SAlex Deucher 3787466f4ccSAdam Jackson raw = rdev->bios + edid_info; 379fafcf94eSAlex Deucher size = EDID_LENGTH * (raw[0x7e] + 1); 380fafcf94eSAlex Deucher edid = kmalloc(size, GFP_KERNEL); 3813c537889SAlex Deucher if (edid == NULL) 3823c537889SAlex Deucher return false; 3833c537889SAlex Deucher 384fafcf94eSAlex Deucher memcpy((unsigned char *)edid, raw, size); 3853c537889SAlex Deucher 3863c537889SAlex Deucher if (!drm_edid_is_valid(edid)) { 3873c537889SAlex Deucher kfree(edid); 3883c537889SAlex Deucher return false; 3893c537889SAlex Deucher } 3903c537889SAlex Deucher 3913c537889SAlex Deucher rdev->mode_info.bios_hardcoded_edid = edid; 392fafcf94eSAlex Deucher rdev->mode_info.bios_hardcoded_edid_size = size; 3933c537889SAlex Deucher return true; 3943c537889SAlex Deucher } 3953c537889SAlex Deucher 396c324acd5SAlex Deucher /* this is used for atom LCDs as well */ 3973c537889SAlex Deucher struct edid * 398c324acd5SAlex Deucher radeon_bios_get_hardcoded_edid(struct radeon_device *rdev) 3993c537889SAlex Deucher { 400fafcf94eSAlex Deucher struct edid *edid; 401fafcf94eSAlex Deucher 402fafcf94eSAlex Deucher if (rdev->mode_info.bios_hardcoded_edid) { 403fafcf94eSAlex Deucher edid = kmalloc(rdev->mode_info.bios_hardcoded_edid_size, GFP_KERNEL); 404fafcf94eSAlex Deucher if (edid) { 405fafcf94eSAlex Deucher memcpy((unsigned char *)edid, 406fafcf94eSAlex Deucher (unsigned char *)rdev->mode_info.bios_hardcoded_edid, 407fafcf94eSAlex Deucher rdev->mode_info.bios_hardcoded_edid_size); 408fafcf94eSAlex Deucher return edid; 409fafcf94eSAlex Deucher } 410fafcf94eSAlex Deucher } 4113c537889SAlex Deucher return NULL; 4123c537889SAlex Deucher } 4133c537889SAlex Deucher 4146a93cb25SAlex Deucher static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev, 415179e8078SAlex Deucher enum radeon_combios_ddc ddc, 416179e8078SAlex Deucher u32 clk_mask, 417179e8078SAlex Deucher u32 data_mask) 418771fe6b9SJerome Glisse { 419771fe6b9SJerome Glisse struct radeon_i2c_bus_rec i2c; 420179e8078SAlex Deucher int ddc_line = 0; 421179e8078SAlex Deucher 422179e8078SAlex Deucher /* ddc id = mask reg 423179e8078SAlex Deucher * DDC_NONE_DETECTED = none 424179e8078SAlex Deucher * DDC_DVI = RADEON_GPIO_DVI_DDC 425179e8078SAlex Deucher * DDC_VGA = RADEON_GPIO_VGA_DDC 426179e8078SAlex Deucher * DDC_LCD = RADEON_GPIOPAD_MASK 427179e8078SAlex Deucher * DDC_GPIO = RADEON_MDGPIO_MASK 428508c8d60SAlex Deucher * r1xx 429179e8078SAlex Deucher * DDC_MONID = RADEON_GPIO_MONID 430179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_CRT2_DDC 431508c8d60SAlex Deucher * r200 432179e8078SAlex Deucher * DDC_MONID = RADEON_GPIO_MONID 433179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_DVI_DDC 434508c8d60SAlex Deucher * r300/r350 435508c8d60SAlex Deucher * DDC_MONID = RADEON_GPIO_DVI_DDC 436508c8d60SAlex Deucher * DDC_CRT2 = RADEON_GPIO_DVI_DDC 437508c8d60SAlex Deucher * rv2xx/rv3xx 438508c8d60SAlex Deucher * DDC_MONID = RADEON_GPIO_MONID 439508c8d60SAlex Deucher * DDC_CRT2 = RADEON_GPIO_MONID 440179e8078SAlex Deucher * rs3xx/rs4xx 441179e8078SAlex Deucher * DDC_MONID = RADEON_GPIOPAD_MASK 442179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_MONID 443179e8078SAlex Deucher */ 444179e8078SAlex Deucher switch (ddc) { 445179e8078SAlex Deucher case DDC_NONE_DETECTED: 446179e8078SAlex Deucher default: 447179e8078SAlex Deucher ddc_line = 0; 448179e8078SAlex Deucher break; 449179e8078SAlex Deucher case DDC_DVI: 450179e8078SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 451179e8078SAlex Deucher break; 452179e8078SAlex Deucher case DDC_VGA: 453179e8078SAlex Deucher ddc_line = RADEON_GPIO_VGA_DDC; 454179e8078SAlex Deucher break; 455179e8078SAlex Deucher case DDC_LCD: 456179e8078SAlex Deucher ddc_line = RADEON_GPIOPAD_MASK; 457179e8078SAlex Deucher break; 458179e8078SAlex Deucher case DDC_GPIO: 459179e8078SAlex Deucher ddc_line = RADEON_MDGPIO_MASK; 460179e8078SAlex Deucher break; 461179e8078SAlex Deucher case DDC_MONID: 462179e8078SAlex Deucher if (rdev->family == CHIP_RS300 || 463179e8078SAlex Deucher rdev->family == CHIP_RS400 || 464179e8078SAlex Deucher rdev->family == CHIP_RS480) 465179e8078SAlex Deucher ddc_line = RADEON_GPIOPAD_MASK; 466508c8d60SAlex Deucher else if (rdev->family == CHIP_R300 || 467776f2b7cSAlex Deucher rdev->family == CHIP_R350) { 468508c8d60SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 469776f2b7cSAlex Deucher ddc = DDC_DVI; 470776f2b7cSAlex Deucher } else 471179e8078SAlex Deucher ddc_line = RADEON_GPIO_MONID; 472179e8078SAlex Deucher break; 473179e8078SAlex Deucher case DDC_CRT2: 474508c8d60SAlex Deucher if (rdev->family == CHIP_R200 || 475508c8d60SAlex Deucher rdev->family == CHIP_R300 || 476776f2b7cSAlex Deucher rdev->family == CHIP_R350) { 477179e8078SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 478776f2b7cSAlex Deucher ddc = DDC_DVI; 479776f2b7cSAlex Deucher } else if (rdev->family == CHIP_RS300 || 480776f2b7cSAlex Deucher rdev->family == CHIP_RS400 || 481776f2b7cSAlex Deucher rdev->family == CHIP_RS480) 482508c8d60SAlex Deucher ddc_line = RADEON_GPIO_MONID; 483776f2b7cSAlex Deucher else if (rdev->family >= CHIP_RV350) { 484776f2b7cSAlex Deucher ddc_line = RADEON_GPIO_MONID; 485776f2b7cSAlex Deucher ddc = DDC_MONID; 486776f2b7cSAlex Deucher } else 487179e8078SAlex Deucher ddc_line = RADEON_GPIO_CRT2_DDC; 488179e8078SAlex Deucher break; 489179e8078SAlex Deucher } 490771fe6b9SJerome Glisse 4916a93cb25SAlex Deucher if (ddc_line == RADEON_GPIOPAD_MASK) { 4926a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_GPIOPAD_MASK; 4936a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_GPIOPAD_MASK; 4946a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_GPIOPAD_A; 4956a93cb25SAlex Deucher i2c.a_data_reg = RADEON_GPIOPAD_A; 4966a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_GPIOPAD_EN; 4976a93cb25SAlex Deucher i2c.en_data_reg = RADEON_GPIOPAD_EN; 4986a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_GPIOPAD_Y; 4996a93cb25SAlex Deucher i2c.y_data_reg = RADEON_GPIOPAD_Y; 5006a93cb25SAlex Deucher } else if (ddc_line == RADEON_MDGPIO_MASK) { 5016a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_MDGPIO_MASK; 5026a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_MDGPIO_MASK; 5036a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_MDGPIO_A; 5046a93cb25SAlex Deucher i2c.a_data_reg = RADEON_MDGPIO_A; 5056a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_MDGPIO_EN; 5066a93cb25SAlex Deucher i2c.en_data_reg = RADEON_MDGPIO_EN; 5076a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_MDGPIO_Y; 5086a93cb25SAlex Deucher i2c.y_data_reg = RADEON_MDGPIO_Y; 5096a93cb25SAlex Deucher } else { 510771fe6b9SJerome Glisse i2c.mask_clk_reg = ddc_line; 511771fe6b9SJerome Glisse i2c.mask_data_reg = ddc_line; 512771fe6b9SJerome Glisse i2c.a_clk_reg = ddc_line; 513771fe6b9SJerome Glisse i2c.a_data_reg = ddc_line; 5149b9fe724SAlex Deucher i2c.en_clk_reg = ddc_line; 5159b9fe724SAlex Deucher i2c.en_data_reg = ddc_line; 5169b9fe724SAlex Deucher i2c.y_clk_reg = ddc_line; 5179b9fe724SAlex Deucher i2c.y_data_reg = ddc_line; 518771fe6b9SJerome Glisse } 519771fe6b9SJerome Glisse 520179e8078SAlex Deucher if (clk_mask && data_mask) { 521be663057SAlex Deucher /* system specific masks */ 522179e8078SAlex Deucher i2c.mask_clk_mask = clk_mask; 523179e8078SAlex Deucher i2c.mask_data_mask = data_mask; 524179e8078SAlex Deucher i2c.a_clk_mask = clk_mask; 525179e8078SAlex Deucher i2c.a_data_mask = data_mask; 526179e8078SAlex Deucher i2c.en_clk_mask = clk_mask; 527179e8078SAlex Deucher i2c.en_data_mask = data_mask; 528179e8078SAlex Deucher i2c.y_clk_mask = clk_mask; 529179e8078SAlex Deucher i2c.y_data_mask = data_mask; 530be663057SAlex Deucher } else if ((ddc_line == RADEON_GPIOPAD_MASK) || 531be663057SAlex Deucher (ddc_line == RADEON_MDGPIO_MASK)) { 532be663057SAlex Deucher /* default gpiopad masks */ 533be663057SAlex Deucher i2c.mask_clk_mask = (0x20 << 8); 534be663057SAlex Deucher i2c.mask_data_mask = 0x80; 535be663057SAlex Deucher i2c.a_clk_mask = (0x20 << 8); 536be663057SAlex Deucher i2c.a_data_mask = 0x80; 537be663057SAlex Deucher i2c.en_clk_mask = (0x20 << 8); 538be663057SAlex Deucher i2c.en_data_mask = 0x80; 539be663057SAlex Deucher i2c.y_clk_mask = (0x20 << 8); 540be663057SAlex Deucher i2c.y_data_mask = 0x80; 541179e8078SAlex Deucher } else { 542be663057SAlex Deucher /* default masks for ddc pads */ 543286e0c94SJean Delvare i2c.mask_clk_mask = RADEON_GPIO_MASK_1; 544286e0c94SJean Delvare i2c.mask_data_mask = RADEON_GPIO_MASK_0; 545179e8078SAlex Deucher i2c.a_clk_mask = RADEON_GPIO_A_1; 546179e8078SAlex Deucher i2c.a_data_mask = RADEON_GPIO_A_0; 547179e8078SAlex Deucher i2c.en_clk_mask = RADEON_GPIO_EN_1; 548179e8078SAlex Deucher i2c.en_data_mask = RADEON_GPIO_EN_0; 549179e8078SAlex Deucher i2c.y_clk_mask = RADEON_GPIO_Y_1; 550179e8078SAlex Deucher i2c.y_data_mask = RADEON_GPIO_Y_0; 551179e8078SAlex Deucher } 552179e8078SAlex Deucher 55340bacf16SAlex Deucher switch (rdev->family) { 55440bacf16SAlex Deucher case CHIP_R100: 55540bacf16SAlex Deucher case CHIP_RV100: 55640bacf16SAlex Deucher case CHIP_RS100: 55740bacf16SAlex Deucher case CHIP_RV200: 55840bacf16SAlex Deucher case CHIP_RS200: 55940bacf16SAlex Deucher case CHIP_RS300: 56040bacf16SAlex Deucher switch (ddc_line) { 56140bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 562b28ea411SAlex Deucher i2c.hw_capable = true; 56340bacf16SAlex Deucher break; 56440bacf16SAlex Deucher default: 56540bacf16SAlex Deucher i2c.hw_capable = false; 56640bacf16SAlex Deucher break; 56740bacf16SAlex Deucher } 56840bacf16SAlex Deucher break; 56940bacf16SAlex Deucher case CHIP_R200: 57040bacf16SAlex Deucher switch (ddc_line) { 57140bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 57240bacf16SAlex Deucher case RADEON_GPIO_MONID: 57340bacf16SAlex Deucher i2c.hw_capable = true; 57440bacf16SAlex Deucher break; 57540bacf16SAlex Deucher default: 57640bacf16SAlex Deucher i2c.hw_capable = false; 57740bacf16SAlex Deucher break; 57840bacf16SAlex Deucher } 57940bacf16SAlex Deucher break; 58040bacf16SAlex Deucher case CHIP_RV250: 58140bacf16SAlex Deucher case CHIP_RV280: 58240bacf16SAlex Deucher switch (ddc_line) { 58340bacf16SAlex Deucher case RADEON_GPIO_VGA_DDC: 58440bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 58540bacf16SAlex Deucher case RADEON_GPIO_CRT2_DDC: 58640bacf16SAlex Deucher i2c.hw_capable = true; 58740bacf16SAlex Deucher break; 58840bacf16SAlex Deucher default: 58940bacf16SAlex Deucher i2c.hw_capable = false; 59040bacf16SAlex Deucher break; 59140bacf16SAlex Deucher } 59240bacf16SAlex Deucher break; 59340bacf16SAlex Deucher case CHIP_R300: 59440bacf16SAlex Deucher case CHIP_R350: 59540bacf16SAlex Deucher switch (ddc_line) { 59640bacf16SAlex Deucher case RADEON_GPIO_VGA_DDC: 59740bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 59840bacf16SAlex Deucher i2c.hw_capable = true; 59940bacf16SAlex Deucher break; 60040bacf16SAlex Deucher default: 60140bacf16SAlex Deucher i2c.hw_capable = false; 60240bacf16SAlex Deucher break; 60340bacf16SAlex Deucher } 60440bacf16SAlex Deucher break; 60540bacf16SAlex Deucher case CHIP_RV350: 60640bacf16SAlex Deucher case CHIP_RV380: 60740bacf16SAlex Deucher case CHIP_RS400: 60840bacf16SAlex Deucher case CHIP_RS480: 6096a93cb25SAlex Deucher switch (ddc_line) { 6106a93cb25SAlex Deucher case RADEON_GPIO_VGA_DDC: 6116a93cb25SAlex Deucher case RADEON_GPIO_DVI_DDC: 6126a93cb25SAlex Deucher i2c.hw_capable = true; 6136a93cb25SAlex Deucher break; 6146a93cb25SAlex Deucher case RADEON_GPIO_MONID: 6156a93cb25SAlex Deucher /* hw i2c on RADEON_GPIO_MONID doesn't seem to work 6166a93cb25SAlex Deucher * reliably on some pre-r4xx hardware; not sure why. 6176a93cb25SAlex Deucher */ 6186a93cb25SAlex Deucher i2c.hw_capable = false; 6196a93cb25SAlex Deucher break; 6206a93cb25SAlex Deucher default: 6216a93cb25SAlex Deucher i2c.hw_capable = false; 6226a93cb25SAlex Deucher break; 6236a93cb25SAlex Deucher } 62440bacf16SAlex Deucher break; 62540bacf16SAlex Deucher default: 62640bacf16SAlex Deucher i2c.hw_capable = false; 62740bacf16SAlex Deucher break; 6286a93cb25SAlex Deucher } 6296a93cb25SAlex Deucher i2c.mm_i2c = false; 630f376b94fSAlex Deucher 631179e8078SAlex Deucher i2c.i2c_id = ddc; 6328e36ed00SAlex Deucher i2c.hpd = RADEON_HPD_NONE; 6336a93cb25SAlex Deucher 634771fe6b9SJerome Glisse if (ddc_line) 635771fe6b9SJerome Glisse i2c.valid = true; 636771fe6b9SJerome Glisse else 637771fe6b9SJerome Glisse i2c.valid = false; 638771fe6b9SJerome Glisse 639771fe6b9SJerome Glisse return i2c; 640771fe6b9SJerome Glisse } 641771fe6b9SJerome Glisse 6423d61bd42SAlex Deucher static struct radeon_i2c_bus_rec radeon_combios_get_i2c_info_from_table(struct radeon_device *rdev) 6433d61bd42SAlex Deucher { 6443d61bd42SAlex Deucher struct drm_device *dev = rdev->ddev; 6453d61bd42SAlex Deucher struct radeon_i2c_bus_rec i2c; 6463d61bd42SAlex Deucher u16 offset; 6473d61bd42SAlex Deucher u8 id, blocks, clk, data; 6483d61bd42SAlex Deucher int i; 6493d61bd42SAlex Deucher 6503d61bd42SAlex Deucher i2c.valid = false; 6513d61bd42SAlex Deucher 6523d61bd42SAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE); 6533d61bd42SAlex Deucher if (offset) { 6543d61bd42SAlex Deucher blocks = RBIOS8(offset + 2); 6553d61bd42SAlex Deucher for (i = 0; i < blocks; i++) { 6563d61bd42SAlex Deucher id = RBIOS8(offset + 3 + (i * 5) + 0); 6573d61bd42SAlex Deucher if (id == 136) { 6583d61bd42SAlex Deucher clk = RBIOS8(offset + 3 + (i * 5) + 3); 6593d61bd42SAlex Deucher data = RBIOS8(offset + 3 + (i * 5) + 4); 6603d61bd42SAlex Deucher /* gpiopad */ 6613d61bd42SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 6623d61bd42SAlex Deucher (1 << clk), (1 << data)); 6633d61bd42SAlex Deucher break; 6643d61bd42SAlex Deucher } 6653d61bd42SAlex Deucher } 6663d61bd42SAlex Deucher } 6673d61bd42SAlex Deucher return i2c; 6683d61bd42SAlex Deucher } 6693d61bd42SAlex Deucher 670f376b94fSAlex Deucher void radeon_combios_i2c_init(struct radeon_device *rdev) 671f376b94fSAlex Deucher { 672f376b94fSAlex Deucher struct drm_device *dev = rdev->ddev; 673f376b94fSAlex Deucher struct radeon_i2c_bus_rec i2c; 674f376b94fSAlex Deucher 675508c8d60SAlex Deucher /* actual hw pads 676508c8d60SAlex Deucher * r1xx/rs2xx/rs3xx 677508c8d60SAlex Deucher * 0x60, 0x64, 0x68, 0x6c, gpiopads, mm 678508c8d60SAlex Deucher * r200 679508c8d60SAlex Deucher * 0x60, 0x64, 0x68, mm 680508c8d60SAlex Deucher * r300/r350 681508c8d60SAlex Deucher * 0x60, 0x64, mm 682508c8d60SAlex Deucher * rv2xx/rv3xx/rs4xx 683508c8d60SAlex Deucher * 0x60, 0x64, 0x68, gpiopads, mm 684508c8d60SAlex Deucher */ 685f376b94fSAlex Deucher 686508c8d60SAlex Deucher /* 0x60 */ 687179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 688179e8078SAlex Deucher rdev->i2c_bus[0] = radeon_i2c_create(dev, &i2c, "DVI_DDC"); 689508c8d60SAlex Deucher /* 0x64 */ 690179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 691179e8078SAlex Deucher rdev->i2c_bus[1] = radeon_i2c_create(dev, &i2c, "VGA_DDC"); 692f376b94fSAlex Deucher 693508c8d60SAlex Deucher /* mm i2c */ 694f376b94fSAlex Deucher i2c.valid = true; 695f376b94fSAlex Deucher i2c.hw_capable = true; 696f376b94fSAlex Deucher i2c.mm_i2c = true; 697179e8078SAlex Deucher i2c.i2c_id = 0xa0; 698179e8078SAlex Deucher rdev->i2c_bus[2] = radeon_i2c_create(dev, &i2c, "MM_I2C"); 699179e8078SAlex Deucher 700508c8d60SAlex Deucher if (rdev->family == CHIP_R300 || 701508c8d60SAlex Deucher rdev->family == CHIP_R350) { 702508c8d60SAlex Deucher /* only 2 sw i2c pads */ 703508c8d60SAlex Deucher } else if (rdev->family == CHIP_RS300 || 704179e8078SAlex Deucher rdev->family == CHIP_RS400 || 705179e8078SAlex Deucher rdev->family == CHIP_RS480) { 706508c8d60SAlex Deucher /* 0x68 */ 707179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 708179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 709179e8078SAlex Deucher 710508c8d60SAlex Deucher /* gpiopad */ 7113d61bd42SAlex Deucher i2c = radeon_combios_get_i2c_info_from_table(rdev); 7123d61bd42SAlex Deucher if (i2c.valid) 713179e8078SAlex Deucher rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "GPIOPAD_MASK"); 7146dd66633SAlex Deucher } else if ((rdev->family == CHIP_R200) || 7156dd66633SAlex Deucher (rdev->family >= CHIP_R300)) { 716508c8d60SAlex Deucher /* 0x68 */ 717179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 718179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 719179e8078SAlex Deucher } else { 720508c8d60SAlex Deucher /* 0x68 */ 721179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 722179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 723508c8d60SAlex Deucher /* 0x6c */ 724179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 725179e8078SAlex Deucher rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "CRT2_DDC"); 726179e8078SAlex Deucher } 727f376b94fSAlex Deucher } 728f376b94fSAlex Deucher 729771fe6b9SJerome Glisse bool radeon_combios_get_clock_info(struct drm_device *dev) 730771fe6b9SJerome Glisse { 731771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 732771fe6b9SJerome Glisse uint16_t pll_info; 733771fe6b9SJerome Glisse struct radeon_pll *p1pll = &rdev->clock.p1pll; 734771fe6b9SJerome Glisse struct radeon_pll *p2pll = &rdev->clock.p2pll; 735771fe6b9SJerome Glisse struct radeon_pll *spll = &rdev->clock.spll; 736771fe6b9SJerome Glisse struct radeon_pll *mpll = &rdev->clock.mpll; 737771fe6b9SJerome Glisse int8_t rev; 738771fe6b9SJerome Glisse uint16_t sclk, mclk; 739771fe6b9SJerome Glisse 740771fe6b9SJerome Glisse pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE); 741771fe6b9SJerome Glisse if (pll_info) { 742771fe6b9SJerome Glisse rev = RBIOS8(pll_info); 743771fe6b9SJerome Glisse 744771fe6b9SJerome Glisse /* pixel clocks */ 745771fe6b9SJerome Glisse p1pll->reference_freq = RBIOS16(pll_info + 0xe); 746771fe6b9SJerome Glisse p1pll->reference_div = RBIOS16(pll_info + 0x10); 747771fe6b9SJerome Glisse p1pll->pll_out_min = RBIOS32(pll_info + 0x12); 748771fe6b9SJerome Glisse p1pll->pll_out_max = RBIOS32(pll_info + 0x16); 74986cb2bbfSAlex Deucher p1pll->lcd_pll_out_min = p1pll->pll_out_min; 75086cb2bbfSAlex Deucher p1pll->lcd_pll_out_max = p1pll->pll_out_max; 751771fe6b9SJerome Glisse 752771fe6b9SJerome Glisse if (rev > 9) { 753771fe6b9SJerome Glisse p1pll->pll_in_min = RBIOS32(pll_info + 0x36); 754771fe6b9SJerome Glisse p1pll->pll_in_max = RBIOS32(pll_info + 0x3a); 755771fe6b9SJerome Glisse } else { 756771fe6b9SJerome Glisse p1pll->pll_in_min = 40; 757771fe6b9SJerome Glisse p1pll->pll_in_max = 500; 758771fe6b9SJerome Glisse } 759771fe6b9SJerome Glisse *p2pll = *p1pll; 760771fe6b9SJerome Glisse 761771fe6b9SJerome Glisse /* system clock */ 762771fe6b9SJerome Glisse spll->reference_freq = RBIOS16(pll_info + 0x1a); 763771fe6b9SJerome Glisse spll->reference_div = RBIOS16(pll_info + 0x1c); 764771fe6b9SJerome Glisse spll->pll_out_min = RBIOS32(pll_info + 0x1e); 765771fe6b9SJerome Glisse spll->pll_out_max = RBIOS32(pll_info + 0x22); 766771fe6b9SJerome Glisse 767771fe6b9SJerome Glisse if (rev > 10) { 768771fe6b9SJerome Glisse spll->pll_in_min = RBIOS32(pll_info + 0x48); 769771fe6b9SJerome Glisse spll->pll_in_max = RBIOS32(pll_info + 0x4c); 770771fe6b9SJerome Glisse } else { 771771fe6b9SJerome Glisse /* ??? */ 772771fe6b9SJerome Glisse spll->pll_in_min = 40; 773771fe6b9SJerome Glisse spll->pll_in_max = 500; 774771fe6b9SJerome Glisse } 775771fe6b9SJerome Glisse 776771fe6b9SJerome Glisse /* memory clock */ 777771fe6b9SJerome Glisse mpll->reference_freq = RBIOS16(pll_info + 0x26); 778771fe6b9SJerome Glisse mpll->reference_div = RBIOS16(pll_info + 0x28); 779771fe6b9SJerome Glisse mpll->pll_out_min = RBIOS32(pll_info + 0x2a); 780771fe6b9SJerome Glisse mpll->pll_out_max = RBIOS32(pll_info + 0x2e); 781771fe6b9SJerome Glisse 782771fe6b9SJerome Glisse if (rev > 10) { 783771fe6b9SJerome Glisse mpll->pll_in_min = RBIOS32(pll_info + 0x5a); 784771fe6b9SJerome Glisse mpll->pll_in_max = RBIOS32(pll_info + 0x5e); 785771fe6b9SJerome Glisse } else { 786771fe6b9SJerome Glisse /* ??? */ 787771fe6b9SJerome Glisse mpll->pll_in_min = 40; 788771fe6b9SJerome Glisse mpll->pll_in_max = 500; 789771fe6b9SJerome Glisse } 790771fe6b9SJerome Glisse 791771fe6b9SJerome Glisse /* default sclk/mclk */ 792771fe6b9SJerome Glisse sclk = RBIOS16(pll_info + 0xa); 793771fe6b9SJerome Glisse mclk = RBIOS16(pll_info + 0x8); 794771fe6b9SJerome Glisse if (sclk == 0) 795771fe6b9SJerome Glisse sclk = 200 * 100; 796771fe6b9SJerome Glisse if (mclk == 0) 797771fe6b9SJerome Glisse mclk = 200 * 100; 798771fe6b9SJerome Glisse 799771fe6b9SJerome Glisse rdev->clock.default_sclk = sclk; 800771fe6b9SJerome Glisse rdev->clock.default_mclk = mclk; 801771fe6b9SJerome Glisse 802b20f9befSAlex Deucher if (RBIOS32(pll_info + 0x16)) 803b20f9befSAlex Deucher rdev->clock.max_pixel_clock = RBIOS32(pll_info + 0x16); 804b20f9befSAlex Deucher else 805b20f9befSAlex Deucher rdev->clock.max_pixel_clock = 35000; /* might need something asic specific */ 806b20f9befSAlex Deucher 807771fe6b9SJerome Glisse return true; 808771fe6b9SJerome Glisse } 809771fe6b9SJerome Glisse return false; 810771fe6b9SJerome Glisse } 811771fe6b9SJerome Glisse 81206b6476dSAlex Deucher bool radeon_combios_sideport_present(struct radeon_device *rdev) 81306b6476dSAlex Deucher { 81406b6476dSAlex Deucher struct drm_device *dev = rdev->ddev; 81506b6476dSAlex Deucher u16 igp_info; 81606b6476dSAlex Deucher 8174c70b2eaSAlex Deucher /* sideport is AMD only */ 8184c70b2eaSAlex Deucher if (rdev->family == CHIP_RS400) 8194c70b2eaSAlex Deucher return false; 8204c70b2eaSAlex Deucher 82106b6476dSAlex Deucher igp_info = combios_get_table_offset(dev, COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE); 82206b6476dSAlex Deucher 82306b6476dSAlex Deucher if (igp_info) { 82406b6476dSAlex Deucher if (RBIOS16(igp_info + 0x4)) 82506b6476dSAlex Deucher return true; 82606b6476dSAlex Deucher } 82706b6476dSAlex Deucher return false; 82806b6476dSAlex Deucher } 82906b6476dSAlex Deucher 830246263ccSAlex Deucher static const uint32_t default_primarydac_adj[CHIP_LAST] = { 831246263ccSAlex Deucher 0x00000808, /* r100 */ 832246263ccSAlex Deucher 0x00000808, /* rv100 */ 833246263ccSAlex Deucher 0x00000808, /* rs100 */ 834246263ccSAlex Deucher 0x00000808, /* rv200 */ 835246263ccSAlex Deucher 0x00000808, /* rs200 */ 836246263ccSAlex Deucher 0x00000808, /* r200 */ 837246263ccSAlex Deucher 0x00000808, /* rv250 */ 838246263ccSAlex Deucher 0x00000000, /* rs300 */ 839246263ccSAlex Deucher 0x00000808, /* rv280 */ 840246263ccSAlex Deucher 0x00000808, /* r300 */ 841246263ccSAlex Deucher 0x00000808, /* r350 */ 842246263ccSAlex Deucher 0x00000808, /* rv350 */ 843246263ccSAlex Deucher 0x00000808, /* rv380 */ 844246263ccSAlex Deucher 0x00000808, /* r420 */ 845246263ccSAlex Deucher 0x00000808, /* r423 */ 846246263ccSAlex Deucher 0x00000808, /* rv410 */ 847246263ccSAlex Deucher 0x00000000, /* rs400 */ 848246263ccSAlex Deucher 0x00000000, /* rs480 */ 849246263ccSAlex Deucher }; 850246263ccSAlex Deucher 851246263ccSAlex Deucher static void radeon_legacy_get_primary_dac_info_from_table(struct radeon_device *rdev, 852246263ccSAlex Deucher struct radeon_encoder_primary_dac *p_dac) 853246263ccSAlex Deucher { 854246263ccSAlex Deucher p_dac->ps2_pdac_adj = default_primarydac_adj[rdev->family]; 855246263ccSAlex Deucher return; 856246263ccSAlex Deucher } 857246263ccSAlex Deucher 858771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct 859771fe6b9SJerome Glisse radeon_encoder 860771fe6b9SJerome Glisse *encoder) 861771fe6b9SJerome Glisse { 862771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 863771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 864771fe6b9SJerome Glisse uint16_t dac_info; 865771fe6b9SJerome Glisse uint8_t rev, bg, dac; 866771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *p_dac = NULL; 867246263ccSAlex Deucher int found = 0; 868771fe6b9SJerome Glisse 869246263ccSAlex Deucher p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), 870771fe6b9SJerome Glisse GFP_KERNEL); 871771fe6b9SJerome Glisse 872771fe6b9SJerome Glisse if (!p_dac) 873771fe6b9SJerome Glisse return NULL; 874771fe6b9SJerome Glisse 875246263ccSAlex Deucher /* check CRT table */ 876246263ccSAlex Deucher dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 877246263ccSAlex Deucher if (dac_info) { 878771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 879771fe6b9SJerome Glisse if (rev < 2) { 880771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 881771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf; 882771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 883771fe6b9SJerome Glisse } else { 884771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 885771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x3) & 0xf; 886771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 887771fe6b9SJerome Glisse } 88803ed8cf9SAlex Deucher /* if the values are zeros, use the table */ 88903ed8cf9SAlex Deucher if ((dac == 0) || (bg == 0)) 89003ed8cf9SAlex Deucher found = 0; 89103ed8cf9SAlex Deucher else 892246263ccSAlex Deucher found = 1; 893771fe6b9SJerome Glisse } 894771fe6b9SJerome Glisse 895e8fc4137SAlex Deucher /* quirks */ 896f7929f34SOndrej Zary /* Radeon 7000 (RV100) */ 897*d86a4126SThomas Zimmermann if (((rdev->pdev->device == 0x5159) && 898*d86a4126SThomas Zimmermann (rdev->pdev->subsystem_vendor == 0x174B) && 899*d86a4126SThomas Zimmermann (rdev->pdev->subsystem_device == 0x7c28)) || 900f7929f34SOndrej Zary /* Radeon 9100 (R200) */ 901*d86a4126SThomas Zimmermann ((rdev->pdev->device == 0x514D) && 902*d86a4126SThomas Zimmermann (rdev->pdev->subsystem_vendor == 0x174B) && 903*d86a4126SThomas Zimmermann (rdev->pdev->subsystem_device == 0x7149))) { 904e8fc4137SAlex Deucher /* vbios value is bad, use the default */ 905e8fc4137SAlex Deucher found = 0; 906e8fc4137SAlex Deucher } 907e8fc4137SAlex Deucher 908246263ccSAlex Deucher if (!found) /* fallback to defaults */ 909246263ccSAlex Deucher radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac); 910246263ccSAlex Deucher 911771fe6b9SJerome Glisse return p_dac; 912771fe6b9SJerome Glisse } 913771fe6b9SJerome Glisse 914d79766faSAlex Deucher enum radeon_tv_std 915d79766faSAlex Deucher radeon_combios_get_tv_info(struct radeon_device *rdev) 916771fe6b9SJerome Glisse { 917d79766faSAlex Deucher struct drm_device *dev = rdev->ddev; 918771fe6b9SJerome Glisse uint16_t tv_info; 919771fe6b9SJerome Glisse enum radeon_tv_std tv_std = TV_STD_NTSC; 920771fe6b9SJerome Glisse 921771fe6b9SJerome Glisse tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 922771fe6b9SJerome Glisse if (tv_info) { 923771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 924771fe6b9SJerome Glisse switch (RBIOS8(tv_info + 7) & 0xf) { 925771fe6b9SJerome Glisse case 1: 926771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 92740f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: NTSC\n"); 928771fe6b9SJerome Glisse break; 929771fe6b9SJerome Glisse case 2: 930771fe6b9SJerome Glisse tv_std = TV_STD_PAL; 93140f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL\n"); 932771fe6b9SJerome Glisse break; 933771fe6b9SJerome Glisse case 3: 934771fe6b9SJerome Glisse tv_std = TV_STD_PAL_M; 93540f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL-M\n"); 936771fe6b9SJerome Glisse break; 937771fe6b9SJerome Glisse case 4: 938771fe6b9SJerome Glisse tv_std = TV_STD_PAL_60; 93940f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL-60\n"); 940771fe6b9SJerome Glisse break; 941771fe6b9SJerome Glisse case 5: 942771fe6b9SJerome Glisse tv_std = TV_STD_NTSC_J; 94340f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: NTSC-J\n"); 944771fe6b9SJerome Glisse break; 945771fe6b9SJerome Glisse case 6: 946771fe6b9SJerome Glisse tv_std = TV_STD_SCART_PAL; 94740f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: SCART-PAL\n"); 948771fe6b9SJerome Glisse break; 949771fe6b9SJerome Glisse default: 950771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 95140f76d81SAlex Deucher DRM_DEBUG_KMS 952771fe6b9SJerome Glisse ("Unknown TV standard; defaulting to NTSC\n"); 953771fe6b9SJerome Glisse break; 954771fe6b9SJerome Glisse } 955771fe6b9SJerome Glisse 956771fe6b9SJerome Glisse switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) { 957771fe6b9SJerome Glisse case 0: 95840f76d81SAlex Deucher DRM_DEBUG_KMS("29.498928713 MHz TV ref clk\n"); 959771fe6b9SJerome Glisse break; 960771fe6b9SJerome Glisse case 1: 96140f76d81SAlex Deucher DRM_DEBUG_KMS("28.636360000 MHz TV ref clk\n"); 962771fe6b9SJerome Glisse break; 963771fe6b9SJerome Glisse case 2: 96440f76d81SAlex Deucher DRM_DEBUG_KMS("14.318180000 MHz TV ref clk\n"); 965771fe6b9SJerome Glisse break; 966771fe6b9SJerome Glisse case 3: 96740f76d81SAlex Deucher DRM_DEBUG_KMS("27.000000000 MHz TV ref clk\n"); 968771fe6b9SJerome Glisse break; 969771fe6b9SJerome Glisse default: 970771fe6b9SJerome Glisse break; 971771fe6b9SJerome Glisse } 972771fe6b9SJerome Glisse } 973771fe6b9SJerome Glisse } 974771fe6b9SJerome Glisse return tv_std; 975771fe6b9SJerome Glisse } 976771fe6b9SJerome Glisse 977771fe6b9SJerome Glisse static const uint32_t default_tvdac_adj[CHIP_LAST] = { 978771fe6b9SJerome Glisse 0x00000000, /* r100 */ 979771fe6b9SJerome Glisse 0x00280000, /* rv100 */ 980771fe6b9SJerome Glisse 0x00000000, /* rs100 */ 981771fe6b9SJerome Glisse 0x00880000, /* rv200 */ 982771fe6b9SJerome Glisse 0x00000000, /* rs200 */ 983771fe6b9SJerome Glisse 0x00000000, /* r200 */ 984771fe6b9SJerome Glisse 0x00770000, /* rv250 */ 985771fe6b9SJerome Glisse 0x00290000, /* rs300 */ 986771fe6b9SJerome Glisse 0x00560000, /* rv280 */ 987771fe6b9SJerome Glisse 0x00780000, /* r300 */ 988771fe6b9SJerome Glisse 0x00770000, /* r350 */ 989771fe6b9SJerome Glisse 0x00780000, /* rv350 */ 990771fe6b9SJerome Glisse 0x00780000, /* rv380 */ 991771fe6b9SJerome Glisse 0x01080000, /* r420 */ 992771fe6b9SJerome Glisse 0x01080000, /* r423 */ 993771fe6b9SJerome Glisse 0x01080000, /* rv410 */ 994771fe6b9SJerome Glisse 0x00780000, /* rs400 */ 995771fe6b9SJerome Glisse 0x00780000, /* rs480 */ 996771fe6b9SJerome Glisse }; 997771fe6b9SJerome Glisse 9986a719e05SDave Airlie static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev, 9996a719e05SDave Airlie struct radeon_encoder_tv_dac *tv_dac) 1000771fe6b9SJerome Glisse { 1001771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; 1002771fe6b9SJerome Glisse if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) 1003771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 0x00880000; 1004771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1005771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10066a719e05SDave Airlie return; 1007771fe6b9SJerome Glisse } 1008771fe6b9SJerome Glisse 1009771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct 1010771fe6b9SJerome Glisse radeon_encoder 1011771fe6b9SJerome Glisse *encoder) 1012771fe6b9SJerome Glisse { 1013771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1014771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1015771fe6b9SJerome Glisse uint16_t dac_info; 1016771fe6b9SJerome Glisse uint8_t rev, bg, dac; 1017771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *tv_dac = NULL; 10186a719e05SDave Airlie int found = 0; 10196a719e05SDave Airlie 10206a719e05SDave Airlie tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); 10216a719e05SDave Airlie if (!tv_dac) 10226a719e05SDave Airlie return NULL; 1023771fe6b9SJerome Glisse 1024771fe6b9SJerome Glisse /* first check TV table */ 1025771fe6b9SJerome Glisse dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 1026771fe6b9SJerome Glisse if (dac_info) { 1027771fe6b9SJerome Glisse rev = RBIOS8(dac_info + 0x3); 1028771fe6b9SJerome Glisse if (rev > 4) { 1029771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 1030771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xd) & 0xf; 1031771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 1032771fe6b9SJerome Glisse 1033771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 1034771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xf) & 0xf; 1035771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 1036771fe6b9SJerome Glisse 1037771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x10) & 0xf; 1038771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x11) & 0xf; 1039771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 10403a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10413a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10426a719e05SDave Airlie found = 1; 1043771fe6b9SJerome Glisse } else if (rev > 1) { 1044771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 1045771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; 1046771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 1047771fe6b9SJerome Glisse 1048771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xd) & 0xf; 1049771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf; 1050771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 1051771fe6b9SJerome Glisse 1052771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 1053771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; 1054771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 10553a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10563a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10576a719e05SDave Airlie found = 1; 1058771fe6b9SJerome Glisse } 1059d79766faSAlex Deucher tv_dac->tv_std = radeon_combios_get_tv_info(rdev); 10606a719e05SDave Airlie } 10616a719e05SDave Airlie if (!found) { 1062771fe6b9SJerome Glisse /* then check CRT table */ 1063771fe6b9SJerome Glisse dac_info = 1064771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 1065771fe6b9SJerome Glisse if (dac_info) { 1066771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 1067771fe6b9SJerome Glisse if (rev < 2) { 1068771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x3) & 0xf; 1069771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf; 1070771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 1071771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 1072771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1073771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10743a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10753a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10766a719e05SDave Airlie found = 1; 1077771fe6b9SJerome Glisse } else { 1078771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x4) & 0xf; 1079771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x5) & 0xf; 1080771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 1081771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 1082771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1083771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10843a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10853a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10866a719e05SDave Airlie found = 1; 1087771fe6b9SJerome Glisse } 10886fe7ac3fSAlex Deucher } else { 10896fe7ac3fSAlex Deucher DRM_INFO("No TV DAC info found in BIOS\n"); 1090771fe6b9SJerome Glisse } 1091771fe6b9SJerome Glisse } 1092771fe6b9SJerome Glisse 10936a719e05SDave Airlie if (!found) /* fallback to defaults */ 10946a719e05SDave Airlie radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac); 10956a719e05SDave Airlie 1096771fe6b9SJerome Glisse return tv_dac; 1097771fe6b9SJerome Glisse } 1098771fe6b9SJerome Glisse 1099771fe6b9SJerome Glisse static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct 1100771fe6b9SJerome Glisse radeon_device 1101771fe6b9SJerome Glisse *rdev) 1102771fe6b9SJerome Glisse { 1103771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 1104771fe6b9SJerome Glisse uint32_t fp_vert_stretch, fp_horz_stretch; 1105771fe6b9SJerome Glisse uint32_t ppll_div_sel, ppll_val; 11068b5c7444SMichel Dänzer uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL); 1107771fe6b9SJerome Glisse 1108771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 1109771fe6b9SJerome Glisse 1110771fe6b9SJerome Glisse if (!lvds) 1111771fe6b9SJerome Glisse return NULL; 1112771fe6b9SJerome Glisse 1113771fe6b9SJerome Glisse fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH); 1114771fe6b9SJerome Glisse fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH); 1115771fe6b9SJerome Glisse 11168b5c7444SMichel Dänzer /* These should be fail-safe defaults, fingers crossed */ 11178b5c7444SMichel Dänzer lvds->panel_pwr_delay = 200; 11188b5c7444SMichel Dänzer lvds->panel_vcc_delay = 2000; 11198b5c7444SMichel Dänzer 11208b5c7444SMichel Dänzer lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL); 11218b5c7444SMichel Dänzer lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf; 11228b5c7444SMichel Dänzer lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf; 11238b5c7444SMichel Dänzer 1124771fe6b9SJerome Glisse if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE) 1125de2103e4SAlex Deucher lvds->native_mode.vdisplay = 1126771fe6b9SJerome Glisse ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >> 1127771fe6b9SJerome Glisse RADEON_VERT_PANEL_SHIFT) + 1; 1128771fe6b9SJerome Glisse else 1129de2103e4SAlex Deucher lvds->native_mode.vdisplay = 1130771fe6b9SJerome Glisse (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1; 1131771fe6b9SJerome Glisse 1132771fe6b9SJerome Glisse if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE) 1133de2103e4SAlex Deucher lvds->native_mode.hdisplay = 1134771fe6b9SJerome Glisse (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >> 1135771fe6b9SJerome Glisse RADEON_HORZ_PANEL_SHIFT) + 1) * 8; 1136771fe6b9SJerome Glisse else 1137de2103e4SAlex Deucher lvds->native_mode.hdisplay = 1138771fe6b9SJerome Glisse ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8; 1139771fe6b9SJerome Glisse 1140de2103e4SAlex Deucher if ((lvds->native_mode.hdisplay < 640) || 1141de2103e4SAlex Deucher (lvds->native_mode.vdisplay < 480)) { 1142de2103e4SAlex Deucher lvds->native_mode.hdisplay = 640; 1143de2103e4SAlex Deucher lvds->native_mode.vdisplay = 480; 1144771fe6b9SJerome Glisse } 1145771fe6b9SJerome Glisse 1146771fe6b9SJerome Glisse ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3; 1147771fe6b9SJerome Glisse ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel); 1148771fe6b9SJerome Glisse if ((ppll_val & 0x000707ff) == 0x1bb) 1149771fe6b9SJerome Glisse lvds->use_bios_dividers = false; 1150771fe6b9SJerome Glisse else { 1151771fe6b9SJerome Glisse lvds->panel_ref_divider = 1152771fe6b9SJerome Glisse RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff; 1153771fe6b9SJerome Glisse lvds->panel_post_divider = (ppll_val >> 16) & 0x7; 1154771fe6b9SJerome Glisse lvds->panel_fb_divider = ppll_val & 0x7ff; 1155771fe6b9SJerome Glisse 1156771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1157771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1158771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1159771fe6b9SJerome Glisse } 1160771fe6b9SJerome Glisse lvds->panel_vcc_delay = 200; 1161771fe6b9SJerome Glisse 1162771fe6b9SJerome Glisse DRM_INFO("Panel info derived from registers\n"); 1163de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1164de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1165771fe6b9SJerome Glisse 1166771fe6b9SJerome Glisse return lvds; 1167771fe6b9SJerome Glisse } 1168771fe6b9SJerome Glisse 1169771fe6b9SJerome Glisse struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder 1170771fe6b9SJerome Glisse *encoder) 1171771fe6b9SJerome Glisse { 1172771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1173771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1174771fe6b9SJerome Glisse uint16_t lcd_info; 1175771fe6b9SJerome Glisse uint32_t panel_setup; 1176771fe6b9SJerome Glisse char stmp[30]; 1177771fe6b9SJerome Glisse int tmp, i; 1178771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 1179771fe6b9SJerome Glisse 1180771fe6b9SJerome Glisse lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 1181771fe6b9SJerome Glisse 1182771fe6b9SJerome Glisse if (lcd_info) { 1183771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 1184771fe6b9SJerome Glisse 1185771fe6b9SJerome Glisse if (!lvds) 1186771fe6b9SJerome Glisse return NULL; 1187771fe6b9SJerome Glisse 1188771fe6b9SJerome Glisse for (i = 0; i < 24; i++) 1189771fe6b9SJerome Glisse stmp[i] = RBIOS8(lcd_info + i + 1); 1190771fe6b9SJerome Glisse stmp[24] = 0; 1191771fe6b9SJerome Glisse 1192771fe6b9SJerome Glisse DRM_INFO("Panel ID String: %s\n", stmp); 1193771fe6b9SJerome Glisse 1194de2103e4SAlex Deucher lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19); 1195de2103e4SAlex Deucher lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b); 1196771fe6b9SJerome Glisse 1197de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1198de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1199771fe6b9SJerome Glisse 1200771fe6b9SJerome Glisse lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c); 120194cf6434SAndrew Morton lvds->panel_vcc_delay = min_t(u16, lvds->panel_vcc_delay, 2000); 1202771fe6b9SJerome Glisse 1203771fe6b9SJerome Glisse lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24); 1204771fe6b9SJerome Glisse lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf; 1205771fe6b9SJerome Glisse lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf; 1206771fe6b9SJerome Glisse 1207771fe6b9SJerome Glisse lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e); 1208771fe6b9SJerome Glisse lvds->panel_post_divider = RBIOS8(lcd_info + 0x30); 1209771fe6b9SJerome Glisse lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31); 1210771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1211771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1212771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1213771fe6b9SJerome Glisse 1214771fe6b9SJerome Glisse panel_setup = RBIOS32(lcd_info + 0x39); 1215771fe6b9SJerome Glisse lvds->lvds_gen_cntl = 0xff00; 1216771fe6b9SJerome Glisse if (panel_setup & 0x1) 1217771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT; 1218771fe6b9SJerome Glisse 1219771fe6b9SJerome Glisse if ((panel_setup >> 4) & 0x1) 1220771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE; 1221771fe6b9SJerome Glisse 1222771fe6b9SJerome Glisse switch ((panel_setup >> 8) & 0x7) { 1223771fe6b9SJerome Glisse case 0: 1224771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM; 1225771fe6b9SJerome Glisse break; 1226771fe6b9SJerome Glisse case 1: 1227771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY; 1228771fe6b9SJerome Glisse break; 1229771fe6b9SJerome Glisse case 2: 1230771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY; 1231771fe6b9SJerome Glisse break; 1232771fe6b9SJerome Glisse default: 1233771fe6b9SJerome Glisse break; 1234771fe6b9SJerome Glisse } 1235771fe6b9SJerome Glisse 1236771fe6b9SJerome Glisse if ((panel_setup >> 16) & 0x1) 1237771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW; 1238771fe6b9SJerome Glisse 1239771fe6b9SJerome Glisse if ((panel_setup >> 17) & 0x1) 1240771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW; 1241771fe6b9SJerome Glisse 1242771fe6b9SJerome Glisse if ((panel_setup >> 18) & 0x1) 1243771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW; 1244771fe6b9SJerome Glisse 1245771fe6b9SJerome Glisse if ((panel_setup >> 23) & 0x1) 1246771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL; 1247771fe6b9SJerome Glisse 1248771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000); 1249771fe6b9SJerome Glisse 1250771fe6b9SJerome Glisse for (i = 0; i < 32; i++) { 1251771fe6b9SJerome Glisse tmp = RBIOS16(lcd_info + 64 + i * 2); 1252771fe6b9SJerome Glisse if (tmp == 0) 1253771fe6b9SJerome Glisse break; 1254771fe6b9SJerome Glisse 1255de2103e4SAlex Deucher if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) && 125668b61a7fSAlex Deucher (RBIOS16(tmp + 2) == lvds->native_mode.vdisplay)) { 12570a90a0cfSAlex Deucher u32 hss = (RBIOS16(tmp + 21) - RBIOS16(tmp + 19) - 1) * 8; 12580a90a0cfSAlex Deucher 12590a90a0cfSAlex Deucher if (hss > lvds->native_mode.hdisplay) 12600a90a0cfSAlex Deucher hss = (10 - 1) * 8; 12610a90a0cfSAlex Deucher 126268b61a7fSAlex Deucher lvds->native_mode.htotal = lvds->native_mode.hdisplay + 126368b61a7fSAlex Deucher (RBIOS16(tmp + 17) - RBIOS16(tmp + 19)) * 8; 126468b61a7fSAlex Deucher lvds->native_mode.hsync_start = lvds->native_mode.hdisplay + 12650a90a0cfSAlex Deucher hss; 126668b61a7fSAlex Deucher lvds->native_mode.hsync_end = lvds->native_mode.hsync_start + 126768b61a7fSAlex Deucher (RBIOS8(tmp + 23) * 8); 1268771fe6b9SJerome Glisse 126968b61a7fSAlex Deucher lvds->native_mode.vtotal = lvds->native_mode.vdisplay + 127068b61a7fSAlex Deucher (RBIOS16(tmp + 24) - RBIOS16(tmp + 26)); 127168b61a7fSAlex Deucher lvds->native_mode.vsync_start = lvds->native_mode.vdisplay + 127268b61a7fSAlex Deucher ((RBIOS16(tmp + 28) & 0x7ff) - RBIOS16(tmp + 26)); 127368b61a7fSAlex Deucher lvds->native_mode.vsync_end = lvds->native_mode.vsync_start + 127468b61a7fSAlex Deucher ((RBIOS16(tmp + 28) & 0xf800) >> 11); 1275de2103e4SAlex Deucher 1276de2103e4SAlex Deucher lvds->native_mode.clock = RBIOS16(tmp + 9) * 10; 1277771fe6b9SJerome Glisse lvds->native_mode.flags = 0; 1278de2103e4SAlex Deucher /* set crtc values */ 1279de2103e4SAlex Deucher drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V); 1280de2103e4SAlex Deucher 1281771fe6b9SJerome Glisse } 1282771fe6b9SJerome Glisse } 12836fe7ac3fSAlex Deucher } else { 1284771fe6b9SJerome Glisse DRM_INFO("No panel info found in BIOS\n"); 12858dfaa8a7SMichel Dänzer lvds = radeon_legacy_get_lvds_info_from_regs(rdev); 12866fe7ac3fSAlex Deucher } 128703047cdfSMichel Dänzer 12888dfaa8a7SMichel Dänzer if (lvds) 12898dfaa8a7SMichel Dänzer encoder->native_mode = lvds->native_mode; 1290771fe6b9SJerome Glisse return lvds; 1291771fe6b9SJerome Glisse } 1292771fe6b9SJerome Glisse 1293771fe6b9SJerome Glisse static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = { 1294771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */ 1295771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */ 1296771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */ 1297771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */ 1298771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */ 1299771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */ 1300771fe6b9SJerome Glisse {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */ 1301771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */ 1302771fe6b9SJerome Glisse {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */ 1303771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */ 1304771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */ 1305771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */ 1306771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */ 1307771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */ 1308771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */ 1309771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */ 1310fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */ 1311fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */ 1312771fe6b9SJerome Glisse }; 1313771fe6b9SJerome Glisse 1314445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder, 1315445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1316771fe6b9SJerome Glisse { 1317445282dbSDave Airlie struct drm_device *dev = encoder->base.dev; 1318445282dbSDave Airlie struct radeon_device *rdev = dev->dev_private; 1319771fe6b9SJerome Glisse int i; 1320771fe6b9SJerome Glisse 1321771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 1322771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1323771fe6b9SJerome Glisse default_tmds_pll[rdev->family][i].value; 1324771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq; 1325771fe6b9SJerome Glisse } 1326771fe6b9SJerome Glisse 1327445282dbSDave Airlie return true; 1328771fe6b9SJerome Glisse } 1329771fe6b9SJerome Glisse 1330445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder, 1331445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1332771fe6b9SJerome Glisse { 1333771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1334771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1335771fe6b9SJerome Glisse uint16_t tmds_info; 1336771fe6b9SJerome Glisse int i, n; 1337771fe6b9SJerome Glisse uint8_t ver; 1338771fe6b9SJerome Glisse 1339771fe6b9SJerome Glisse tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 1340771fe6b9SJerome Glisse 1341771fe6b9SJerome Glisse if (tmds_info) { 1342771fe6b9SJerome Glisse ver = RBIOS8(tmds_info); 134340f76d81SAlex Deucher DRM_DEBUG_KMS("DFP table revision: %d\n", ver); 1344771fe6b9SJerome Glisse if (ver == 3) { 1345771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1346771fe6b9SJerome Glisse if (n > 4) 1347771fe6b9SJerome Glisse n = 4; 1348771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1349771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1350771fe6b9SJerome Glisse RBIOS32(tmds_info + i * 10 + 0x08); 1351771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1352771fe6b9SJerome Glisse RBIOS16(tmds_info + i * 10 + 0x10); 1353d9fdaafbSDave Airlie DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", 1354771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1355771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1356771fe6b9SJerome Glisse } 1357771fe6b9SJerome Glisse } else if (ver == 4) { 1358771fe6b9SJerome Glisse int stride = 0; 1359771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1360771fe6b9SJerome Glisse if (n > 4) 1361771fe6b9SJerome Glisse n = 4; 1362771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1363771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1364771fe6b9SJerome Glisse RBIOS32(tmds_info + stride + 0x08); 1365771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1366771fe6b9SJerome Glisse RBIOS16(tmds_info + stride + 0x10); 1367771fe6b9SJerome Glisse if (i == 0) 1368771fe6b9SJerome Glisse stride += 10; 1369771fe6b9SJerome Glisse else 1370771fe6b9SJerome Glisse stride += 6; 1371d9fdaafbSDave Airlie DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", 1372771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1373771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1374771fe6b9SJerome Glisse } 1375771fe6b9SJerome Glisse } 1376fcec570bSAlex Deucher } else { 1377771fe6b9SJerome Glisse DRM_INFO("No TMDS info found in BIOS\n"); 1378fcec570bSAlex Deucher return false; 1379fcec570bSAlex Deucher } 1380445282dbSDave Airlie return true; 1381445282dbSDave Airlie } 1382445282dbSDave Airlie 1383fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder, 1384fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1385771fe6b9SJerome Glisse { 1386771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1387771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1388fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1389fcec570bSAlex Deucher 1390fcec570bSAlex Deucher /* default for macs */ 1391179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1392f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1393fcec570bSAlex Deucher 1394fcec570bSAlex Deucher /* XXX some macs have duallink chips */ 1395fcec570bSAlex Deucher switch (rdev->mode_info.connector_table) { 1396fcec570bSAlex Deucher case CT_POWERBOOK_EXTERNAL: 1397fcec570bSAlex Deucher case CT_MINI_EXTERNAL: 1398fcec570bSAlex Deucher default: 1399fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1400fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1401fcec570bSAlex Deucher break; 1402fcec570bSAlex Deucher } 1403fcec570bSAlex Deucher 1404fcec570bSAlex Deucher return true; 1405fcec570bSAlex Deucher } 1406fcec570bSAlex Deucher 1407fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder, 1408fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1409fcec570bSAlex Deucher { 1410fcec570bSAlex Deucher struct drm_device *dev = encoder->base.dev; 1411fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 1412fcec570bSAlex Deucher uint16_t offset; 1413179e8078SAlex Deucher uint8_t ver; 1414fcec570bSAlex Deucher enum radeon_combios_ddc gpio; 1415fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1416771fe6b9SJerome Glisse 1417fcec570bSAlex Deucher tmds->i2c_bus = NULL; 1418fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 1419179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1420f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1421fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1422fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1423fcec570bSAlex Deucher } else { 1424fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 1425fcec570bSAlex Deucher if (offset) { 1426fcec570bSAlex Deucher ver = RBIOS8(offset); 142740f76d81SAlex Deucher DRM_DEBUG_KMS("External TMDS Table revision: %d\n", ver); 1428fcec570bSAlex Deucher tmds->slave_addr = RBIOS8(offset + 4 + 2); 1429fcec570bSAlex Deucher tmds->slave_addr >>= 1; /* 7 bit addressing */ 1430fcec570bSAlex Deucher gpio = RBIOS8(offset + 4 + 3); 1431179e8078SAlex Deucher if (gpio == DDC_LCD) { 1432179e8078SAlex Deucher /* MM i2c */ 143340bacf16SAlex Deucher i2c_bus.valid = true; 143440bacf16SAlex Deucher i2c_bus.hw_capable = true; 143540bacf16SAlex Deucher i2c_bus.mm_i2c = true; 1436179e8078SAlex Deucher i2c_bus.i2c_id = 0xa0; 1437179e8078SAlex Deucher } else 1438179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0); 1439f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1440fcec570bSAlex Deucher } 1441fcec570bSAlex Deucher } 1442fcec570bSAlex Deucher 1443fcec570bSAlex Deucher if (!tmds->i2c_bus) { 1444fcec570bSAlex Deucher DRM_INFO("No valid Ext TMDS info found in BIOS\n"); 1445fcec570bSAlex Deucher return false; 1446fcec570bSAlex Deucher } 1447fcec570bSAlex Deucher 1448fcec570bSAlex Deucher return true; 1449fcec570bSAlex Deucher } 1450771fe6b9SJerome Glisse 1451771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) 1452771fe6b9SJerome Glisse { 1453771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1454771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 1455eed45b30SAlex Deucher struct radeon_hpd hpd; 1456771fe6b9SJerome Glisse 1457771fe6b9SJerome Glisse rdev->mode_info.connector_table = radeon_connector_table; 1458771fe6b9SJerome Glisse if (rdev->mode_info.connector_table == CT_NONE) { 1459771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 146071a157e8SGrant Likely if (of_machine_is_compatible("PowerBook3,3")) { 1461771fe6b9SJerome Glisse /* powerbook with VGA */ 1462771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_VGA; 146371a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook3,4") || 146471a157e8SGrant Likely of_machine_is_compatible("PowerBook3,5")) { 1465771fe6b9SJerome Glisse /* powerbook with internal tmds */ 1466771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; 146771a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,1") || 146871a157e8SGrant Likely of_machine_is_compatible("PowerBook5,2") || 146971a157e8SGrant Likely of_machine_is_compatible("PowerBook5,3") || 147071a157e8SGrant Likely of_machine_is_compatible("PowerBook5,4") || 147171a157e8SGrant Likely of_machine_is_compatible("PowerBook5,5")) { 1472771fe6b9SJerome Glisse /* powerbook with external single link tmds (sil164) */ 1473771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 147471a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,6")) { 1475771fe6b9SJerome Glisse /* powerbook with external dual or single link tmds */ 1476771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 147771a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,7") || 147871a157e8SGrant Likely of_machine_is_compatible("PowerBook5,8") || 147971a157e8SGrant Likely of_machine_is_compatible("PowerBook5,9")) { 1480771fe6b9SJerome Glisse /* PowerBook6,2 ? */ 1481771fe6b9SJerome Glisse /* powerbook with external dual link tmds (sil1178?) */ 1482771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 148371a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook4,1") || 148471a157e8SGrant Likely of_machine_is_compatible("PowerBook4,2") || 148571a157e8SGrant Likely of_machine_is_compatible("PowerBook4,3") || 148671a157e8SGrant Likely of_machine_is_compatible("PowerBook6,3") || 148771a157e8SGrant Likely of_machine_is_compatible("PowerBook6,5") || 148871a157e8SGrant Likely of_machine_is_compatible("PowerBook6,7")) { 1489771fe6b9SJerome Glisse /* ibook */ 1490771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IBOOK; 1491cafa59b9SAlex Deucher } else if (of_machine_is_compatible("PowerMac3,5")) { 1492cafa59b9SAlex Deucher /* PowerMac G4 Silver radeon 7500 */ 1493cafa59b9SAlex Deucher rdev->mode_info.connector_table = CT_MAC_G4_SILVER; 149471a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac4,4")) { 1495771fe6b9SJerome Glisse /* emac */ 1496771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_EMAC; 149771a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac10,1")) { 1498771fe6b9SJerome Glisse /* mini with internal tmds */ 1499771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_INTERNAL; 150071a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac10,2")) { 1501771fe6b9SJerome Glisse /* mini with external tmds */ 1502771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_EXTERNAL; 150371a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac12,1")) { 1504771fe6b9SJerome Glisse /* PowerMac8,1 ? */ 1505771fe6b9SJerome Glisse /* imac g5 isight */ 1506771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; 1507aa74fbb4SAlex Deucher } else if ((rdev->pdev->device == 0x4a48) && 1508aa74fbb4SAlex Deucher (rdev->pdev->subsystem_vendor == 0x1002) && 1509aa74fbb4SAlex Deucher (rdev->pdev->subsystem_device == 0x4a48)) { 1510aa74fbb4SAlex Deucher /* Mac X800 */ 1511aa74fbb4SAlex Deucher rdev->mode_info.connector_table = CT_MAC_X800; 15127c88d2b8SAlex Deucher } else if ((of_machine_is_compatible("PowerMac7,2") || 15137c88d2b8SAlex Deucher of_machine_is_compatible("PowerMac7,3")) && 15147c88d2b8SAlex Deucher (rdev->pdev->device == 0x4150) && 15157c88d2b8SAlex Deucher (rdev->pdev->subsystem_vendor == 0x1002) && 15167c88d2b8SAlex Deucher (rdev->pdev->subsystem_device == 0x4150)) { 15177c88d2b8SAlex Deucher /* Mac G5 tower 9600 */ 15189fad321aSAlex Deucher rdev->mode_info.connector_table = CT_MAC_G5_9600; 15196a556039SAlex Deucher } else if ((rdev->pdev->device == 0x4c66) && 15206a556039SAlex Deucher (rdev->pdev->subsystem_vendor == 0x1002) && 15216a556039SAlex Deucher (rdev->pdev->subsystem_device == 0x4c66)) { 15226a556039SAlex Deucher /* SAM440ep RV250 embedded board */ 15236a556039SAlex Deucher rdev->mode_info.connector_table = CT_SAM440EP; 1524771fe6b9SJerome Glisse } else 1525771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 152676a7142aSDave Airlie #ifdef CONFIG_PPC64 152776a7142aSDave Airlie if (ASIC_IS_RN50(rdev)) 152876a7142aSDave Airlie rdev->mode_info.connector_table = CT_RN50_POWER; 152976a7142aSDave Airlie else 153076a7142aSDave Airlie #endif 1531771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_GENERIC; 1532771fe6b9SJerome Glisse } 1533771fe6b9SJerome Glisse 1534771fe6b9SJerome Glisse switch (rdev->mode_info.connector_table) { 1535771fe6b9SJerome Glisse case CT_GENERIC: 1536771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (generic)\n", 1537771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1538771fe6b9SJerome Glisse /* these are the most common settings */ 1539771fe6b9SJerome Glisse if (rdev->flags & RADEON_SINGLE_CRTC) { 1540771fe6b9SJerome Glisse /* VGA - primary dac */ 1541179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1542eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1543771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15445137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1545771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1546771fe6b9SJerome Glisse 1), 1547771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1548771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1549771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1550771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1551b75fad06SAlex Deucher &ddc_i2c, 1552eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1553eed45b30SAlex Deucher &hpd); 1554771fe6b9SJerome Glisse } else if (rdev->flags & RADEON_IS_MOBILITY) { 1555771fe6b9SJerome Glisse /* LVDS */ 1556179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_NONE_DETECTED, 0, 0); 1557eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1558771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15595137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1560771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1561771fe6b9SJerome Glisse 0), 1562771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1563771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1564771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1565771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 1566b75fad06SAlex Deucher &ddc_i2c, 1567eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1568eed45b30SAlex Deucher &hpd); 1569771fe6b9SJerome Glisse 1570771fe6b9SJerome Glisse /* VGA - primary dac */ 1571179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1572eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1573771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15745137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1575771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1576771fe6b9SJerome Glisse 1), 1577771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1578771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1579771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1580771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1581b75fad06SAlex Deucher &ddc_i2c, 1582eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1583eed45b30SAlex Deucher &hpd); 1584771fe6b9SJerome Glisse } else { 1585771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1586179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1587eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 1588771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15895137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1590771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1591771fe6b9SJerome Glisse 0), 1592771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1593771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15945137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1595771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1596771fe6b9SJerome Glisse 2), 1597771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1598771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1599771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1600771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1601771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 1602b75fad06SAlex Deucher &ddc_i2c, 1603eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1604eed45b30SAlex Deucher &hpd); 1605771fe6b9SJerome Glisse 1606771fe6b9SJerome Glisse /* VGA - primary dac */ 1607179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1608eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1609771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16105137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1611771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1612771fe6b9SJerome Glisse 1), 1613771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1614771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1615771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1616771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1617b75fad06SAlex Deucher &ddc_i2c, 1618eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1619eed45b30SAlex Deucher &hpd); 1620771fe6b9SJerome Glisse } 1621771fe6b9SJerome Glisse 1622771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 1623771fe6b9SJerome Glisse /* TV - tv dac */ 1624eed45b30SAlex Deucher ddc_i2c.valid = false; 1625eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1626771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16275137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1628771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1629771fe6b9SJerome Glisse 2), 1630771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1631771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, 1632771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1633771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1634b75fad06SAlex Deucher &ddc_i2c, 1635eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1636eed45b30SAlex Deucher &hpd); 1637771fe6b9SJerome Glisse } 1638771fe6b9SJerome Glisse break; 1639771fe6b9SJerome Glisse case CT_IBOOK: 1640771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (ibook)\n", 1641771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1642771fe6b9SJerome Glisse /* LVDS */ 1643179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1644eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1645771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16465137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1647771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1648771fe6b9SJerome Glisse 0), 1649771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1650771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1651b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1652eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1653eed45b30SAlex Deucher &hpd); 1654771fe6b9SJerome Glisse /* VGA - TV DAC */ 1655179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1656eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1657771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16585137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1659771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1660771fe6b9SJerome Glisse 2), 1661771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1662771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1663b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1664eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1665eed45b30SAlex Deucher &hpd); 1666771fe6b9SJerome Glisse /* TV - TV DAC */ 1667eed45b30SAlex Deucher ddc_i2c.valid = false; 1668eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1669771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16705137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1671771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1672771fe6b9SJerome Glisse 2), 1673771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1674771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1675771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1676b75fad06SAlex Deucher &ddc_i2c, 1677eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1678eed45b30SAlex Deucher &hpd); 1679771fe6b9SJerome Glisse break; 1680771fe6b9SJerome Glisse case CT_POWERBOOK_EXTERNAL: 1681771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook external tmds)\n", 1682771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1683771fe6b9SJerome Glisse /* LVDS */ 1684179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1685eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1686771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16875137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1688771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1689771fe6b9SJerome Glisse 0), 1690771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1691771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1692b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1693eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1694eed45b30SAlex Deucher &hpd); 1695771fe6b9SJerome Glisse /* DVI-I - primary dac, ext tmds */ 1696179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1697eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1698771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16995137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1700771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1701771fe6b9SJerome Glisse 0), 1702771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1703771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17045137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1705771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1706771fe6b9SJerome Glisse 1), 1707771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1708b75fad06SAlex Deucher /* XXX some are SL */ 1709771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1710771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1711771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1712b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1713eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 1714eed45b30SAlex Deucher &hpd); 1715771fe6b9SJerome Glisse /* TV - TV DAC */ 1716eed45b30SAlex Deucher ddc_i2c.valid = false; 1717eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1718771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17195137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1720771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1721771fe6b9SJerome Glisse 2), 1722771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1723771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1724771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1725b75fad06SAlex Deucher &ddc_i2c, 1726eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1727eed45b30SAlex Deucher &hpd); 1728771fe6b9SJerome Glisse break; 1729771fe6b9SJerome Glisse case CT_POWERBOOK_INTERNAL: 1730771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook internal tmds)\n", 1731771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1732771fe6b9SJerome Glisse /* LVDS */ 1733179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1734eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1735771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17365137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1737771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1738771fe6b9SJerome Glisse 0), 1739771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1740771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1741b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1742eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1743eed45b30SAlex Deucher &hpd); 1744771fe6b9SJerome Glisse /* DVI-I - primary dac, int tmds */ 1745179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1746eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1747771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17485137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1749771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1750771fe6b9SJerome Glisse 0), 1751771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1752771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17535137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1754771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1755771fe6b9SJerome Glisse 1), 1756771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1757771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1758771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1759771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1760b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1761eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1762eed45b30SAlex Deucher &hpd); 1763771fe6b9SJerome Glisse /* TV - TV DAC */ 1764eed45b30SAlex Deucher ddc_i2c.valid = false; 1765eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1766771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17675137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1768771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1769771fe6b9SJerome Glisse 2), 1770771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1771771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1772771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1773b75fad06SAlex Deucher &ddc_i2c, 1774eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1775eed45b30SAlex Deucher &hpd); 1776771fe6b9SJerome Glisse break; 1777771fe6b9SJerome Glisse case CT_POWERBOOK_VGA: 1778771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook vga)\n", 1779771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1780771fe6b9SJerome Glisse /* LVDS */ 1781179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1782eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1783771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17845137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1785771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1786771fe6b9SJerome Glisse 0), 1787771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1788771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1789b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1790eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1791eed45b30SAlex Deucher &hpd); 1792771fe6b9SJerome Glisse /* VGA - primary dac */ 1793179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1794eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1795771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17965137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1797771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1798771fe6b9SJerome Glisse 1), 1799771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1800771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT, 1801b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1802eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1803eed45b30SAlex Deucher &hpd); 1804771fe6b9SJerome Glisse /* TV - TV DAC */ 1805eed45b30SAlex Deucher ddc_i2c.valid = false; 1806eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1807771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18085137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1809771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1810771fe6b9SJerome Glisse 2), 1811771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1812771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1813771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1814b75fad06SAlex Deucher &ddc_i2c, 1815eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1816eed45b30SAlex Deucher &hpd); 1817771fe6b9SJerome Glisse break; 1818771fe6b9SJerome Glisse case CT_MINI_EXTERNAL: 1819771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini external tmds)\n", 1820771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1821771fe6b9SJerome Glisse /* DVI-I - tv dac, ext tmds */ 1822179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1823eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1824771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18255137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1826771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1827771fe6b9SJerome Glisse 0), 1828771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1829771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18305137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1831771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1832771fe6b9SJerome Glisse 2), 1833771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1834b75fad06SAlex Deucher /* XXX are any DL? */ 1835771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1836771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1837771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1838b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1839eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1840eed45b30SAlex Deucher &hpd); 1841771fe6b9SJerome Glisse /* TV - TV DAC */ 1842eed45b30SAlex Deucher ddc_i2c.valid = false; 1843eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1844771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18455137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1846771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1847771fe6b9SJerome Glisse 2), 1848771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1849771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1850771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1851b75fad06SAlex Deucher &ddc_i2c, 1852eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1853eed45b30SAlex Deucher &hpd); 1854771fe6b9SJerome Glisse break; 1855771fe6b9SJerome Glisse case CT_MINI_INTERNAL: 1856771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini internal tmds)\n", 1857771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1858771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1859179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1860eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1861771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18625137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1863771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1864771fe6b9SJerome Glisse 0), 1865771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1866771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18675137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1868771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1869771fe6b9SJerome Glisse 2), 1870771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1871771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1872771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1873771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1874b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1875eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1876eed45b30SAlex Deucher &hpd); 1877771fe6b9SJerome Glisse /* TV - TV DAC */ 1878eed45b30SAlex Deucher ddc_i2c.valid = false; 1879eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1880771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18815137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1882771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1883771fe6b9SJerome Glisse 2), 1884771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1885771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1886771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1887b75fad06SAlex Deucher &ddc_i2c, 1888eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1889eed45b30SAlex Deucher &hpd); 1890771fe6b9SJerome Glisse break; 1891771fe6b9SJerome Glisse case CT_IMAC_G5_ISIGHT: 1892771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (imac g5 isight)\n", 1893771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1894771fe6b9SJerome Glisse /* DVI-D - int tmds */ 1895179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1896eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1897771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18985137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1899771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1900771fe6b9SJerome Glisse 0), 1901771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1902771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT, 1903b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVID, &ddc_i2c, 1904eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 1905eed45b30SAlex Deucher &hpd); 1906771fe6b9SJerome Glisse /* VGA - tv dac */ 1907179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1908eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1909771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19105137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1911771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1912771fe6b9SJerome Glisse 2), 1913771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1914771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1915b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1916eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1917eed45b30SAlex Deucher &hpd); 1918771fe6b9SJerome Glisse /* TV - TV DAC */ 1919eed45b30SAlex Deucher ddc_i2c.valid = false; 1920eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1921771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19225137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1923771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1924771fe6b9SJerome Glisse 2), 1925771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1926771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1927771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1928b75fad06SAlex Deucher &ddc_i2c, 1929eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1930eed45b30SAlex Deucher &hpd); 1931771fe6b9SJerome Glisse break; 1932771fe6b9SJerome Glisse case CT_EMAC: 1933771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (emac)\n", 1934771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1935771fe6b9SJerome Glisse /* VGA - primary dac */ 1936179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1937eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1938771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19395137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1940771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1941771fe6b9SJerome Glisse 1), 1942771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1943771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 1944b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1945eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1946eed45b30SAlex Deucher &hpd); 1947771fe6b9SJerome Glisse /* VGA - tv dac */ 1948179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1949eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1950771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19515137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1952771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1953771fe6b9SJerome Glisse 2), 1954771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1955771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1956b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1957eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1958eed45b30SAlex Deucher &hpd); 1959771fe6b9SJerome Glisse /* TV - TV DAC */ 1960eed45b30SAlex Deucher ddc_i2c.valid = false; 1961eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1962771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19635137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1964771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1965771fe6b9SJerome Glisse 2), 1966771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1967771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1968771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1969b75fad06SAlex Deucher &ddc_i2c, 1970eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1971eed45b30SAlex Deucher &hpd); 1972771fe6b9SJerome Glisse break; 197376a7142aSDave Airlie case CT_RN50_POWER: 197476a7142aSDave Airlie DRM_INFO("Connector Table: %d (rn50-power)\n", 197576a7142aSDave Airlie rdev->mode_info.connector_table); 197676a7142aSDave Airlie /* VGA - primary dac */ 1977179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 197876a7142aSDave Airlie hpd.hpd = RADEON_HPD_NONE; 197976a7142aSDave Airlie radeon_add_legacy_encoder(dev, 19805137ee94SAlex Deucher radeon_get_encoder_enum(dev, 198176a7142aSDave Airlie ATOM_DEVICE_CRT1_SUPPORT, 198276a7142aSDave Airlie 1), 198376a7142aSDave Airlie ATOM_DEVICE_CRT1_SUPPORT); 198476a7142aSDave Airlie radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 198576a7142aSDave Airlie DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 198676a7142aSDave Airlie CONNECTOR_OBJECT_ID_VGA, 198776a7142aSDave Airlie &hpd); 1988179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 198976a7142aSDave Airlie hpd.hpd = RADEON_HPD_NONE; 199076a7142aSDave Airlie radeon_add_legacy_encoder(dev, 19915137ee94SAlex Deucher radeon_get_encoder_enum(dev, 199276a7142aSDave Airlie ATOM_DEVICE_CRT2_SUPPORT, 199376a7142aSDave Airlie 2), 199476a7142aSDave Airlie ATOM_DEVICE_CRT2_SUPPORT); 199576a7142aSDave Airlie radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 199676a7142aSDave Airlie DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 199776a7142aSDave Airlie CONNECTOR_OBJECT_ID_VGA, 199876a7142aSDave Airlie &hpd); 199976a7142aSDave Airlie break; 2000aa74fbb4SAlex Deucher case CT_MAC_X800: 2001aa74fbb4SAlex Deucher DRM_INFO("Connector Table: %d (mac x800)\n", 2002aa74fbb4SAlex Deucher rdev->mode_info.connector_table); 2003aa74fbb4SAlex Deucher /* DVI - primary dac, internal tmds */ 2004aa74fbb4SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 2005aa74fbb4SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 2006aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2007aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2008aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 2009aa74fbb4SAlex Deucher 0), 2010aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 2011aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2012aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2013aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2014aa74fbb4SAlex Deucher 1), 2015aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 2016aa74fbb4SAlex Deucher radeon_add_legacy_connector(dev, 0, 2017aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 2018aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2019aa74fbb4SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 2020aa74fbb4SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2021aa74fbb4SAlex Deucher &hpd); 2022aa74fbb4SAlex Deucher /* DVI - tv dac, dvo */ 2023aa74fbb4SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 2024aa74fbb4SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 2025aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2026aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2027aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT, 2028aa74fbb4SAlex Deucher 0), 2029aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT); 2030aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2031aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2032aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2033aa74fbb4SAlex Deucher 2), 2034aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 2035aa74fbb4SAlex Deucher radeon_add_legacy_connector(dev, 1, 2036aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT | 2037aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2038aa74fbb4SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 2039aa74fbb4SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 2040aa74fbb4SAlex Deucher &hpd); 2041aa74fbb4SAlex Deucher break; 20429fad321aSAlex Deucher case CT_MAC_G5_9600: 20439fad321aSAlex Deucher DRM_INFO("Connector Table: %d (mac g5 9600)\n", 20449fad321aSAlex Deucher rdev->mode_info.connector_table); 20459fad321aSAlex Deucher /* DVI - tv dac, dvo */ 20469fad321aSAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 20479fad321aSAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 20489fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20499fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20509fad321aSAlex Deucher ATOM_DEVICE_DFP2_SUPPORT, 20519fad321aSAlex Deucher 0), 20529fad321aSAlex Deucher ATOM_DEVICE_DFP2_SUPPORT); 20539fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20549fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20559fad321aSAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 20569fad321aSAlex Deucher 2), 20579fad321aSAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 20589fad321aSAlex Deucher radeon_add_legacy_connector(dev, 0, 20599fad321aSAlex Deucher ATOM_DEVICE_DFP2_SUPPORT | 20609fad321aSAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 20619fad321aSAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 20629fad321aSAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 20639fad321aSAlex Deucher &hpd); 20649fad321aSAlex Deucher /* ADC - primary dac, internal tmds */ 20659fad321aSAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 20669fad321aSAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 20679fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20689fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20699fad321aSAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 20709fad321aSAlex Deucher 0), 20719fad321aSAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 20729fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20739fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20749fad321aSAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 20759fad321aSAlex Deucher 1), 20769fad321aSAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 20779fad321aSAlex Deucher radeon_add_legacy_connector(dev, 1, 20789fad321aSAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 20799fad321aSAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 20809fad321aSAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 20819fad321aSAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 20829fad321aSAlex Deucher &hpd); 2083beb47274SAlex Deucher /* TV - TV DAC */ 2084beb47274SAlex Deucher ddc_i2c.valid = false; 2085beb47274SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2086beb47274SAlex Deucher radeon_add_legacy_encoder(dev, 2087beb47274SAlex Deucher radeon_get_encoder_enum(dev, 2088beb47274SAlex Deucher ATOM_DEVICE_TV1_SUPPORT, 2089beb47274SAlex Deucher 2), 2090beb47274SAlex Deucher ATOM_DEVICE_TV1_SUPPORT); 2091beb47274SAlex Deucher radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 2092beb47274SAlex Deucher DRM_MODE_CONNECTOR_SVIDEO, 2093beb47274SAlex Deucher &ddc_i2c, 2094beb47274SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2095beb47274SAlex Deucher &hpd); 20969fad321aSAlex Deucher break; 20976a556039SAlex Deucher case CT_SAM440EP: 20986a556039SAlex Deucher DRM_INFO("Connector Table: %d (SAM440ep embedded board)\n", 20996a556039SAlex Deucher rdev->mode_info.connector_table); 21006a556039SAlex Deucher /* LVDS */ 21016a556039SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_NONE_DETECTED, 0, 0); 21026a556039SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 21036a556039SAlex Deucher radeon_add_legacy_encoder(dev, 21046a556039SAlex Deucher radeon_get_encoder_enum(dev, 21056a556039SAlex Deucher ATOM_DEVICE_LCD1_SUPPORT, 21066a556039SAlex Deucher 0), 21076a556039SAlex Deucher ATOM_DEVICE_LCD1_SUPPORT); 21086a556039SAlex Deucher radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 21096a556039SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 21106a556039SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 21116a556039SAlex Deucher &hpd); 21126a556039SAlex Deucher /* DVI-I - secondary dac, int tmds */ 21136a556039SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 21146a556039SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 21156a556039SAlex Deucher radeon_add_legacy_encoder(dev, 21166a556039SAlex Deucher radeon_get_encoder_enum(dev, 21176a556039SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 21186a556039SAlex Deucher 0), 21196a556039SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 21206a556039SAlex Deucher radeon_add_legacy_encoder(dev, 21216a556039SAlex Deucher radeon_get_encoder_enum(dev, 21226a556039SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 21236a556039SAlex Deucher 2), 21246a556039SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 21256a556039SAlex Deucher radeon_add_legacy_connector(dev, 1, 21266a556039SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 21276a556039SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 21286a556039SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 21296a556039SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 21306a556039SAlex Deucher &hpd); 21316a556039SAlex Deucher /* VGA - primary dac */ 21326a556039SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 21336a556039SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 21346a556039SAlex Deucher radeon_add_legacy_encoder(dev, 21356a556039SAlex Deucher radeon_get_encoder_enum(dev, 21366a556039SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 21376a556039SAlex Deucher 1), 21386a556039SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 21396a556039SAlex Deucher radeon_add_legacy_connector(dev, 2, 21406a556039SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 21416a556039SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 21426a556039SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 21436a556039SAlex Deucher &hpd); 21446a556039SAlex Deucher /* TV - TV DAC */ 21456a556039SAlex Deucher ddc_i2c.valid = false; 21466a556039SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 21476a556039SAlex Deucher radeon_add_legacy_encoder(dev, 21486a556039SAlex Deucher radeon_get_encoder_enum(dev, 21496a556039SAlex Deucher ATOM_DEVICE_TV1_SUPPORT, 21506a556039SAlex Deucher 2), 21516a556039SAlex Deucher ATOM_DEVICE_TV1_SUPPORT); 21526a556039SAlex Deucher radeon_add_legacy_connector(dev, 3, ATOM_DEVICE_TV1_SUPPORT, 21536a556039SAlex Deucher DRM_MODE_CONNECTOR_SVIDEO, 21546a556039SAlex Deucher &ddc_i2c, 21556a556039SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 21566a556039SAlex Deucher &hpd); 21576a556039SAlex Deucher break; 2158cafa59b9SAlex Deucher case CT_MAC_G4_SILVER: 2159cafa59b9SAlex Deucher DRM_INFO("Connector Table: %d (mac g4 silver)\n", 2160cafa59b9SAlex Deucher rdev->mode_info.connector_table); 2161cafa59b9SAlex Deucher /* DVI-I - tv dac, int tmds */ 2162cafa59b9SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 2163cafa59b9SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 2164cafa59b9SAlex Deucher radeon_add_legacy_encoder(dev, 2165cafa59b9SAlex Deucher radeon_get_encoder_enum(dev, 2166cafa59b9SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 2167cafa59b9SAlex Deucher 0), 2168cafa59b9SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 2169cafa59b9SAlex Deucher radeon_add_legacy_encoder(dev, 2170cafa59b9SAlex Deucher radeon_get_encoder_enum(dev, 2171cafa59b9SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2172cafa59b9SAlex Deucher 2), 2173cafa59b9SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 2174cafa59b9SAlex Deucher radeon_add_legacy_connector(dev, 0, 2175cafa59b9SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 2176cafa59b9SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2177cafa59b9SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 2178cafa59b9SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2179cafa59b9SAlex Deucher &hpd); 2180cafa59b9SAlex Deucher /* VGA - primary dac */ 2181cafa59b9SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 2182cafa59b9SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2183cafa59b9SAlex Deucher radeon_add_legacy_encoder(dev, 2184cafa59b9SAlex Deucher radeon_get_encoder_enum(dev, 2185cafa59b9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2186cafa59b9SAlex Deucher 1), 2187cafa59b9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 2188cafa59b9SAlex Deucher radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT, 2189cafa59b9SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 2190cafa59b9SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2191cafa59b9SAlex Deucher &hpd); 2192cafa59b9SAlex Deucher /* TV - TV DAC */ 2193cafa59b9SAlex Deucher ddc_i2c.valid = false; 2194cafa59b9SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2195cafa59b9SAlex Deucher radeon_add_legacy_encoder(dev, 2196cafa59b9SAlex Deucher radeon_get_encoder_enum(dev, 2197cafa59b9SAlex Deucher ATOM_DEVICE_TV1_SUPPORT, 2198cafa59b9SAlex Deucher 2), 2199cafa59b9SAlex Deucher ATOM_DEVICE_TV1_SUPPORT); 2200cafa59b9SAlex Deucher radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 2201cafa59b9SAlex Deucher DRM_MODE_CONNECTOR_SVIDEO, 2202cafa59b9SAlex Deucher &ddc_i2c, 2203cafa59b9SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2204cafa59b9SAlex Deucher &hpd); 2205cafa59b9SAlex Deucher break; 2206771fe6b9SJerome Glisse default: 2207771fe6b9SJerome Glisse DRM_INFO("Connector table: %d (invalid)\n", 2208771fe6b9SJerome Glisse rdev->mode_info.connector_table); 2209771fe6b9SJerome Glisse return false; 2210771fe6b9SJerome Glisse } 2211771fe6b9SJerome Glisse 2212771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2213771fe6b9SJerome Glisse 2214771fe6b9SJerome Glisse return true; 2215771fe6b9SJerome Glisse } 2216771fe6b9SJerome Glisse 2217771fe6b9SJerome Glisse static bool radeon_apply_legacy_quirks(struct drm_device *dev, 2218771fe6b9SJerome Glisse int bios_index, 2219771fe6b9SJerome Glisse enum radeon_combios_connector 2220771fe6b9SJerome Glisse *legacy_connector, 2221eed45b30SAlex Deucher struct radeon_i2c_bus_rec *ddc_i2c, 2222eed45b30SAlex Deucher struct radeon_hpd *hpd) 2223771fe6b9SJerome Glisse { 2224*d86a4126SThomas Zimmermann struct radeon_device *rdev = dev->dev_private; 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 */ 2228*d86a4126SThomas Zimmermann if (rdev->pdev->device == 0x515e && 2229*d86a4126SThomas Zimmermann rdev->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 */ 2236*d86a4126SThomas Zimmermann if (rdev->pdev->device == 0x5B60 && 2237*d86a4126SThomas Zimmermann rdev->pdev->subsystem_vendor == 0x17af && 2238*d86a4126SThomas Zimmermann rdev->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 { 2248*d86a4126SThomas Zimmermann struct radeon_device *rdev = dev->dev_private; 2249*d86a4126SThomas Zimmermann 2250790cfb34SAlex Deucher /* Acer 5102 has non-existent TV port */ 2251*d86a4126SThomas Zimmermann if (rdev->pdev->device == 0x5975 && 2252*d86a4126SThomas Zimmermann rdev->pdev->subsystem_vendor == 0x1025 && 2253*d86a4126SThomas Zimmermann rdev->pdev->subsystem_device == 0x009f) 2254790cfb34SAlex Deucher return false; 2255790cfb34SAlex Deucher 2256fc7f7119SAlex Deucher /* HP dc5750 has non-existent TV port */ 2257*d86a4126SThomas Zimmermann if (rdev->pdev->device == 0x5974 && 2258*d86a4126SThomas Zimmermann rdev->pdev->subsystem_vendor == 0x103c && 2259*d86a4126SThomas Zimmermann rdev->pdev->subsystem_device == 0x280a) 2260fc7f7119SAlex Deucher return false; 2261fc7f7119SAlex Deucher 2262fd874ad0SAlex Deucher /* MSI S270 has non-existent TV port */ 2263*d86a4126SThomas Zimmermann if (rdev->pdev->device == 0x5955 && 2264*d86a4126SThomas Zimmermann rdev->pdev->subsystem_vendor == 0x1462 && 2265*d86a4126SThomas Zimmermann rdev->pdev->subsystem_device == 0x0131) 2266fd874ad0SAlex Deucher return false; 2267fd874ad0SAlex Deucher 2268790cfb34SAlex Deucher return true; 2269790cfb34SAlex Deucher } 2270790cfb34SAlex Deucher 2271b75fad06SAlex Deucher static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d) 2272b75fad06SAlex Deucher { 2273b75fad06SAlex Deucher struct radeon_device *rdev = dev->dev_private; 2274b75fad06SAlex Deucher uint32_t ext_tmds_info; 2275b75fad06SAlex Deucher 2276b75fad06SAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2277b75fad06SAlex Deucher if (is_dvi_d) 2278b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 2279b75fad06SAlex Deucher else 2280b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2281b75fad06SAlex Deucher } 2282b75fad06SAlex Deucher ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2283b75fad06SAlex Deucher if (ext_tmds_info) { 2284b75fad06SAlex Deucher uint8_t rev = RBIOS8(ext_tmds_info); 2285b75fad06SAlex Deucher uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5); 2286b75fad06SAlex Deucher if (rev >= 3) { 2287b75fad06SAlex Deucher if (is_dvi_d) 2288b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 2289b75fad06SAlex Deucher else 2290b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 2291b75fad06SAlex Deucher } else { 2292b75fad06SAlex Deucher if (flags & 1) { 2293b75fad06SAlex Deucher if (is_dvi_d) 2294b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 2295b75fad06SAlex Deucher else 2296b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 2297b75fad06SAlex Deucher } 2298b75fad06SAlex Deucher } 2299b75fad06SAlex Deucher } 2300b75fad06SAlex Deucher if (is_dvi_d) 2301b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 2302b75fad06SAlex Deucher else 2303b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2304b75fad06SAlex Deucher } 2305b75fad06SAlex Deucher 2306771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) 2307771fe6b9SJerome Glisse { 2308771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2309771fe6b9SJerome Glisse uint32_t conn_info, entry, devices; 2310b75fad06SAlex Deucher uint16_t tmp, connector_object_id; 2311771fe6b9SJerome Glisse enum radeon_combios_ddc ddc_type; 2312771fe6b9SJerome Glisse enum radeon_combios_connector connector; 2313771fe6b9SJerome Glisse int i = 0; 2314771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 2315eed45b30SAlex Deucher struct radeon_hpd hpd; 2316771fe6b9SJerome Glisse 2317771fe6b9SJerome Glisse conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE); 2318771fe6b9SJerome Glisse if (conn_info) { 2319771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 2320771fe6b9SJerome Glisse entry = conn_info + 2 + i * 2; 2321771fe6b9SJerome Glisse 2322771fe6b9SJerome Glisse if (!RBIOS16(entry)) 2323771fe6b9SJerome Glisse break; 2324771fe6b9SJerome Glisse 2325771fe6b9SJerome Glisse tmp = RBIOS16(entry); 2326771fe6b9SJerome Glisse 2327771fe6b9SJerome Glisse connector = (tmp >> 12) & 0xf; 2328771fe6b9SJerome Glisse 2329771fe6b9SJerome Glisse ddc_type = (tmp >> 8) & 0xf; 23303d61bd42SAlex Deucher if (ddc_type == 5) 23313d61bd42SAlex Deucher ddc_i2c = radeon_combios_get_i2c_info_from_table(rdev); 23323d61bd42SAlex Deucher else 2333179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, ddc_type, 0, 0); 2334771fe6b9SJerome Glisse 2335eed45b30SAlex Deucher switch (connector) { 2336eed45b30SAlex Deucher case CONNECTOR_PROPRIETARY_LEGACY: 2337eed45b30SAlex Deucher case CONNECTOR_DVI_I_LEGACY: 2338eed45b30SAlex Deucher case CONNECTOR_DVI_D_LEGACY: 2339eed45b30SAlex Deucher if ((tmp >> 4) & 0x1) 2340eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; 2341eed45b30SAlex Deucher else 2342eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 2343eed45b30SAlex Deucher break; 2344eed45b30SAlex Deucher default: 2345eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2346eed45b30SAlex Deucher break; 2347eed45b30SAlex Deucher } 2348eed45b30SAlex Deucher 23492d152c6bSAlex Deucher if (!radeon_apply_legacy_quirks(dev, i, &connector, 2350eed45b30SAlex Deucher &ddc_i2c, &hpd)) 23512d152c6bSAlex Deucher continue; 2352771fe6b9SJerome Glisse 2353771fe6b9SJerome Glisse switch (connector) { 2354771fe6b9SJerome Glisse case CONNECTOR_PROPRIETARY_LEGACY: 2355771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) 2356771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2357771fe6b9SJerome Glisse else 2358771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2359771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23605137ee94SAlex Deucher radeon_get_encoder_enum 2361771fe6b9SJerome Glisse (dev, devices, 0), 2362771fe6b9SJerome Glisse devices); 2363771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2364771fe6b9SJerome Glisse legacy_connector_convert 2365771fe6b9SJerome Glisse [connector], 2366b75fad06SAlex Deucher &ddc_i2c, 2367eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 2368eed45b30SAlex Deucher &hpd); 2369771fe6b9SJerome Glisse break; 2370771fe6b9SJerome Glisse case CONNECTOR_CRT_LEGACY: 2371771fe6b9SJerome Glisse if (tmp & 0x1) { 2372771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT2_SUPPORT; 2373771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23745137ee94SAlex Deucher radeon_get_encoder_enum 2375771fe6b9SJerome Glisse (dev, 2376771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2377771fe6b9SJerome Glisse 2), 2378771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2379771fe6b9SJerome Glisse } else { 2380771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT1_SUPPORT; 2381771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23825137ee94SAlex Deucher radeon_get_encoder_enum 2383771fe6b9SJerome Glisse (dev, 2384771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2385771fe6b9SJerome Glisse 1), 2386771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2387771fe6b9SJerome Glisse } 2388771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2389771fe6b9SJerome Glisse i, 2390771fe6b9SJerome Glisse devices, 2391771fe6b9SJerome Glisse legacy_connector_convert 2392771fe6b9SJerome Glisse [connector], 2393b75fad06SAlex Deucher &ddc_i2c, 2394eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2395eed45b30SAlex Deucher &hpd); 2396771fe6b9SJerome Glisse break; 2397771fe6b9SJerome Glisse case CONNECTOR_DVI_I_LEGACY: 2398771fe6b9SJerome Glisse devices = 0; 2399771fe6b9SJerome Glisse if (tmp & 0x1) { 2400771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT2_SUPPORT; 2401771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24025137ee94SAlex Deucher radeon_get_encoder_enum 2403771fe6b9SJerome Glisse (dev, 2404771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2405771fe6b9SJerome Glisse 2), 2406771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2407771fe6b9SJerome Glisse } else { 2408771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT1_SUPPORT; 2409771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24105137ee94SAlex Deucher radeon_get_encoder_enum 2411771fe6b9SJerome Glisse (dev, 2412771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2413771fe6b9SJerome Glisse 1), 2414771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2415771fe6b9SJerome Glisse } 24169200ee49SAlex Deucher /* RV100 board with external TDMS bit mis-set. 24179200ee49SAlex Deucher * Actually uses internal TMDS, clear the bit. 24189200ee49SAlex Deucher */ 2419*d86a4126SThomas Zimmermann if (rdev->pdev->device == 0x5159 && 2420*d86a4126SThomas Zimmermann rdev->pdev->subsystem_vendor == 0x1014 && 2421*d86a4126SThomas Zimmermann rdev->pdev->subsystem_device == 0x029A) { 24229200ee49SAlex Deucher tmp &= ~(1 << 4); 24239200ee49SAlex Deucher } 2424771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) { 2425771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP2_SUPPORT; 2426771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24275137ee94SAlex Deucher radeon_get_encoder_enum 2428771fe6b9SJerome Glisse (dev, 2429771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 2430771fe6b9SJerome Glisse 0), 2431771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 2432b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 0); 2433771fe6b9SJerome Glisse } else { 2434771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP1_SUPPORT; 2435771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24365137ee94SAlex Deucher radeon_get_encoder_enum 2437771fe6b9SJerome Glisse (dev, 2438771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2439771fe6b9SJerome Glisse 0), 2440771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2441b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2442771fe6b9SJerome Glisse } 2443771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2444771fe6b9SJerome Glisse i, 2445771fe6b9SJerome Glisse devices, 2446771fe6b9SJerome Glisse legacy_connector_convert 2447771fe6b9SJerome Glisse [connector], 2448b75fad06SAlex Deucher &ddc_i2c, 2449eed45b30SAlex Deucher connector_object_id, 2450eed45b30SAlex Deucher &hpd); 2451771fe6b9SJerome Glisse break; 2452771fe6b9SJerome Glisse case CONNECTOR_DVI_D_LEGACY: 2453b75fad06SAlex Deucher if ((tmp >> 4) & 0x1) { 2454771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2455b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 1); 2456b75fad06SAlex Deucher } else { 2457771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2458b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2459b75fad06SAlex Deucher } 2460771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24615137ee94SAlex Deucher radeon_get_encoder_enum 2462771fe6b9SJerome Glisse (dev, devices, 0), 2463771fe6b9SJerome Glisse devices); 2464771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2465771fe6b9SJerome Glisse legacy_connector_convert 2466771fe6b9SJerome Glisse [connector], 2467b75fad06SAlex Deucher &ddc_i2c, 2468eed45b30SAlex Deucher connector_object_id, 2469eed45b30SAlex Deucher &hpd); 2470771fe6b9SJerome Glisse break; 2471771fe6b9SJerome Glisse case CONNECTOR_CTV_LEGACY: 2472771fe6b9SJerome Glisse case CONNECTOR_STV_LEGACY: 2473771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24745137ee94SAlex Deucher radeon_get_encoder_enum 2475771fe6b9SJerome Glisse (dev, 2476771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2477771fe6b9SJerome Glisse 2), 2478771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2479771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, 2480771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2481771fe6b9SJerome Glisse legacy_connector_convert 2482771fe6b9SJerome Glisse [connector], 2483b75fad06SAlex Deucher &ddc_i2c, 2484eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2485eed45b30SAlex Deucher &hpd); 2486771fe6b9SJerome Glisse break; 2487771fe6b9SJerome Glisse default: 2488771fe6b9SJerome Glisse DRM_ERROR("Unknown connector type: %d\n", 2489771fe6b9SJerome Glisse connector); 2490771fe6b9SJerome Glisse continue; 2491771fe6b9SJerome Glisse } 2492771fe6b9SJerome Glisse 2493771fe6b9SJerome Glisse } 2494771fe6b9SJerome Glisse } else { 2495771fe6b9SJerome Glisse uint16_t tmds_info = 2496771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 2497771fe6b9SJerome Glisse if (tmds_info) { 2498d9fdaafbSDave Airlie DRM_DEBUG_KMS("Found DFP table, assuming DVI connector\n"); 2499771fe6b9SJerome Glisse 2500771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 25015137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2502771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2503771fe6b9SJerome Glisse 1), 2504771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2505771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 25065137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2507771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2508771fe6b9SJerome Glisse 0), 2509771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2510771fe6b9SJerome Glisse 2511179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 25128e36ed00SAlex Deucher hpd.hpd = RADEON_HPD_1; 2513771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2514771fe6b9SJerome Glisse 0, 2515771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT | 2516771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2517771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 2518b75fad06SAlex Deucher &ddc_i2c, 2519eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2520eed45b30SAlex Deucher &hpd); 2521771fe6b9SJerome Glisse } else { 2522d0c403e9SAlex Deucher uint16_t crt_info = 2523d0c403e9SAlex Deucher combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 2524d9fdaafbSDave Airlie DRM_DEBUG_KMS("Found CRT table, assuming VGA connector\n"); 2525d0c403e9SAlex Deucher if (crt_info) { 2526d0c403e9SAlex Deucher radeon_add_legacy_encoder(dev, 25275137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2528d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2529d0c403e9SAlex Deucher 1), 2530d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 2531179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 2532eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2533d0c403e9SAlex Deucher radeon_add_legacy_connector(dev, 2534d0c403e9SAlex Deucher 0, 2535d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2536d0c403e9SAlex Deucher DRM_MODE_CONNECTOR_VGA, 2537b75fad06SAlex Deucher &ddc_i2c, 2538eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2539eed45b30SAlex Deucher &hpd); 2540d0c403e9SAlex Deucher } else { 2541d9fdaafbSDave Airlie DRM_DEBUG_KMS("No connector info found\n"); 2542771fe6b9SJerome Glisse return false; 2543771fe6b9SJerome Glisse } 2544771fe6b9SJerome Glisse } 2545d0c403e9SAlex Deucher } 2546771fe6b9SJerome Glisse 2547771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) { 2548771fe6b9SJerome Glisse uint16_t lcd_info = 2549771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 2550771fe6b9SJerome Glisse if (lcd_info) { 2551771fe6b9SJerome Glisse uint16_t lcd_ddc_info = 2552771fe6b9SJerome Glisse combios_get_table_offset(dev, 2553771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE); 2554771fe6b9SJerome Glisse 2555771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 25565137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2557771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2558771fe6b9SJerome Glisse 0), 2559771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 2560771fe6b9SJerome Glisse 2561771fe6b9SJerome Glisse if (lcd_ddc_info) { 2562771fe6b9SJerome Glisse ddc_type = RBIOS8(lcd_ddc_info + 2); 2563771fe6b9SJerome Glisse switch (ddc_type) { 2564771fe6b9SJerome Glisse case DDC_LCD: 2565771fe6b9SJerome Glisse ddc_i2c = 2566179e8078SAlex Deucher combios_setup_i2c_bus(rdev, 2567179e8078SAlex Deucher DDC_LCD, 2568179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 3), 2569179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 7)); 2570f376b94fSAlex Deucher radeon_i2c_add(rdev, &ddc_i2c, "LCD"); 2571771fe6b9SJerome Glisse break; 2572771fe6b9SJerome Glisse case DDC_GPIO: 2573771fe6b9SJerome Glisse ddc_i2c = 2574179e8078SAlex Deucher combios_setup_i2c_bus(rdev, 2575179e8078SAlex Deucher DDC_GPIO, 2576179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 3), 2577179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 7)); 2578f376b94fSAlex Deucher radeon_i2c_add(rdev, &ddc_i2c, "LCD"); 2579771fe6b9SJerome Glisse break; 2580771fe6b9SJerome Glisse default: 2581179e8078SAlex Deucher ddc_i2c = 2582179e8078SAlex Deucher combios_setup_i2c_bus(rdev, ddc_type, 0, 0); 2583771fe6b9SJerome Glisse break; 2584771fe6b9SJerome Glisse } 2585d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD DDC Info Table found!\n"); 2586771fe6b9SJerome Glisse } else 2587771fe6b9SJerome Glisse ddc_i2c.valid = false; 2588771fe6b9SJerome Glisse 2589eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2590771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2591771fe6b9SJerome Glisse 5, 2592771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2593771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 2594b75fad06SAlex Deucher &ddc_i2c, 2595eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 2596eed45b30SAlex Deucher &hpd); 2597771fe6b9SJerome Glisse } 2598771fe6b9SJerome Glisse } 2599771fe6b9SJerome Glisse 2600771fe6b9SJerome Glisse /* check TV table */ 2601771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 2602771fe6b9SJerome Glisse uint32_t tv_info = 2603771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 2604771fe6b9SJerome Glisse if (tv_info) { 2605771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 2606790cfb34SAlex Deucher if (radeon_apply_legacy_tv_quirks(dev)) { 2607eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2608d294ed69SDave Airlie ddc_i2c.valid = false; 2609771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 26105137ee94SAlex Deucher radeon_get_encoder_enum 2611771fe6b9SJerome Glisse (dev, 2612771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2613771fe6b9SJerome Glisse 2), 2614771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2615771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 6, 2616771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2617771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 2618b75fad06SAlex Deucher &ddc_i2c, 2619eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2620eed45b30SAlex Deucher &hpd); 2621771fe6b9SJerome Glisse } 2622771fe6b9SJerome Glisse } 2623771fe6b9SJerome Glisse } 2624790cfb34SAlex Deucher } 2625771fe6b9SJerome Glisse 2626771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2627771fe6b9SJerome Glisse 2628771fe6b9SJerome Glisse return true; 2629771fe6b9SJerome Glisse } 2630771fe6b9SJerome Glisse 263163f7d982SAlex Deucher static const char *thermal_controller_names[] = { 263263f7d982SAlex Deucher "NONE", 263363f7d982SAlex Deucher "lm63", 263463f7d982SAlex Deucher "adm1032", 263563f7d982SAlex Deucher }; 263663f7d982SAlex Deucher 263756278a8eSAlex Deucher void radeon_combios_get_power_modes(struct radeon_device *rdev) 263856278a8eSAlex Deucher { 263956278a8eSAlex Deucher struct drm_device *dev = rdev->ddev; 264056278a8eSAlex Deucher u16 offset, misc, misc2 = 0; 264177441f77Szhengbin u8 rev, tmp; 264256278a8eSAlex Deucher int state_index = 0; 2643c41b9ee9SAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 264456278a8eSAlex Deucher 2645a48b9b4eSAlex Deucher rdev->pm.default_power_state_index = -1; 264656278a8eSAlex Deucher 26470975b162SAlex Deucher /* allocate 2 power states */ 26486396bb22SKees Cook rdev->pm.power_state = kcalloc(2, sizeof(struct radeon_power_state), 26496396bb22SKees Cook GFP_KERNEL); 2650a7c36fd8SAlex Deucher if (rdev->pm.power_state) { 2651a7c36fd8SAlex Deucher /* allocate 1 clock mode per state */ 2652a7c36fd8SAlex Deucher rdev->pm.power_state[0].clock_info = 26536396bb22SKees Cook kcalloc(1, sizeof(struct radeon_pm_clock_info), 26546396bb22SKees Cook GFP_KERNEL); 2655a7c36fd8SAlex Deucher rdev->pm.power_state[1].clock_info = 26566396bb22SKees Cook kcalloc(1, sizeof(struct radeon_pm_clock_info), 26576396bb22SKees Cook GFP_KERNEL); 2658a7c36fd8SAlex Deucher if (!rdev->pm.power_state[0].clock_info || 2659a7c36fd8SAlex Deucher !rdev->pm.power_state[1].clock_info) 2660a7c36fd8SAlex Deucher goto pm_failed; 2661a7c36fd8SAlex Deucher } else 2662a7c36fd8SAlex Deucher goto pm_failed; 26630975b162SAlex Deucher 266463f7d982SAlex Deucher /* check for a thermal chip */ 266563f7d982SAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_OVERDRIVE_INFO_TABLE); 266663f7d982SAlex Deucher if (offset) { 266763f7d982SAlex Deucher u8 thermal_controller = 0, gpio = 0, i2c_addr = 0, clk_bit = 0, data_bit = 0; 266863f7d982SAlex Deucher 266963f7d982SAlex Deucher rev = RBIOS8(offset); 267063f7d982SAlex Deucher 267163f7d982SAlex Deucher if (rev == 0) { 267263f7d982SAlex Deucher thermal_controller = RBIOS8(offset + 3); 267363f7d982SAlex Deucher gpio = RBIOS8(offset + 4) & 0x3f; 267463f7d982SAlex Deucher i2c_addr = RBIOS8(offset + 5); 267563f7d982SAlex Deucher } else if (rev == 1) { 267663f7d982SAlex Deucher thermal_controller = RBIOS8(offset + 4); 267763f7d982SAlex Deucher gpio = RBIOS8(offset + 5) & 0x3f; 267863f7d982SAlex Deucher i2c_addr = RBIOS8(offset + 6); 267963f7d982SAlex Deucher } else if (rev == 2) { 268063f7d982SAlex Deucher thermal_controller = RBIOS8(offset + 4); 268163f7d982SAlex Deucher gpio = RBIOS8(offset + 5) & 0x3f; 268263f7d982SAlex Deucher i2c_addr = RBIOS8(offset + 6); 268363f7d982SAlex Deucher clk_bit = RBIOS8(offset + 0xa); 268463f7d982SAlex Deucher data_bit = RBIOS8(offset + 0xb); 268563f7d982SAlex Deucher } 268663f7d982SAlex Deucher if ((thermal_controller > 0) && (thermal_controller < 3)) { 268763f7d982SAlex Deucher DRM_INFO("Possible %s thermal controller at 0x%02x\n", 268863f7d982SAlex Deucher thermal_controller_names[thermal_controller], 268963f7d982SAlex Deucher i2c_addr >> 1); 269063f7d982SAlex Deucher if (gpio == DDC_LCD) { 269163f7d982SAlex Deucher /* MM i2c */ 269263f7d982SAlex Deucher i2c_bus.valid = true; 269363f7d982SAlex Deucher i2c_bus.hw_capable = true; 269463f7d982SAlex Deucher i2c_bus.mm_i2c = true; 269563f7d982SAlex Deucher i2c_bus.i2c_id = 0xa0; 269663f7d982SAlex Deucher } else if (gpio == DDC_GPIO) 269763f7d982SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 1 << clk_bit, 1 << data_bit); 269863f7d982SAlex Deucher else 269963f7d982SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0); 270063f7d982SAlex Deucher rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 270163f7d982SAlex Deucher if (rdev->pm.i2c_bus) { 270263f7d982SAlex Deucher struct i2c_board_info info = { }; 270363f7d982SAlex Deucher const char *name = thermal_controller_names[thermal_controller]; 270463f7d982SAlex Deucher info.addr = i2c_addr >> 1; 270563f7d982SAlex Deucher strlcpy(info.type, name, sizeof(info.type)); 2706c7ccc1b7SWolfram Sang i2c_new_client_device(&rdev->pm.i2c_bus->adapter, &info); 270763f7d982SAlex Deucher } 270863f7d982SAlex Deucher } 2709c41b9ee9SAlex Deucher } else { 2710c41b9ee9SAlex Deucher /* boards with a thermal chip, but no overdrive table */ 2711c41b9ee9SAlex Deucher 2712c41b9ee9SAlex Deucher /* Asus 9600xt has an f75375 on the monid bus */ 2713*d86a4126SThomas Zimmermann if ((rdev->pdev->device == 0x4152) && 2714*d86a4126SThomas Zimmermann (rdev->pdev->subsystem_vendor == 0x1043) && 2715*d86a4126SThomas Zimmermann (rdev->pdev->subsystem_device == 0xc002)) { 2716c41b9ee9SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 2717c41b9ee9SAlex Deucher rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 2718c41b9ee9SAlex Deucher if (rdev->pm.i2c_bus) { 2719c41b9ee9SAlex Deucher struct i2c_board_info info = { }; 2720c41b9ee9SAlex Deucher const char *name = "f75375"; 2721c41b9ee9SAlex Deucher info.addr = 0x28; 2722c41b9ee9SAlex Deucher strlcpy(info.type, name, sizeof(info.type)); 2723c7ccc1b7SWolfram Sang i2c_new_client_device(&rdev->pm.i2c_bus->adapter, &info); 2724c41b9ee9SAlex Deucher DRM_INFO("Possible %s thermal controller at 0x%02x\n", 2725c41b9ee9SAlex Deucher name, info.addr); 2726c41b9ee9SAlex Deucher } 2727c41b9ee9SAlex Deucher } 272863f7d982SAlex Deucher } 272963f7d982SAlex Deucher 273056278a8eSAlex Deucher if (rdev->flags & RADEON_IS_MOBILITY) { 273156278a8eSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE); 273256278a8eSAlex Deucher if (offset) { 273356278a8eSAlex Deucher rev = RBIOS8(offset); 273456278a8eSAlex Deucher /* power mode 0 tends to be the only valid one */ 273556278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 273656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = RBIOS32(offset + 0x5 + 0x2); 273756278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = RBIOS32(offset + 0x5 + 0x6); 273856278a8eSAlex Deucher if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) || 273956278a8eSAlex Deucher (rdev->pm.power_state[state_index].clock_info[0].sclk == 0)) 274056278a8eSAlex Deucher goto default_mode; 27410ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 27420ec0e74fSAlex Deucher POWER_STATE_TYPE_BATTERY; 274356278a8eSAlex Deucher misc = RBIOS16(offset + 0x5 + 0x0); 274456278a8eSAlex Deucher if (rev > 4) 274556278a8eSAlex Deucher misc2 = RBIOS16(offset + 0x5 + 0xe); 274679daedc9SAlex Deucher rdev->pm.power_state[state_index].misc = misc; 274779daedc9SAlex Deucher rdev->pm.power_state[state_index].misc2 = misc2; 274856278a8eSAlex Deucher if (misc & 0x4) { 274956278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_GPIO; 275056278a8eSAlex Deucher if (misc & 0x8) 275156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 275256278a8eSAlex Deucher true; 275356278a8eSAlex Deucher else 275456278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 275556278a8eSAlex Deucher false; 275656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = true; 275756278a8eSAlex Deucher if (rev < 6) { 275856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 275956278a8eSAlex Deucher RBIOS16(offset + 0x5 + 0xb) * 4; 276056278a8eSAlex Deucher tmp = RBIOS8(offset + 0x5 + 0xd); 276156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 276256278a8eSAlex Deucher } else { 276356278a8eSAlex Deucher u8 entries = RBIOS8(offset + 0x5 + 0xb); 276456278a8eSAlex Deucher u16 voltage_table_offset = RBIOS16(offset + 0x5 + 0xc); 276556278a8eSAlex Deucher if (entries && voltage_table_offset) { 276656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 276756278a8eSAlex Deucher RBIOS16(voltage_table_offset) * 4; 276856278a8eSAlex Deucher tmp = RBIOS8(voltage_table_offset + 0x2); 276956278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 277056278a8eSAlex Deucher } else 277156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = false; 277256278a8eSAlex Deucher } 277356278a8eSAlex Deucher switch ((misc2 & 0x700) >> 8) { 277456278a8eSAlex Deucher case 0: 277556278a8eSAlex Deucher default: 277656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 0; 277756278a8eSAlex Deucher break; 277856278a8eSAlex Deucher case 1: 277956278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 33; 278056278a8eSAlex Deucher break; 278156278a8eSAlex Deucher case 2: 278256278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 66; 278356278a8eSAlex Deucher break; 278456278a8eSAlex Deucher case 3: 278556278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 99; 278656278a8eSAlex Deucher break; 278756278a8eSAlex Deucher case 4: 278856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 132; 278956278a8eSAlex Deucher break; 279056278a8eSAlex Deucher } 279156278a8eSAlex Deucher } else 279256278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 279356278a8eSAlex Deucher if (rev > 6) 279479daedc9SAlex Deucher rdev->pm.power_state[state_index].pcie_lanes = 279556278a8eSAlex Deucher RBIOS8(offset + 0x5 + 0x10); 2796d7311171SAlex Deucher rdev->pm.power_state[state_index].flags = RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; 279756278a8eSAlex Deucher state_index++; 279856278a8eSAlex Deucher } else { 279956278a8eSAlex Deucher /* XXX figure out some good default low power mode for mobility cards w/out power tables */ 280056278a8eSAlex Deucher } 280156278a8eSAlex Deucher } else { 280256278a8eSAlex Deucher /* XXX figure out some good default low power mode for desktop cards */ 280356278a8eSAlex Deucher } 280456278a8eSAlex Deucher 280556278a8eSAlex Deucher default_mode: 280656278a8eSAlex Deucher /* add the default mode */ 28070ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 28080ec0e74fSAlex Deucher POWER_STATE_TYPE_DEFAULT; 280956278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 281056278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk; 281156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk; 281256278a8eSAlex Deucher rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0]; 281384d88f4cSAlex Deucher if ((state_index > 0) && 28148de016e2SAlex Deucher (rdev->pm.power_state[0].clock_info[0].voltage.type == VOLTAGE_GPIO)) 281584d88f4cSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage = 281684d88f4cSAlex Deucher rdev->pm.power_state[0].clock_info[0].voltage; 281784d88f4cSAlex Deucher else 281856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 281979daedc9SAlex Deucher rdev->pm.power_state[state_index].pcie_lanes = 16; 2820a48b9b4eSAlex Deucher rdev->pm.power_state[state_index].flags = 0; 2821a48b9b4eSAlex Deucher rdev->pm.default_power_state_index = state_index; 282256278a8eSAlex Deucher rdev->pm.num_power_states = state_index + 1; 28239038dfdfSRafał Miłecki 2824a48b9b4eSAlex Deucher rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; 2825a48b9b4eSAlex Deucher rdev->pm.current_clock_mode_index = 0; 2826a7c36fd8SAlex Deucher return; 2827a7c36fd8SAlex Deucher 2828a7c36fd8SAlex Deucher pm_failed: 2829a7c36fd8SAlex Deucher rdev->pm.default_power_state_index = state_index; 2830a7c36fd8SAlex Deucher rdev->pm.num_power_states = 0; 2831a7c36fd8SAlex Deucher 2832a7c36fd8SAlex Deucher rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; 2833a7c36fd8SAlex Deucher rdev->pm.current_clock_mode_index = 0; 283456278a8eSAlex Deucher } 283556278a8eSAlex Deucher 2836fcec570bSAlex Deucher void radeon_external_tmds_setup(struct drm_encoder *encoder) 2837fcec570bSAlex Deucher { 2838fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2839fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2840fcec570bSAlex Deucher 2841fcec570bSAlex Deucher if (!tmds) 2842fcec570bSAlex Deucher return; 2843fcec570bSAlex Deucher 2844fcec570bSAlex Deucher switch (tmds->dvo_chip) { 2845fcec570bSAlex Deucher case DVO_SIL164: 2846fcec570bSAlex Deucher /* sil 164 */ 28475a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2848fcec570bSAlex Deucher tmds->slave_addr, 2849fcec570bSAlex Deucher 0x08, 0x30); 28505a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2851fcec570bSAlex Deucher tmds->slave_addr, 2852fcec570bSAlex Deucher 0x09, 0x00); 28535a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2854fcec570bSAlex Deucher tmds->slave_addr, 2855fcec570bSAlex Deucher 0x0a, 0x90); 28565a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2857fcec570bSAlex Deucher tmds->slave_addr, 2858fcec570bSAlex Deucher 0x0c, 0x89); 28595a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2860fcec570bSAlex Deucher tmds->slave_addr, 2861fcec570bSAlex Deucher 0x08, 0x3b); 2862fcec570bSAlex Deucher break; 2863fcec570bSAlex Deucher case DVO_SIL1178: 2864fcec570bSAlex Deucher /* sil 1178 - untested */ 2865fcec570bSAlex Deucher /* 2866fcec570bSAlex Deucher * 0x0f, 0x44 2867fcec570bSAlex Deucher * 0x0f, 0x4c 2868fcec570bSAlex Deucher * 0x0e, 0x01 2869fcec570bSAlex Deucher * 0x0a, 0x80 2870fcec570bSAlex Deucher * 0x09, 0x30 2871fcec570bSAlex Deucher * 0x0c, 0xc9 2872fcec570bSAlex Deucher * 0x0d, 0x70 2873fcec570bSAlex Deucher * 0x08, 0x32 2874fcec570bSAlex Deucher * 0x08, 0x33 2875fcec570bSAlex Deucher */ 2876fcec570bSAlex Deucher break; 2877fcec570bSAlex Deucher default: 2878fcec570bSAlex Deucher break; 2879fcec570bSAlex Deucher } 2880fcec570bSAlex Deucher 2881fcec570bSAlex Deucher } 2882fcec570bSAlex Deucher 2883fcec570bSAlex Deucher bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder) 2884fcec570bSAlex Deucher { 2885fcec570bSAlex Deucher struct drm_device *dev = encoder->dev; 2886fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 2887fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2888fcec570bSAlex Deucher uint16_t offset; 2889fcec570bSAlex Deucher uint8_t blocks, slave_addr, rev; 2890fcec570bSAlex Deucher uint32_t index, id; 2891fcec570bSAlex Deucher uint32_t reg, val, and_mask, or_mask; 2892fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2893fcec570bSAlex Deucher 2894fcec570bSAlex Deucher if (!tmds) 2895fcec570bSAlex Deucher return false; 2896fcec570bSAlex Deucher 2897fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2898fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE); 2899fcec570bSAlex Deucher rev = RBIOS8(offset); 2900fcec570bSAlex Deucher if (offset) { 2901fcec570bSAlex Deucher rev = RBIOS8(offset); 2902fcec570bSAlex Deucher if (rev > 1) { 2903fcec570bSAlex Deucher blocks = RBIOS8(offset + 3); 2904fcec570bSAlex Deucher index = offset + 4; 2905fcec570bSAlex Deucher while (blocks > 0) { 2906fcec570bSAlex Deucher id = RBIOS16(index); 2907fcec570bSAlex Deucher index += 2; 2908fcec570bSAlex Deucher switch (id >> 13) { 2909fcec570bSAlex Deucher case 0: 2910fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2911fcec570bSAlex Deucher val = RBIOS32(index); 2912fcec570bSAlex Deucher index += 4; 2913fcec570bSAlex Deucher WREG32(reg, val); 2914fcec570bSAlex Deucher break; 2915fcec570bSAlex Deucher case 2: 2916fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2917fcec570bSAlex Deucher and_mask = RBIOS32(index); 2918fcec570bSAlex Deucher index += 4; 2919fcec570bSAlex Deucher or_mask = RBIOS32(index); 2920fcec570bSAlex Deucher index += 4; 2921fcec570bSAlex Deucher val = RREG32(reg); 2922fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2923fcec570bSAlex Deucher WREG32(reg, val); 2924fcec570bSAlex Deucher break; 2925fcec570bSAlex Deucher case 3: 2926fcec570bSAlex Deucher val = RBIOS16(index); 2927fcec570bSAlex Deucher index += 2; 2928fcec570bSAlex Deucher udelay(val); 2929fcec570bSAlex Deucher break; 2930fcec570bSAlex Deucher case 4: 2931fcec570bSAlex Deucher val = RBIOS16(index); 2932fcec570bSAlex Deucher index += 2; 29334de833c3SArnd Bergmann mdelay(val); 2934fcec570bSAlex Deucher break; 2935fcec570bSAlex Deucher case 6: 2936fcec570bSAlex Deucher slave_addr = id & 0xff; 2937fcec570bSAlex Deucher slave_addr >>= 1; /* 7 bit addressing */ 2938fcec570bSAlex Deucher index++; 2939fcec570bSAlex Deucher reg = RBIOS8(index); 2940fcec570bSAlex Deucher index++; 2941fcec570bSAlex Deucher val = RBIOS8(index); 2942fcec570bSAlex Deucher index++; 29435a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2944fcec570bSAlex Deucher slave_addr, 2945fcec570bSAlex Deucher reg, val); 2946fcec570bSAlex Deucher break; 2947fcec570bSAlex Deucher default: 2948fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2949fcec570bSAlex Deucher break; 2950fcec570bSAlex Deucher } 2951fcec570bSAlex Deucher blocks--; 2952fcec570bSAlex Deucher } 2953fcec570bSAlex Deucher return true; 2954fcec570bSAlex Deucher } 2955fcec570bSAlex Deucher } 2956fcec570bSAlex Deucher } else { 2957fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2958fcec570bSAlex Deucher if (offset) { 2959fcec570bSAlex Deucher index = offset + 10; 2960fcec570bSAlex Deucher id = RBIOS16(index); 2961fcec570bSAlex Deucher while (id != 0xffff) { 2962fcec570bSAlex Deucher index += 2; 2963fcec570bSAlex Deucher switch (id >> 13) { 2964fcec570bSAlex Deucher case 0: 2965fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2966fcec570bSAlex Deucher val = RBIOS32(index); 2967fcec570bSAlex Deucher WREG32(reg, val); 2968fcec570bSAlex Deucher break; 2969fcec570bSAlex Deucher case 2: 2970fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2971fcec570bSAlex Deucher and_mask = RBIOS32(index); 2972fcec570bSAlex Deucher index += 4; 2973fcec570bSAlex Deucher or_mask = RBIOS32(index); 2974fcec570bSAlex Deucher index += 4; 2975fcec570bSAlex Deucher val = RREG32(reg); 2976fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2977fcec570bSAlex Deucher WREG32(reg, val); 2978fcec570bSAlex Deucher break; 2979fcec570bSAlex Deucher case 4: 2980fcec570bSAlex Deucher val = RBIOS16(index); 2981fcec570bSAlex Deucher index += 2; 2982fcec570bSAlex Deucher udelay(val); 2983fcec570bSAlex Deucher break; 2984fcec570bSAlex Deucher case 5: 2985fcec570bSAlex Deucher reg = id & 0x1fff; 2986fcec570bSAlex Deucher and_mask = RBIOS32(index); 2987fcec570bSAlex Deucher index += 4; 2988fcec570bSAlex Deucher or_mask = RBIOS32(index); 2989fcec570bSAlex Deucher index += 4; 2990fcec570bSAlex Deucher val = RREG32_PLL(reg); 2991fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2992fcec570bSAlex Deucher WREG32_PLL(reg, val); 2993fcec570bSAlex Deucher break; 2994fcec570bSAlex Deucher case 6: 2995fcec570bSAlex Deucher reg = id & 0x1fff; 2996fcec570bSAlex Deucher val = RBIOS8(index); 2997fcec570bSAlex Deucher index += 1; 29985a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2999fcec570bSAlex Deucher tmds->slave_addr, 3000fcec570bSAlex Deucher reg, val); 3001fcec570bSAlex Deucher break; 3002fcec570bSAlex Deucher default: 3003fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 3004fcec570bSAlex Deucher break; 3005fcec570bSAlex Deucher } 3006fcec570bSAlex Deucher id = RBIOS16(index); 3007fcec570bSAlex Deucher } 3008fcec570bSAlex Deucher return true; 3009fcec570bSAlex Deucher } 3010fcec570bSAlex Deucher } 3011fcec570bSAlex Deucher return false; 3012fcec570bSAlex Deucher } 3013fcec570bSAlex Deucher 3014771fe6b9SJerome Glisse static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset) 3015771fe6b9SJerome Glisse { 3016771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3017771fe6b9SJerome Glisse 3018771fe6b9SJerome Glisse if (offset) { 3019771fe6b9SJerome Glisse while (RBIOS16(offset)) { 3020771fe6b9SJerome Glisse uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13); 3021771fe6b9SJerome Glisse uint32_t addr = (RBIOS16(offset) & 0x1fff); 3022771fe6b9SJerome Glisse uint32_t val, and_mask, or_mask; 3023771fe6b9SJerome Glisse uint32_t tmp; 3024771fe6b9SJerome Glisse 3025771fe6b9SJerome Glisse offset += 2; 3026771fe6b9SJerome Glisse switch (cmd) { 3027771fe6b9SJerome Glisse case 0: 3028771fe6b9SJerome Glisse val = RBIOS32(offset); 3029771fe6b9SJerome Glisse offset += 4; 3030771fe6b9SJerome Glisse WREG32(addr, val); 3031771fe6b9SJerome Glisse break; 3032771fe6b9SJerome Glisse case 1: 3033771fe6b9SJerome Glisse val = RBIOS32(offset); 3034771fe6b9SJerome Glisse offset += 4; 3035771fe6b9SJerome Glisse WREG32(addr, val); 3036771fe6b9SJerome Glisse break; 3037771fe6b9SJerome Glisse case 2: 3038771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 3039771fe6b9SJerome Glisse offset += 4; 3040771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 3041771fe6b9SJerome Glisse offset += 4; 3042771fe6b9SJerome Glisse tmp = RREG32(addr); 3043771fe6b9SJerome Glisse tmp &= and_mask; 3044771fe6b9SJerome Glisse tmp |= or_mask; 3045771fe6b9SJerome Glisse WREG32(addr, tmp); 3046771fe6b9SJerome Glisse break; 3047771fe6b9SJerome Glisse case 3: 3048771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 3049771fe6b9SJerome Glisse offset += 4; 3050771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 3051771fe6b9SJerome Glisse offset += 4; 3052771fe6b9SJerome Glisse tmp = RREG32(addr); 3053771fe6b9SJerome Glisse tmp &= and_mask; 3054771fe6b9SJerome Glisse tmp |= or_mask; 3055771fe6b9SJerome Glisse WREG32(addr, tmp); 3056771fe6b9SJerome Glisse break; 3057771fe6b9SJerome Glisse case 4: 3058771fe6b9SJerome Glisse val = RBIOS16(offset); 3059771fe6b9SJerome Glisse offset += 2; 3060771fe6b9SJerome Glisse udelay(val); 3061771fe6b9SJerome Glisse break; 3062771fe6b9SJerome Glisse case 5: 3063771fe6b9SJerome Glisse val = RBIOS16(offset); 3064771fe6b9SJerome Glisse offset += 2; 3065771fe6b9SJerome Glisse switch (addr) { 3066771fe6b9SJerome Glisse case 8: 3067771fe6b9SJerome Glisse while (val--) { 3068771fe6b9SJerome Glisse if (! 3069771fe6b9SJerome Glisse (RREG32_PLL 3070771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 3071771fe6b9SJerome Glisse RADEON_MC_BUSY)) 3072771fe6b9SJerome Glisse break; 3073771fe6b9SJerome Glisse } 3074771fe6b9SJerome Glisse break; 3075771fe6b9SJerome Glisse case 9: 3076771fe6b9SJerome Glisse while (val--) { 3077771fe6b9SJerome Glisse if ((RREG32(RADEON_MC_STATUS) & 3078771fe6b9SJerome Glisse RADEON_MC_IDLE)) 3079771fe6b9SJerome Glisse break; 3080771fe6b9SJerome Glisse } 3081771fe6b9SJerome Glisse break; 3082771fe6b9SJerome Glisse default: 3083771fe6b9SJerome Glisse break; 3084771fe6b9SJerome Glisse } 3085771fe6b9SJerome Glisse break; 3086771fe6b9SJerome Glisse default: 3087771fe6b9SJerome Glisse break; 3088771fe6b9SJerome Glisse } 3089771fe6b9SJerome Glisse } 3090771fe6b9SJerome Glisse } 3091771fe6b9SJerome Glisse } 3092771fe6b9SJerome Glisse 3093771fe6b9SJerome Glisse static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset) 3094771fe6b9SJerome Glisse { 3095771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3096771fe6b9SJerome Glisse 3097771fe6b9SJerome Glisse if (offset) { 3098771fe6b9SJerome Glisse while (RBIOS8(offset)) { 3099771fe6b9SJerome Glisse uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6); 3100771fe6b9SJerome Glisse uint8_t addr = (RBIOS8(offset) & 0x3f); 3101771fe6b9SJerome Glisse uint32_t val, shift, tmp; 3102771fe6b9SJerome Glisse uint32_t and_mask, or_mask; 3103771fe6b9SJerome Glisse 3104771fe6b9SJerome Glisse offset++; 3105771fe6b9SJerome Glisse switch (cmd) { 3106771fe6b9SJerome Glisse case 0: 3107771fe6b9SJerome Glisse val = RBIOS32(offset); 3108771fe6b9SJerome Glisse offset += 4; 3109771fe6b9SJerome Glisse WREG32_PLL(addr, val); 3110771fe6b9SJerome Glisse break; 3111771fe6b9SJerome Glisse case 1: 3112771fe6b9SJerome Glisse shift = RBIOS8(offset) * 8; 3113771fe6b9SJerome Glisse offset++; 3114771fe6b9SJerome Glisse and_mask = RBIOS8(offset) << shift; 3115771fe6b9SJerome Glisse and_mask |= ~(0xff << shift); 3116771fe6b9SJerome Glisse offset++; 3117771fe6b9SJerome Glisse or_mask = RBIOS8(offset) << shift; 3118771fe6b9SJerome Glisse offset++; 3119771fe6b9SJerome Glisse tmp = RREG32_PLL(addr); 3120771fe6b9SJerome Glisse tmp &= and_mask; 3121771fe6b9SJerome Glisse tmp |= or_mask; 3122771fe6b9SJerome Glisse WREG32_PLL(addr, tmp); 3123771fe6b9SJerome Glisse break; 3124771fe6b9SJerome Glisse case 2: 3125771fe6b9SJerome Glisse case 3: 3126771fe6b9SJerome Glisse tmp = 1000; 3127771fe6b9SJerome Glisse switch (addr) { 3128771fe6b9SJerome Glisse case 1: 3129771fe6b9SJerome Glisse udelay(150); 3130771fe6b9SJerome Glisse break; 3131771fe6b9SJerome Glisse case 2: 31324de833c3SArnd Bergmann mdelay(1); 3133771fe6b9SJerome Glisse break; 3134771fe6b9SJerome Glisse case 3: 3135771fe6b9SJerome Glisse while (tmp--) { 3136771fe6b9SJerome Glisse if (! 3137771fe6b9SJerome Glisse (RREG32_PLL 3138771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 3139771fe6b9SJerome Glisse RADEON_MC_BUSY)) 3140771fe6b9SJerome Glisse break; 3141771fe6b9SJerome Glisse } 3142771fe6b9SJerome Glisse break; 3143771fe6b9SJerome Glisse case 4: 3144771fe6b9SJerome Glisse while (tmp--) { 3145771fe6b9SJerome Glisse if (RREG32_PLL 3146771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 3147771fe6b9SJerome Glisse RADEON_DLL_READY) 3148771fe6b9SJerome Glisse break; 3149771fe6b9SJerome Glisse } 3150771fe6b9SJerome Glisse break; 3151771fe6b9SJerome Glisse case 5: 3152771fe6b9SJerome Glisse tmp = 3153771fe6b9SJerome Glisse RREG32_PLL(RADEON_CLK_PWRMGT_CNTL); 3154771fe6b9SJerome Glisse if (tmp & RADEON_CG_NO1_DEBUG_0) { 3155771fe6b9SJerome Glisse #if 0 3156771fe6b9SJerome Glisse uint32_t mclk_cntl = 3157771fe6b9SJerome Glisse RREG32_PLL 3158771fe6b9SJerome Glisse (RADEON_MCLK_CNTL); 3159771fe6b9SJerome Glisse mclk_cntl &= 0xffff0000; 3160771fe6b9SJerome Glisse /*mclk_cntl |= 0x00001111;*//* ??? */ 3161771fe6b9SJerome Glisse WREG32_PLL(RADEON_MCLK_CNTL, 3162771fe6b9SJerome Glisse mclk_cntl); 31634de833c3SArnd Bergmann mdelay(10); 3164771fe6b9SJerome Glisse #endif 3165771fe6b9SJerome Glisse WREG32_PLL 3166771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL, 3167771fe6b9SJerome Glisse tmp & 3168771fe6b9SJerome Glisse ~RADEON_CG_NO1_DEBUG_0); 31694de833c3SArnd Bergmann mdelay(10); 3170771fe6b9SJerome Glisse } 3171771fe6b9SJerome Glisse break; 3172771fe6b9SJerome Glisse default: 3173771fe6b9SJerome Glisse break; 3174771fe6b9SJerome Glisse } 3175771fe6b9SJerome Glisse break; 3176771fe6b9SJerome Glisse default: 3177771fe6b9SJerome Glisse break; 3178771fe6b9SJerome Glisse } 3179771fe6b9SJerome Glisse } 3180771fe6b9SJerome Glisse } 3181771fe6b9SJerome Glisse } 3182771fe6b9SJerome Glisse 3183771fe6b9SJerome Glisse static void combios_parse_ram_reset_table(struct drm_device *dev, 3184771fe6b9SJerome Glisse uint16_t offset) 3185771fe6b9SJerome Glisse { 3186771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3187771fe6b9SJerome Glisse uint32_t tmp; 3188771fe6b9SJerome Glisse 3189771fe6b9SJerome Glisse if (offset) { 3190771fe6b9SJerome Glisse uint8_t val = RBIOS8(offset); 3191771fe6b9SJerome Glisse while (val != 0xff) { 3192771fe6b9SJerome Glisse offset++; 3193771fe6b9SJerome Glisse 3194771fe6b9SJerome Glisse if (val == 0x0f) { 3195771fe6b9SJerome Glisse uint32_t channel_complete_mask; 3196771fe6b9SJerome Glisse 3197771fe6b9SJerome Glisse if (ASIC_IS_R300(rdev)) 3198771fe6b9SJerome Glisse channel_complete_mask = 3199771fe6b9SJerome Glisse R300_MEM_PWRUP_COMPLETE; 3200771fe6b9SJerome Glisse else 3201771fe6b9SJerome Glisse channel_complete_mask = 3202771fe6b9SJerome Glisse RADEON_MEM_PWRUP_COMPLETE; 3203771fe6b9SJerome Glisse tmp = 20000; 3204771fe6b9SJerome Glisse while (tmp--) { 3205771fe6b9SJerome Glisse if ((RREG32(RADEON_MEM_STR_CNTL) & 3206771fe6b9SJerome Glisse channel_complete_mask) == 3207771fe6b9SJerome Glisse channel_complete_mask) 3208771fe6b9SJerome Glisse break; 3209771fe6b9SJerome Glisse } 3210771fe6b9SJerome Glisse } else { 3211771fe6b9SJerome Glisse uint32_t or_mask = RBIOS16(offset); 3212771fe6b9SJerome Glisse offset += 2; 3213771fe6b9SJerome Glisse 3214771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 3215771fe6b9SJerome Glisse tmp &= RADEON_SDRAM_MODE_MASK; 3216771fe6b9SJerome Glisse tmp |= or_mask; 3217771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 3218771fe6b9SJerome Glisse 3219771fe6b9SJerome Glisse or_mask = val << 24; 3220771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 3221771fe6b9SJerome Glisse tmp &= RADEON_B3MEM_RESET_MASK; 3222771fe6b9SJerome Glisse tmp |= or_mask; 3223771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 3224771fe6b9SJerome Glisse } 3225771fe6b9SJerome Glisse val = RBIOS8(offset); 3226771fe6b9SJerome Glisse } 3227771fe6b9SJerome Glisse } 3228771fe6b9SJerome Glisse } 3229771fe6b9SJerome Glisse 3230771fe6b9SJerome Glisse static uint32_t combios_detect_ram(struct drm_device *dev, int ram, 3231771fe6b9SJerome Glisse int mem_addr_mapping) 3232771fe6b9SJerome Glisse { 3233771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3234771fe6b9SJerome Glisse uint32_t mem_cntl; 3235771fe6b9SJerome Glisse uint32_t mem_size; 3236771fe6b9SJerome Glisse uint32_t addr = 0; 3237771fe6b9SJerome Glisse 3238771fe6b9SJerome Glisse mem_cntl = RREG32(RADEON_MEM_CNTL); 3239771fe6b9SJerome Glisse if (mem_cntl & RV100_HALF_MODE) 3240771fe6b9SJerome Glisse ram /= 2; 3241771fe6b9SJerome Glisse mem_size = ram; 3242771fe6b9SJerome Glisse mem_cntl &= ~(0xff << 8); 3243771fe6b9SJerome Glisse mem_cntl |= (mem_addr_mapping & 0xff) << 8; 3244771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 3245771fe6b9SJerome Glisse RREG32(RADEON_MEM_CNTL); 3246771fe6b9SJerome Glisse 3247771fe6b9SJerome Glisse /* sdram reset ? */ 3248771fe6b9SJerome Glisse 3249771fe6b9SJerome Glisse /* something like this???? */ 3250771fe6b9SJerome Glisse while (ram--) { 3251771fe6b9SJerome Glisse addr = ram * 1024 * 1024; 3252771fe6b9SJerome Glisse /* write to each page */ 32532ef9bdfeSDaniel Vetter WREG32_IDX((addr) | RADEON_MM_APER, 0xdeadbeef); 3254771fe6b9SJerome Glisse /* read back and verify */ 32552ef9bdfeSDaniel Vetter if (RREG32_IDX((addr) | RADEON_MM_APER) != 0xdeadbeef) 3256771fe6b9SJerome Glisse return 0; 3257771fe6b9SJerome Glisse } 3258771fe6b9SJerome Glisse 3259771fe6b9SJerome Glisse return mem_size; 3260771fe6b9SJerome Glisse } 3261771fe6b9SJerome Glisse 3262771fe6b9SJerome Glisse static void combios_write_ram_size(struct drm_device *dev) 3263771fe6b9SJerome Glisse { 3264771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3265771fe6b9SJerome Glisse uint8_t rev; 3266771fe6b9SJerome Glisse uint16_t offset; 3267771fe6b9SJerome Glisse uint32_t mem_size = 0; 3268771fe6b9SJerome Glisse uint32_t mem_cntl = 0; 3269771fe6b9SJerome Glisse 3270771fe6b9SJerome Glisse /* should do something smarter here I guess... */ 3271771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_IGP) 3272771fe6b9SJerome Glisse return; 3273771fe6b9SJerome Glisse 3274771fe6b9SJerome Glisse /* first check detected mem table */ 3275771fe6b9SJerome Glisse offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE); 3276771fe6b9SJerome Glisse if (offset) { 3277771fe6b9SJerome Glisse rev = RBIOS8(offset); 3278771fe6b9SJerome Glisse if (rev < 3) { 3279771fe6b9SJerome Glisse mem_cntl = RBIOS32(offset + 1); 3280771fe6b9SJerome Glisse mem_size = RBIOS16(offset + 5); 32814ce9198eSAlex Deucher if ((rdev->family < CHIP_R200) && 32824ce9198eSAlex Deucher !ASIC_IS_RN50(rdev)) 3283771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 3284771fe6b9SJerome Glisse } 3285771fe6b9SJerome Glisse } 3286771fe6b9SJerome Glisse 3287771fe6b9SJerome Glisse if (!mem_size) { 3288771fe6b9SJerome Glisse offset = 3289771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 3290771fe6b9SJerome Glisse if (offset) { 3291771fe6b9SJerome Glisse rev = RBIOS8(offset - 1); 3292771fe6b9SJerome Glisse if (rev < 1) { 32934ce9198eSAlex Deucher if ((rdev->family < CHIP_R200) 32944ce9198eSAlex Deucher && !ASIC_IS_RN50(rdev)) { 3295771fe6b9SJerome Glisse int ram = 0; 3296771fe6b9SJerome Glisse int mem_addr_mapping = 0; 3297771fe6b9SJerome Glisse 3298771fe6b9SJerome Glisse while (RBIOS8(offset)) { 3299771fe6b9SJerome Glisse ram = RBIOS8(offset); 3300771fe6b9SJerome Glisse mem_addr_mapping = 3301771fe6b9SJerome Glisse RBIOS8(offset + 1); 3302771fe6b9SJerome Glisse if (mem_addr_mapping != 0x25) 3303771fe6b9SJerome Glisse ram *= 2; 3304771fe6b9SJerome Glisse mem_size = 3305771fe6b9SJerome Glisse combios_detect_ram(dev, ram, 3306771fe6b9SJerome Glisse mem_addr_mapping); 3307771fe6b9SJerome Glisse if (mem_size) 3308771fe6b9SJerome Glisse break; 3309771fe6b9SJerome Glisse offset += 2; 3310771fe6b9SJerome Glisse } 3311771fe6b9SJerome Glisse } else 3312771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 3313771fe6b9SJerome Glisse } else { 3314771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 3315771fe6b9SJerome Glisse mem_size *= 2; /* convert to MB */ 3316771fe6b9SJerome Glisse } 3317771fe6b9SJerome Glisse } 3318771fe6b9SJerome Glisse } 3319771fe6b9SJerome Glisse 3320771fe6b9SJerome Glisse mem_size *= (1024 * 1024); /* convert to bytes */ 3321771fe6b9SJerome Glisse WREG32(RADEON_CONFIG_MEMSIZE, mem_size); 3322771fe6b9SJerome Glisse } 3323771fe6b9SJerome Glisse 3324771fe6b9SJerome Glisse void radeon_combios_asic_init(struct drm_device *dev) 3325771fe6b9SJerome Glisse { 3326771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3327771fe6b9SJerome Glisse uint16_t table; 3328771fe6b9SJerome Glisse 3329771fe6b9SJerome Glisse /* port hardcoded mac stuff from radeonfb */ 3330771fe6b9SJerome Glisse if (rdev->bios == NULL) 3331771fe6b9SJerome Glisse return; 3332771fe6b9SJerome Glisse 3333771fe6b9SJerome Glisse /* ASIC INIT 1 */ 3334771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE); 3335771fe6b9SJerome Glisse if (table) 3336771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3337771fe6b9SJerome Glisse 3338771fe6b9SJerome Glisse /* PLL INIT */ 3339771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE); 3340771fe6b9SJerome Glisse if (table) 3341771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 3342771fe6b9SJerome Glisse 3343771fe6b9SJerome Glisse /* ASIC INIT 2 */ 3344771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE); 3345771fe6b9SJerome Glisse if (table) 3346771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3347771fe6b9SJerome Glisse 3348771fe6b9SJerome Glisse if (!(rdev->flags & RADEON_IS_IGP)) { 3349771fe6b9SJerome Glisse /* ASIC INIT 4 */ 3350771fe6b9SJerome Glisse table = 3351771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE); 3352771fe6b9SJerome Glisse if (table) 3353771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3354771fe6b9SJerome Glisse 3355771fe6b9SJerome Glisse /* RAM RESET */ 3356771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE); 3357771fe6b9SJerome Glisse if (table) 3358771fe6b9SJerome Glisse combios_parse_ram_reset_table(dev, table); 3359771fe6b9SJerome Glisse 3360771fe6b9SJerome Glisse /* ASIC INIT 3 */ 3361771fe6b9SJerome Glisse table = 3362771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE); 3363771fe6b9SJerome Glisse if (table) 3364771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3365771fe6b9SJerome Glisse 3366771fe6b9SJerome Glisse /* write CONFIG_MEMSIZE */ 3367771fe6b9SJerome Glisse combios_write_ram_size(dev); 3368771fe6b9SJerome Glisse } 3369771fe6b9SJerome Glisse 3370580b4fffSDave Airlie /* quirk for rs4xx HP nx6125 laptop to make it resume 3371580b4fffSDave Airlie * - it hangs on resume inside the dynclk 1 table. 3372580b4fffSDave Airlie */ 3373580b4fffSDave Airlie if (rdev->family == CHIP_RS480 && 3374580b4fffSDave Airlie rdev->pdev->subsystem_vendor == 0x103c && 3375580b4fffSDave Airlie rdev->pdev->subsystem_device == 0x308b) 3376580b4fffSDave Airlie return; 3377580b4fffSDave Airlie 337852fa2bbcSAlex Deucher /* quirk for rs4xx HP dv5000 laptop to make it resume 337952fa2bbcSAlex Deucher * - it hangs on resume inside the dynclk 1 table. 338052fa2bbcSAlex Deucher */ 338152fa2bbcSAlex Deucher if (rdev->family == CHIP_RS480 && 338252fa2bbcSAlex Deucher rdev->pdev->subsystem_vendor == 0x103c && 338352fa2bbcSAlex Deucher rdev->pdev->subsystem_device == 0x30a4) 338452fa2bbcSAlex Deucher return; 338552fa2bbcSAlex Deucher 3386302a8e8bSAlex Deucher /* quirk for rs4xx Compaq Presario V5245EU laptop to make it resume 3387302a8e8bSAlex Deucher * - it hangs on resume inside the dynclk 1 table. 3388302a8e8bSAlex Deucher */ 3389302a8e8bSAlex Deucher if (rdev->family == CHIP_RS480 && 3390302a8e8bSAlex Deucher rdev->pdev->subsystem_vendor == 0x103c && 3391302a8e8bSAlex Deucher rdev->pdev->subsystem_device == 0x30ae) 3392302a8e8bSAlex Deucher return; 3393302a8e8bSAlex Deucher 339409bfda10SJeffery Miller /* quirk for rs4xx HP Compaq dc5750 Small Form Factor to make it resume 339509bfda10SJeffery Miller * - it hangs on resume inside the dynclk 1 table. 339609bfda10SJeffery Miller */ 339709bfda10SJeffery Miller if (rdev->family == CHIP_RS480 && 339809bfda10SJeffery Miller rdev->pdev->subsystem_vendor == 0x103c && 339909bfda10SJeffery Miller rdev->pdev->subsystem_device == 0x280a) 340009bfda10SJeffery Miller return; 3401acfd6ee4SAlex Deucher /* quirk for rs4xx Toshiba Sattellite L20-183 latop to make it resume 3402acfd6ee4SAlex Deucher * - it hangs on resume inside the dynclk 1 table. 3403acfd6ee4SAlex Deucher */ 3404acfd6ee4SAlex Deucher if (rdev->family == CHIP_RS400 && 3405acfd6ee4SAlex Deucher rdev->pdev->subsystem_vendor == 0x1179 && 3406acfd6ee4SAlex Deucher rdev->pdev->subsystem_device == 0xff31) 3407acfd6ee4SAlex Deucher return; 340809bfda10SJeffery Miller 3409771fe6b9SJerome Glisse /* DYN CLK 1 */ 3410771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 3411771fe6b9SJerome Glisse if (table) 3412771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 3413771fe6b9SJerome Glisse 3414771fe6b9SJerome Glisse } 3415771fe6b9SJerome Glisse 3416771fe6b9SJerome Glisse void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev) 3417771fe6b9SJerome Glisse { 3418771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3419771fe6b9SJerome Glisse uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch; 3420771fe6b9SJerome Glisse 3421771fe6b9SJerome Glisse bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); 3422771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3423771fe6b9SJerome Glisse bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH); 3424771fe6b9SJerome Glisse 3425771fe6b9SJerome Glisse /* let the bios control the backlight */ 3426771fe6b9SJerome Glisse bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN; 3427771fe6b9SJerome Glisse 3428771fe6b9SJerome Glisse /* tell the bios not to handle mode switching */ 3429771fe6b9SJerome Glisse bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS | 3430771fe6b9SJerome Glisse RADEON_ACC_MODE_CHANGE); 3431771fe6b9SJerome Glisse 3432771fe6b9SJerome Glisse /* tell the bios a driver is loaded */ 3433771fe6b9SJerome Glisse bios_7_scratch |= RADEON_DRV_LOADED; 3434771fe6b9SJerome Glisse 3435771fe6b9SJerome Glisse WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch); 3436771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3437771fe6b9SJerome Glisse WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch); 3438771fe6b9SJerome Glisse } 3439771fe6b9SJerome Glisse 3440771fe6b9SJerome Glisse void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock) 3441771fe6b9SJerome Glisse { 3442771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3443771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3444771fe6b9SJerome Glisse uint32_t bios_6_scratch; 3445771fe6b9SJerome Glisse 3446771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3447771fe6b9SJerome Glisse 3448771fe6b9SJerome Glisse if (lock) 3449771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DRIVER_CRITICAL; 3450771fe6b9SJerome Glisse else 3451771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DRIVER_CRITICAL; 3452771fe6b9SJerome Glisse 3453771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3454771fe6b9SJerome Glisse } 3455771fe6b9SJerome Glisse 3456771fe6b9SJerome Glisse void 3457771fe6b9SJerome Glisse radeon_combios_connected_scratch_regs(struct drm_connector *connector, 3458771fe6b9SJerome Glisse struct drm_encoder *encoder, 3459771fe6b9SJerome Glisse bool connected) 3460771fe6b9SJerome Glisse { 3461771fe6b9SJerome Glisse struct drm_device *dev = connector->dev; 3462771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3463771fe6b9SJerome Glisse struct radeon_connector *radeon_connector = 3464771fe6b9SJerome Glisse to_radeon_connector(connector); 3465771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3466771fe6b9SJerome Glisse uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH); 3467771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3468771fe6b9SJerome Glisse 3469771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) && 3470771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) { 3471771fe6b9SJerome Glisse if (connected) { 3472d9fdaafbSDave Airlie DRM_DEBUG_KMS("TV1 connected\n"); 3473771fe6b9SJerome Glisse /* fix me */ 3474771fe6b9SJerome Glisse bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO; 3475771fe6b9SJerome Glisse /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */ 3476771fe6b9SJerome Glisse bios_5_scratch |= RADEON_TV1_ON; 3477771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_TV1; 3478771fe6b9SJerome Glisse } else { 3479d9fdaafbSDave Airlie DRM_DEBUG_KMS("TV1 disconnected\n"); 3480771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK; 3481771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_ON; 3482771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_TV1; 3483771fe6b9SJerome Glisse } 3484771fe6b9SJerome Glisse } 3485771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) && 3486771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) { 3487771fe6b9SJerome Glisse if (connected) { 3488d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD1 connected\n"); 3489771fe6b9SJerome Glisse bios_4_scratch |= RADEON_LCD1_ATTACHED; 3490771fe6b9SJerome Glisse bios_5_scratch |= RADEON_LCD1_ON; 3491771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_LCD1; 3492771fe6b9SJerome Glisse } else { 3493d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD1 disconnected\n"); 3494771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_LCD1_ATTACHED; 3495771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_ON; 3496771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_LCD1; 3497771fe6b9SJerome Glisse } 3498771fe6b9SJerome Glisse } 3499771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) && 3500771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) { 3501771fe6b9SJerome Glisse if (connected) { 3502d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT1 connected\n"); 3503771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR; 3504771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT1_ON; 3505771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT1; 3506771fe6b9SJerome Glisse } else { 3507d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT1 disconnected\n"); 3508771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK; 3509771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_ON; 3510771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT1; 3511771fe6b9SJerome Glisse } 3512771fe6b9SJerome Glisse } 3513771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) && 3514771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) { 3515771fe6b9SJerome Glisse if (connected) { 3516d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT2 connected\n"); 3517771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR; 3518771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT2_ON; 3519771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT2; 3520771fe6b9SJerome Glisse } else { 3521d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT2 disconnected\n"); 3522771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK; 3523771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_ON; 3524771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT2; 3525771fe6b9SJerome Glisse } 3526771fe6b9SJerome Glisse } 3527771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) && 3528771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) { 3529771fe6b9SJerome Glisse if (connected) { 3530d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP1 connected\n"); 3531771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP1_ATTACHED; 3532771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP1_ON; 3533771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP1; 3534771fe6b9SJerome Glisse } else { 3535d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP1 disconnected\n"); 3536771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP1_ATTACHED; 3537771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_ON; 3538771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP1; 3539771fe6b9SJerome Glisse } 3540771fe6b9SJerome Glisse } 3541771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) && 3542771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) { 3543771fe6b9SJerome Glisse if (connected) { 3544d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP2 connected\n"); 3545771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP2_ATTACHED; 3546771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP2_ON; 3547771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP2; 3548771fe6b9SJerome Glisse } else { 3549d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP2 disconnected\n"); 3550771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP2_ATTACHED; 3551771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_ON; 3552771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP2; 3553771fe6b9SJerome Glisse } 3554771fe6b9SJerome Glisse } 3555771fe6b9SJerome Glisse WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch); 3556771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3557771fe6b9SJerome Glisse } 3558771fe6b9SJerome Glisse 3559771fe6b9SJerome Glisse void 3560771fe6b9SJerome Glisse radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc) 3561771fe6b9SJerome Glisse { 3562771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3563771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3564771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3565771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3566771fe6b9SJerome Glisse 3567771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { 3568771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_CRTC_MASK; 3569771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT); 3570771fe6b9SJerome Glisse } 3571771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { 3572771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK; 3573771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT); 3574771fe6b9SJerome Glisse } 3575771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { 3576771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK; 3577771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT); 3578771fe6b9SJerome Glisse } 3579771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { 3580771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK; 3581771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT); 3582771fe6b9SJerome Glisse } 3583771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { 3584771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK; 3585771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT); 3586771fe6b9SJerome Glisse } 3587771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { 3588771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK; 3589771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT); 3590771fe6b9SJerome Glisse } 3591771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3592771fe6b9SJerome Glisse } 3593771fe6b9SJerome Glisse 3594771fe6b9SJerome Glisse void 3595771fe6b9SJerome Glisse radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on) 3596771fe6b9SJerome Glisse { 3597771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3598771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3599771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3600771fe6b9SJerome Glisse uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3601771fe6b9SJerome Glisse 3602771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { 3603771fe6b9SJerome Glisse if (on) 3604771fe6b9SJerome Glisse bios_6_scratch |= RADEON_TV_DPMS_ON; 3605771fe6b9SJerome Glisse else 3606771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_TV_DPMS_ON; 3607771fe6b9SJerome Glisse } 3608771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) { 3609771fe6b9SJerome Glisse if (on) 3610771fe6b9SJerome Glisse bios_6_scratch |= RADEON_CRT_DPMS_ON; 3611771fe6b9SJerome Glisse else 3612771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_CRT_DPMS_ON; 3613771fe6b9SJerome Glisse } 3614771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 3615771fe6b9SJerome Glisse if (on) 3616771fe6b9SJerome Glisse bios_6_scratch |= RADEON_LCD_DPMS_ON; 3617771fe6b9SJerome Glisse else 3618771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_LCD_DPMS_ON; 3619771fe6b9SJerome Glisse } 3620771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 3621771fe6b9SJerome Glisse if (on) 3622771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DFP_DPMS_ON; 3623771fe6b9SJerome Glisse else 3624771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DFP_DPMS_ON; 3625771fe6b9SJerome Glisse } 3626771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3627771fe6b9SJerome Glisse } 3628