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 */ 27771fe6b9SJerome Glisse #include "drmP.h" 28771fe6b9SJerome Glisse #include "radeon_drm.h" 29771fe6b9SJerome Glisse #include "radeon.h" 30771fe6b9SJerome Glisse #include "atom.h" 31771fe6b9SJerome Glisse 32771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 33771fe6b9SJerome Glisse /* not sure which of these are needed */ 34771fe6b9SJerome Glisse #include <asm/machdep.h> 35771fe6b9SJerome Glisse #include <asm/pmac_feature.h> 36771fe6b9SJerome Glisse #include <asm/prom.h> 37771fe6b9SJerome Glisse #include <asm/pci-bridge.h> 38771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 39771fe6b9SJerome Glisse 40771fe6b9SJerome Glisse /* from radeon_encoder.c */ 41771fe6b9SJerome Glisse extern uint32_t 425137ee94SAlex Deucher radeon_get_encoder_enum(struct drm_device *dev, uint32_t supported_device, 43771fe6b9SJerome Glisse uint8_t dac); 44771fe6b9SJerome Glisse extern void radeon_link_encoder_connector(struct drm_device *dev); 45771fe6b9SJerome Glisse 46771fe6b9SJerome Glisse /* from radeon_connector.c */ 47771fe6b9SJerome Glisse extern void 48771fe6b9SJerome Glisse radeon_add_legacy_connector(struct drm_device *dev, 49771fe6b9SJerome Glisse uint32_t connector_id, 50771fe6b9SJerome Glisse uint32_t supported_device, 51771fe6b9SJerome Glisse int connector_type, 52b75fad06SAlex Deucher struct radeon_i2c_bus_rec *i2c_bus, 53eed45b30SAlex Deucher uint16_t connector_object_id, 54eed45b30SAlex Deucher struct radeon_hpd *hpd); 55771fe6b9SJerome Glisse 56771fe6b9SJerome Glisse /* from radeon_legacy_encoder.c */ 57771fe6b9SJerome Glisse extern void 585137ee94SAlex Deucher radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_enum, 59771fe6b9SJerome Glisse uint32_t supported_device); 60771fe6b9SJerome Glisse 61771fe6b9SJerome Glisse /* old legacy ATI BIOS routines */ 62771fe6b9SJerome Glisse 63771fe6b9SJerome Glisse /* COMBIOS table offsets */ 64771fe6b9SJerome Glisse enum radeon_combios_table_offset { 65771fe6b9SJerome Glisse /* absolute offset tables */ 66771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_1_TABLE, 67771fe6b9SJerome Glisse COMBIOS_BIOS_SUPPORT_TABLE, 68771fe6b9SJerome Glisse COMBIOS_DAC_PROGRAMMING_TABLE, 69771fe6b9SJerome Glisse COMBIOS_MAX_COLOR_DEPTH_TABLE, 70771fe6b9SJerome Glisse COMBIOS_CRTC_INFO_TABLE, 71771fe6b9SJerome Glisse COMBIOS_PLL_INFO_TABLE, 72771fe6b9SJerome Glisse COMBIOS_TV_INFO_TABLE, 73771fe6b9SJerome Glisse COMBIOS_DFP_INFO_TABLE, 74771fe6b9SJerome Glisse COMBIOS_HW_CONFIG_INFO_TABLE, 75771fe6b9SJerome Glisse COMBIOS_MULTIMEDIA_INFO_TABLE, 76771fe6b9SJerome Glisse COMBIOS_TV_STD_PATCH_TABLE, 77771fe6b9SJerome Glisse COMBIOS_LCD_INFO_TABLE, 78771fe6b9SJerome Glisse COMBIOS_MOBILE_INFO_TABLE, 79771fe6b9SJerome Glisse COMBIOS_PLL_INIT_TABLE, 80771fe6b9SJerome Glisse COMBIOS_MEM_CONFIG_TABLE, 81771fe6b9SJerome Glisse COMBIOS_SAVE_MASK_TABLE, 82771fe6b9SJerome Glisse COMBIOS_HARDCODED_EDID_TABLE, 83771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_2_TABLE, 84771fe6b9SJerome Glisse COMBIOS_CONNECTOR_INFO_TABLE, 85771fe6b9SJerome Glisse COMBIOS_DYN_CLK_1_TABLE, 86771fe6b9SJerome Glisse COMBIOS_RESERVED_MEM_TABLE, 87771fe6b9SJerome Glisse COMBIOS_EXT_TMDS_INFO_TABLE, 88771fe6b9SJerome Glisse COMBIOS_MEM_CLK_INFO_TABLE, 89771fe6b9SJerome Glisse COMBIOS_EXT_DAC_INFO_TABLE, 90771fe6b9SJerome Glisse COMBIOS_MISC_INFO_TABLE, 91771fe6b9SJerome Glisse COMBIOS_CRT_INFO_TABLE, 92771fe6b9SJerome Glisse COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE, 93771fe6b9SJerome Glisse COMBIOS_COMPONENT_VIDEO_INFO_TABLE, 94771fe6b9SJerome Glisse COMBIOS_FAN_SPEED_INFO_TABLE, 95771fe6b9SJerome Glisse COMBIOS_OVERDRIVE_INFO_TABLE, 96771fe6b9SJerome Glisse COMBIOS_OEM_INFO_TABLE, 97771fe6b9SJerome Glisse COMBIOS_DYN_CLK_2_TABLE, 98771fe6b9SJerome Glisse COMBIOS_POWER_CONNECTOR_INFO_TABLE, 99771fe6b9SJerome Glisse COMBIOS_I2C_INFO_TABLE, 100771fe6b9SJerome Glisse /* relative offset tables */ 101771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_3_TABLE, /* offset from misc info */ 102771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_4_TABLE, /* offset from misc info */ 103771fe6b9SJerome Glisse COMBIOS_DETECTED_MEM_TABLE, /* offset from misc info */ 104771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_5_TABLE, /* offset from misc info */ 105771fe6b9SJerome Glisse COMBIOS_RAM_RESET_TABLE, /* offset from mem config */ 106771fe6b9SJerome Glisse COMBIOS_POWERPLAY_INFO_TABLE, /* offset from mobile info */ 107771fe6b9SJerome Glisse COMBIOS_GPIO_INFO_TABLE, /* offset from mobile info */ 108771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE, /* offset from mobile info */ 109771fe6b9SJerome Glisse COMBIOS_TMDS_POWER_TABLE, /* offset from mobile info */ 110771fe6b9SJerome Glisse COMBIOS_TMDS_POWER_ON_TABLE, /* offset from tmds power */ 111771fe6b9SJerome Glisse COMBIOS_TMDS_POWER_OFF_TABLE, /* offset from tmds power */ 112771fe6b9SJerome Glisse }; 113771fe6b9SJerome Glisse 114771fe6b9SJerome Glisse enum radeon_combios_ddc { 115771fe6b9SJerome Glisse DDC_NONE_DETECTED, 116771fe6b9SJerome Glisse DDC_MONID, 117771fe6b9SJerome Glisse DDC_DVI, 118771fe6b9SJerome Glisse DDC_VGA, 119771fe6b9SJerome Glisse DDC_CRT2, 120771fe6b9SJerome Glisse DDC_LCD, 121771fe6b9SJerome Glisse DDC_GPIO, 122771fe6b9SJerome Glisse }; 123771fe6b9SJerome Glisse 124771fe6b9SJerome Glisse enum radeon_combios_connector { 125771fe6b9SJerome Glisse CONNECTOR_NONE_LEGACY, 126771fe6b9SJerome Glisse CONNECTOR_PROPRIETARY_LEGACY, 127771fe6b9SJerome Glisse CONNECTOR_CRT_LEGACY, 128771fe6b9SJerome Glisse CONNECTOR_DVI_I_LEGACY, 129771fe6b9SJerome Glisse CONNECTOR_DVI_D_LEGACY, 130771fe6b9SJerome Glisse CONNECTOR_CTV_LEGACY, 131771fe6b9SJerome Glisse CONNECTOR_STV_LEGACY, 132771fe6b9SJerome Glisse CONNECTOR_UNSUPPORTED_LEGACY 133771fe6b9SJerome Glisse }; 134771fe6b9SJerome Glisse 135771fe6b9SJerome Glisse const int legacy_connector_convert[] = { 136771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_Unknown, 137771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVID, 138771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 139771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 140771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVID, 141771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_Composite, 142771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 143771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_Unknown, 144771fe6b9SJerome Glisse }; 145771fe6b9SJerome Glisse 146771fe6b9SJerome Glisse static uint16_t combios_get_table_offset(struct drm_device *dev, 147771fe6b9SJerome Glisse enum radeon_combios_table_offset table) 148771fe6b9SJerome Glisse { 149771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 150771fe6b9SJerome Glisse int rev; 151771fe6b9SJerome Glisse uint16_t offset = 0, check_offset; 152771fe6b9SJerome Glisse 15303047cdfSMichel Dänzer if (!rdev->bios) 15403047cdfSMichel Dänzer return 0; 15503047cdfSMichel Dänzer 156771fe6b9SJerome Glisse switch (table) { 157771fe6b9SJerome Glisse /* absolute offset tables */ 158771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_1_TABLE: 159771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0xc); 160771fe6b9SJerome Glisse if (check_offset) 161771fe6b9SJerome Glisse offset = check_offset; 162771fe6b9SJerome Glisse break; 163771fe6b9SJerome Glisse case COMBIOS_BIOS_SUPPORT_TABLE: 164771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x14); 165771fe6b9SJerome Glisse if (check_offset) 166771fe6b9SJerome Glisse offset = check_offset; 167771fe6b9SJerome Glisse break; 168771fe6b9SJerome Glisse case COMBIOS_DAC_PROGRAMMING_TABLE: 169771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x2a); 170771fe6b9SJerome Glisse if (check_offset) 171771fe6b9SJerome Glisse offset = check_offset; 172771fe6b9SJerome Glisse break; 173771fe6b9SJerome Glisse case COMBIOS_MAX_COLOR_DEPTH_TABLE: 174771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x2c); 175771fe6b9SJerome Glisse if (check_offset) 176771fe6b9SJerome Glisse offset = check_offset; 177771fe6b9SJerome Glisse break; 178771fe6b9SJerome Glisse case COMBIOS_CRTC_INFO_TABLE: 179771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x2e); 180771fe6b9SJerome Glisse if (check_offset) 181771fe6b9SJerome Glisse offset = check_offset; 182771fe6b9SJerome Glisse break; 183771fe6b9SJerome Glisse case COMBIOS_PLL_INFO_TABLE: 184771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x30); 185771fe6b9SJerome Glisse if (check_offset) 186771fe6b9SJerome Glisse offset = check_offset; 187771fe6b9SJerome Glisse break; 188771fe6b9SJerome Glisse case COMBIOS_TV_INFO_TABLE: 189771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x32); 190771fe6b9SJerome Glisse if (check_offset) 191771fe6b9SJerome Glisse offset = check_offset; 192771fe6b9SJerome Glisse break; 193771fe6b9SJerome Glisse case COMBIOS_DFP_INFO_TABLE: 194771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x34); 195771fe6b9SJerome Glisse if (check_offset) 196771fe6b9SJerome Glisse offset = check_offset; 197771fe6b9SJerome Glisse break; 198771fe6b9SJerome Glisse case COMBIOS_HW_CONFIG_INFO_TABLE: 199771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x36); 200771fe6b9SJerome Glisse if (check_offset) 201771fe6b9SJerome Glisse offset = check_offset; 202771fe6b9SJerome Glisse break; 203771fe6b9SJerome Glisse case COMBIOS_MULTIMEDIA_INFO_TABLE: 204771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x38); 205771fe6b9SJerome Glisse if (check_offset) 206771fe6b9SJerome Glisse offset = check_offset; 207771fe6b9SJerome Glisse break; 208771fe6b9SJerome Glisse case COMBIOS_TV_STD_PATCH_TABLE: 209771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x3e); 210771fe6b9SJerome Glisse if (check_offset) 211771fe6b9SJerome Glisse offset = check_offset; 212771fe6b9SJerome Glisse break; 213771fe6b9SJerome Glisse case COMBIOS_LCD_INFO_TABLE: 214771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x40); 215771fe6b9SJerome Glisse if (check_offset) 216771fe6b9SJerome Glisse offset = check_offset; 217771fe6b9SJerome Glisse break; 218771fe6b9SJerome Glisse case COMBIOS_MOBILE_INFO_TABLE: 219771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x42); 220771fe6b9SJerome Glisse if (check_offset) 221771fe6b9SJerome Glisse offset = check_offset; 222771fe6b9SJerome Glisse break; 223771fe6b9SJerome Glisse case COMBIOS_PLL_INIT_TABLE: 224771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x46); 225771fe6b9SJerome Glisse if (check_offset) 226771fe6b9SJerome Glisse offset = check_offset; 227771fe6b9SJerome Glisse break; 228771fe6b9SJerome Glisse case COMBIOS_MEM_CONFIG_TABLE: 229771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x48); 230771fe6b9SJerome Glisse if (check_offset) 231771fe6b9SJerome Glisse offset = check_offset; 232771fe6b9SJerome Glisse break; 233771fe6b9SJerome Glisse case COMBIOS_SAVE_MASK_TABLE: 234771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x4a); 235771fe6b9SJerome Glisse if (check_offset) 236771fe6b9SJerome Glisse offset = check_offset; 237771fe6b9SJerome Glisse break; 238771fe6b9SJerome Glisse case COMBIOS_HARDCODED_EDID_TABLE: 239771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x4c); 240771fe6b9SJerome Glisse if (check_offset) 241771fe6b9SJerome Glisse offset = check_offset; 242771fe6b9SJerome Glisse break; 243771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_2_TABLE: 244771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x4e); 245771fe6b9SJerome Glisse if (check_offset) 246771fe6b9SJerome Glisse offset = check_offset; 247771fe6b9SJerome Glisse break; 248771fe6b9SJerome Glisse case COMBIOS_CONNECTOR_INFO_TABLE: 249771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x50); 250771fe6b9SJerome Glisse if (check_offset) 251771fe6b9SJerome Glisse offset = check_offset; 252771fe6b9SJerome Glisse break; 253771fe6b9SJerome Glisse case COMBIOS_DYN_CLK_1_TABLE: 254771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x52); 255771fe6b9SJerome Glisse if (check_offset) 256771fe6b9SJerome Glisse offset = check_offset; 257771fe6b9SJerome Glisse break; 258771fe6b9SJerome Glisse case COMBIOS_RESERVED_MEM_TABLE: 259771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x54); 260771fe6b9SJerome Glisse if (check_offset) 261771fe6b9SJerome Glisse offset = check_offset; 262771fe6b9SJerome Glisse break; 263771fe6b9SJerome Glisse case COMBIOS_EXT_TMDS_INFO_TABLE: 264771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x58); 265771fe6b9SJerome Glisse if (check_offset) 266771fe6b9SJerome Glisse offset = check_offset; 267771fe6b9SJerome Glisse break; 268771fe6b9SJerome Glisse case COMBIOS_MEM_CLK_INFO_TABLE: 269771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x5a); 270771fe6b9SJerome Glisse if (check_offset) 271771fe6b9SJerome Glisse offset = check_offset; 272771fe6b9SJerome Glisse break; 273771fe6b9SJerome Glisse case COMBIOS_EXT_DAC_INFO_TABLE: 274771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x5c); 275771fe6b9SJerome Glisse if (check_offset) 276771fe6b9SJerome Glisse offset = check_offset; 277771fe6b9SJerome Glisse break; 278771fe6b9SJerome Glisse case COMBIOS_MISC_INFO_TABLE: 279771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x5e); 280771fe6b9SJerome Glisse if (check_offset) 281771fe6b9SJerome Glisse offset = check_offset; 282771fe6b9SJerome Glisse break; 283771fe6b9SJerome Glisse case COMBIOS_CRT_INFO_TABLE: 284771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x60); 285771fe6b9SJerome Glisse if (check_offset) 286771fe6b9SJerome Glisse offset = check_offset; 287771fe6b9SJerome Glisse break; 288771fe6b9SJerome Glisse case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE: 289771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x62); 290771fe6b9SJerome Glisse if (check_offset) 291771fe6b9SJerome Glisse offset = check_offset; 292771fe6b9SJerome Glisse break; 293771fe6b9SJerome Glisse case COMBIOS_COMPONENT_VIDEO_INFO_TABLE: 294771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x64); 295771fe6b9SJerome Glisse if (check_offset) 296771fe6b9SJerome Glisse offset = check_offset; 297771fe6b9SJerome Glisse break; 298771fe6b9SJerome Glisse case COMBIOS_FAN_SPEED_INFO_TABLE: 299771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x66); 300771fe6b9SJerome Glisse if (check_offset) 301771fe6b9SJerome Glisse offset = check_offset; 302771fe6b9SJerome Glisse break; 303771fe6b9SJerome Glisse case COMBIOS_OVERDRIVE_INFO_TABLE: 304771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x68); 305771fe6b9SJerome Glisse if (check_offset) 306771fe6b9SJerome Glisse offset = check_offset; 307771fe6b9SJerome Glisse break; 308771fe6b9SJerome Glisse case COMBIOS_OEM_INFO_TABLE: 309771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x6a); 310771fe6b9SJerome Glisse if (check_offset) 311771fe6b9SJerome Glisse offset = check_offset; 312771fe6b9SJerome Glisse break; 313771fe6b9SJerome Glisse case COMBIOS_DYN_CLK_2_TABLE: 314771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x6c); 315771fe6b9SJerome Glisse if (check_offset) 316771fe6b9SJerome Glisse offset = check_offset; 317771fe6b9SJerome Glisse break; 318771fe6b9SJerome Glisse case COMBIOS_POWER_CONNECTOR_INFO_TABLE: 319771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x6e); 320771fe6b9SJerome Glisse if (check_offset) 321771fe6b9SJerome Glisse offset = check_offset; 322771fe6b9SJerome Glisse break; 323771fe6b9SJerome Glisse case COMBIOS_I2C_INFO_TABLE: 324771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x70); 325771fe6b9SJerome Glisse if (check_offset) 326771fe6b9SJerome Glisse offset = check_offset; 327771fe6b9SJerome Glisse break; 328771fe6b9SJerome Glisse /* relative offset tables */ 329771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_3_TABLE: /* offset from misc info */ 330771fe6b9SJerome Glisse check_offset = 331771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 332771fe6b9SJerome Glisse if (check_offset) { 333771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 334771fe6b9SJerome Glisse if (rev > 0) { 335771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x3); 336771fe6b9SJerome Glisse if (check_offset) 337771fe6b9SJerome Glisse offset = check_offset; 338771fe6b9SJerome Glisse } 339771fe6b9SJerome Glisse } 340771fe6b9SJerome Glisse break; 341771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_4_TABLE: /* offset from misc info */ 342771fe6b9SJerome Glisse check_offset = 343771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 344771fe6b9SJerome Glisse if (check_offset) { 345771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 346771fe6b9SJerome Glisse if (rev > 0) { 347771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x5); 348771fe6b9SJerome Glisse if (check_offset) 349771fe6b9SJerome Glisse offset = check_offset; 350771fe6b9SJerome Glisse } 351771fe6b9SJerome Glisse } 352771fe6b9SJerome Glisse break; 353771fe6b9SJerome Glisse case COMBIOS_DETECTED_MEM_TABLE: /* offset from misc info */ 354771fe6b9SJerome Glisse check_offset = 355771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 356771fe6b9SJerome Glisse if (check_offset) { 357771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 358771fe6b9SJerome Glisse if (rev > 0) { 359771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x7); 360771fe6b9SJerome Glisse if (check_offset) 361771fe6b9SJerome Glisse offset = check_offset; 362771fe6b9SJerome Glisse } 363771fe6b9SJerome Glisse } 364771fe6b9SJerome Glisse break; 365771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_5_TABLE: /* offset from misc info */ 366771fe6b9SJerome Glisse check_offset = 367771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 368771fe6b9SJerome Glisse if (check_offset) { 369771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 370771fe6b9SJerome Glisse if (rev == 2) { 371771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x9); 372771fe6b9SJerome Glisse if (check_offset) 373771fe6b9SJerome Glisse offset = check_offset; 374771fe6b9SJerome Glisse } 375771fe6b9SJerome Glisse } 376771fe6b9SJerome Glisse break; 377771fe6b9SJerome Glisse case COMBIOS_RAM_RESET_TABLE: /* offset from mem config */ 378771fe6b9SJerome Glisse check_offset = 379771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 380771fe6b9SJerome Glisse if (check_offset) { 381771fe6b9SJerome Glisse while (RBIOS8(check_offset++)); 382771fe6b9SJerome Glisse check_offset += 2; 383771fe6b9SJerome Glisse if (check_offset) 384771fe6b9SJerome Glisse offset = check_offset; 385771fe6b9SJerome Glisse } 386771fe6b9SJerome Glisse break; 387771fe6b9SJerome Glisse case COMBIOS_POWERPLAY_INFO_TABLE: /* offset from mobile info */ 388771fe6b9SJerome Glisse check_offset = 389771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 390771fe6b9SJerome Glisse if (check_offset) { 391771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x11); 392771fe6b9SJerome Glisse if (check_offset) 393771fe6b9SJerome Glisse offset = check_offset; 394771fe6b9SJerome Glisse } 395771fe6b9SJerome Glisse break; 396771fe6b9SJerome Glisse case COMBIOS_GPIO_INFO_TABLE: /* offset from mobile info */ 397771fe6b9SJerome Glisse check_offset = 398771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 399771fe6b9SJerome Glisse if (check_offset) { 400771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x13); 401771fe6b9SJerome Glisse if (check_offset) 402771fe6b9SJerome Glisse offset = check_offset; 403771fe6b9SJerome Glisse } 404771fe6b9SJerome Glisse break; 405771fe6b9SJerome Glisse case COMBIOS_LCD_DDC_INFO_TABLE: /* offset from mobile info */ 406771fe6b9SJerome Glisse check_offset = 407771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 408771fe6b9SJerome Glisse if (check_offset) { 409771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x15); 410771fe6b9SJerome Glisse if (check_offset) 411771fe6b9SJerome Glisse offset = check_offset; 412771fe6b9SJerome Glisse } 413771fe6b9SJerome Glisse break; 414771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_TABLE: /* offset from mobile info */ 415771fe6b9SJerome Glisse check_offset = 416771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 417771fe6b9SJerome Glisse if (check_offset) { 418771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x17); 419771fe6b9SJerome Glisse if (check_offset) 420771fe6b9SJerome Glisse offset = check_offset; 421771fe6b9SJerome Glisse } 422771fe6b9SJerome Glisse break; 423771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_ON_TABLE: /* offset from tmds power */ 424771fe6b9SJerome Glisse check_offset = 425771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); 426771fe6b9SJerome Glisse if (check_offset) { 427771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x2); 428771fe6b9SJerome Glisse if (check_offset) 429771fe6b9SJerome Glisse offset = check_offset; 430771fe6b9SJerome Glisse } 431771fe6b9SJerome Glisse break; 432771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_OFF_TABLE: /* offset from tmds power */ 433771fe6b9SJerome Glisse check_offset = 434771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); 435771fe6b9SJerome Glisse if (check_offset) { 436771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x4); 437771fe6b9SJerome Glisse if (check_offset) 438771fe6b9SJerome Glisse offset = check_offset; 439771fe6b9SJerome Glisse } 440771fe6b9SJerome Glisse break; 441771fe6b9SJerome Glisse default: 442771fe6b9SJerome Glisse break; 443771fe6b9SJerome Glisse } 444771fe6b9SJerome Glisse 445771fe6b9SJerome Glisse return offset; 446771fe6b9SJerome Glisse 447771fe6b9SJerome Glisse } 448771fe6b9SJerome Glisse 4493c537889SAlex Deucher bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev) 4503c537889SAlex Deucher { 4513c537889SAlex Deucher int edid_info; 4523c537889SAlex Deucher struct edid *edid; 4537466f4ccSAdam Jackson unsigned char *raw; 4543c537889SAlex Deucher edid_info = combios_get_table_offset(rdev->ddev, COMBIOS_HARDCODED_EDID_TABLE); 4553c537889SAlex Deucher if (!edid_info) 4563c537889SAlex Deucher return false; 4573c537889SAlex Deucher 4587466f4ccSAdam Jackson raw = rdev->bios + edid_info; 4597466f4ccSAdam Jackson edid = kmalloc(EDID_LENGTH * (raw[0x7e] + 1), GFP_KERNEL); 4603c537889SAlex Deucher if (edid == NULL) 4613c537889SAlex Deucher return false; 4623c537889SAlex Deucher 4637466f4ccSAdam Jackson memcpy((unsigned char *)edid, raw, EDID_LENGTH * (raw[0x7e] + 1)); 4643c537889SAlex Deucher 4653c537889SAlex Deucher if (!drm_edid_is_valid(edid)) { 4663c537889SAlex Deucher kfree(edid); 4673c537889SAlex Deucher return false; 4683c537889SAlex Deucher } 4693c537889SAlex Deucher 4703c537889SAlex Deucher rdev->mode_info.bios_hardcoded_edid = edid; 4713c537889SAlex Deucher return true; 4723c537889SAlex Deucher } 4733c537889SAlex Deucher 4743c537889SAlex Deucher struct edid * 4753c537889SAlex Deucher radeon_combios_get_hardcoded_edid(struct radeon_device *rdev) 4763c537889SAlex Deucher { 4773c537889SAlex Deucher if (rdev->mode_info.bios_hardcoded_edid) 4783c537889SAlex Deucher return rdev->mode_info.bios_hardcoded_edid; 4793c537889SAlex Deucher return NULL; 4803c537889SAlex Deucher } 4813c537889SAlex Deucher 4826a93cb25SAlex Deucher static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev, 483179e8078SAlex Deucher enum radeon_combios_ddc ddc, 484179e8078SAlex Deucher u32 clk_mask, 485179e8078SAlex Deucher u32 data_mask) 486771fe6b9SJerome Glisse { 487771fe6b9SJerome Glisse struct radeon_i2c_bus_rec i2c; 488179e8078SAlex Deucher int ddc_line = 0; 489179e8078SAlex Deucher 490179e8078SAlex Deucher /* ddc id = mask reg 491179e8078SAlex Deucher * DDC_NONE_DETECTED = none 492179e8078SAlex Deucher * DDC_DVI = RADEON_GPIO_DVI_DDC 493179e8078SAlex Deucher * DDC_VGA = RADEON_GPIO_VGA_DDC 494179e8078SAlex Deucher * DDC_LCD = RADEON_GPIOPAD_MASK 495179e8078SAlex Deucher * DDC_GPIO = RADEON_MDGPIO_MASK 496179e8078SAlex Deucher * r1xx/r2xx 497179e8078SAlex Deucher * DDC_MONID = RADEON_GPIO_MONID 498179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_CRT2_DDC 499179e8078SAlex Deucher * r3xx 500179e8078SAlex Deucher * DDC_MONID = RADEON_GPIO_MONID 501179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_DVI_DDC 502179e8078SAlex Deucher * rs3xx/rs4xx 503179e8078SAlex Deucher * DDC_MONID = RADEON_GPIOPAD_MASK 504179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_MONID 505179e8078SAlex Deucher */ 506179e8078SAlex Deucher switch (ddc) { 507179e8078SAlex Deucher case DDC_NONE_DETECTED: 508179e8078SAlex Deucher default: 509179e8078SAlex Deucher ddc_line = 0; 510179e8078SAlex Deucher break; 511179e8078SAlex Deucher case DDC_DVI: 512179e8078SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 513179e8078SAlex Deucher break; 514179e8078SAlex Deucher case DDC_VGA: 515179e8078SAlex Deucher ddc_line = RADEON_GPIO_VGA_DDC; 516179e8078SAlex Deucher break; 517179e8078SAlex Deucher case DDC_LCD: 518179e8078SAlex Deucher ddc_line = RADEON_GPIOPAD_MASK; 519179e8078SAlex Deucher break; 520179e8078SAlex Deucher case DDC_GPIO: 521179e8078SAlex Deucher ddc_line = RADEON_MDGPIO_MASK; 522179e8078SAlex Deucher break; 523179e8078SAlex Deucher case DDC_MONID: 524179e8078SAlex Deucher if (rdev->family == CHIP_RS300 || 525179e8078SAlex Deucher rdev->family == CHIP_RS400 || 526179e8078SAlex Deucher rdev->family == CHIP_RS480) 527179e8078SAlex Deucher ddc_line = RADEON_GPIOPAD_MASK; 528179e8078SAlex Deucher else 529179e8078SAlex Deucher ddc_line = RADEON_GPIO_MONID; 530179e8078SAlex Deucher break; 531179e8078SAlex Deucher case DDC_CRT2: 532179e8078SAlex Deucher if (rdev->family == CHIP_RS300 || 533179e8078SAlex Deucher rdev->family == CHIP_RS400 || 534179e8078SAlex Deucher rdev->family == CHIP_RS480) 535179e8078SAlex Deucher ddc_line = RADEON_GPIO_MONID; 536179e8078SAlex Deucher else if (rdev->family >= CHIP_R300) { 537179e8078SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 538179e8078SAlex Deucher ddc = DDC_DVI; 539179e8078SAlex Deucher } else 540179e8078SAlex Deucher ddc_line = RADEON_GPIO_CRT2_DDC; 541179e8078SAlex Deucher break; 542179e8078SAlex Deucher } 543771fe6b9SJerome Glisse 5446a93cb25SAlex Deucher if (ddc_line == RADEON_GPIOPAD_MASK) { 5456a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_GPIOPAD_MASK; 5466a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_GPIOPAD_MASK; 5476a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_GPIOPAD_A; 5486a93cb25SAlex Deucher i2c.a_data_reg = RADEON_GPIOPAD_A; 5496a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_GPIOPAD_EN; 5506a93cb25SAlex Deucher i2c.en_data_reg = RADEON_GPIOPAD_EN; 5516a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_GPIOPAD_Y; 5526a93cb25SAlex Deucher i2c.y_data_reg = RADEON_GPIOPAD_Y; 5536a93cb25SAlex Deucher } else if (ddc_line == RADEON_MDGPIO_MASK) { 5546a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_MDGPIO_MASK; 5556a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_MDGPIO_MASK; 5566a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_MDGPIO_A; 5576a93cb25SAlex Deucher i2c.a_data_reg = RADEON_MDGPIO_A; 5586a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_MDGPIO_EN; 5596a93cb25SAlex Deucher i2c.en_data_reg = RADEON_MDGPIO_EN; 5606a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_MDGPIO_Y; 5616a93cb25SAlex Deucher i2c.y_data_reg = RADEON_MDGPIO_Y; 5626a93cb25SAlex Deucher } else { 563771fe6b9SJerome Glisse i2c.mask_clk_reg = ddc_line; 564771fe6b9SJerome Glisse i2c.mask_data_reg = ddc_line; 565771fe6b9SJerome Glisse i2c.a_clk_reg = ddc_line; 566771fe6b9SJerome Glisse i2c.a_data_reg = ddc_line; 5679b9fe724SAlex Deucher i2c.en_clk_reg = ddc_line; 5689b9fe724SAlex Deucher i2c.en_data_reg = ddc_line; 5699b9fe724SAlex Deucher i2c.y_clk_reg = ddc_line; 5709b9fe724SAlex Deucher i2c.y_data_reg = ddc_line; 571771fe6b9SJerome Glisse } 572771fe6b9SJerome Glisse 573179e8078SAlex Deucher if (clk_mask && data_mask) { 574179e8078SAlex Deucher i2c.mask_clk_mask = clk_mask; 575179e8078SAlex Deucher i2c.mask_data_mask = data_mask; 576179e8078SAlex Deucher i2c.a_clk_mask = clk_mask; 577179e8078SAlex Deucher i2c.a_data_mask = data_mask; 578179e8078SAlex Deucher i2c.en_clk_mask = clk_mask; 579179e8078SAlex Deucher i2c.en_data_mask = data_mask; 580179e8078SAlex Deucher i2c.y_clk_mask = clk_mask; 581179e8078SAlex Deucher i2c.y_data_mask = data_mask; 582179e8078SAlex Deucher } else { 583179e8078SAlex Deucher i2c.mask_clk_mask = RADEON_GPIO_EN_1; 584179e8078SAlex Deucher i2c.mask_data_mask = RADEON_GPIO_EN_0; 585179e8078SAlex Deucher i2c.a_clk_mask = RADEON_GPIO_A_1; 586179e8078SAlex Deucher i2c.a_data_mask = RADEON_GPIO_A_0; 587179e8078SAlex Deucher i2c.en_clk_mask = RADEON_GPIO_EN_1; 588179e8078SAlex Deucher i2c.en_data_mask = RADEON_GPIO_EN_0; 589179e8078SAlex Deucher i2c.y_clk_mask = RADEON_GPIO_Y_1; 590179e8078SAlex Deucher i2c.y_data_mask = RADEON_GPIO_Y_0; 591179e8078SAlex Deucher } 592179e8078SAlex Deucher 59340bacf16SAlex Deucher switch (rdev->family) { 59440bacf16SAlex Deucher case CHIP_R100: 59540bacf16SAlex Deucher case CHIP_RV100: 59640bacf16SAlex Deucher case CHIP_RS100: 59740bacf16SAlex Deucher case CHIP_RV200: 59840bacf16SAlex Deucher case CHIP_RS200: 59940bacf16SAlex Deucher case CHIP_RS300: 60040bacf16SAlex Deucher switch (ddc_line) { 60140bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 602b28ea411SAlex Deucher i2c.hw_capable = true; 60340bacf16SAlex Deucher break; 60440bacf16SAlex Deucher default: 60540bacf16SAlex Deucher i2c.hw_capable = false; 60640bacf16SAlex Deucher break; 60740bacf16SAlex Deucher } 60840bacf16SAlex Deucher break; 60940bacf16SAlex Deucher case CHIP_R200: 61040bacf16SAlex Deucher switch (ddc_line) { 61140bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 61240bacf16SAlex Deucher case RADEON_GPIO_MONID: 61340bacf16SAlex Deucher i2c.hw_capable = true; 61440bacf16SAlex Deucher break; 61540bacf16SAlex Deucher default: 61640bacf16SAlex Deucher i2c.hw_capable = false; 61740bacf16SAlex Deucher break; 61840bacf16SAlex Deucher } 61940bacf16SAlex Deucher break; 62040bacf16SAlex Deucher case CHIP_RV250: 62140bacf16SAlex Deucher case CHIP_RV280: 62240bacf16SAlex Deucher switch (ddc_line) { 62340bacf16SAlex Deucher case RADEON_GPIO_VGA_DDC: 62440bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 62540bacf16SAlex Deucher case RADEON_GPIO_CRT2_DDC: 62640bacf16SAlex Deucher i2c.hw_capable = true; 62740bacf16SAlex Deucher break; 62840bacf16SAlex Deucher default: 62940bacf16SAlex Deucher i2c.hw_capable = false; 63040bacf16SAlex Deucher break; 63140bacf16SAlex Deucher } 63240bacf16SAlex Deucher break; 63340bacf16SAlex Deucher case CHIP_R300: 63440bacf16SAlex Deucher case CHIP_R350: 63540bacf16SAlex Deucher switch (ddc_line) { 63640bacf16SAlex Deucher case RADEON_GPIO_VGA_DDC: 63740bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 63840bacf16SAlex Deucher i2c.hw_capable = true; 63940bacf16SAlex Deucher break; 64040bacf16SAlex Deucher default: 64140bacf16SAlex Deucher i2c.hw_capable = false; 64240bacf16SAlex Deucher break; 64340bacf16SAlex Deucher } 64440bacf16SAlex Deucher break; 64540bacf16SAlex Deucher case CHIP_RV350: 64640bacf16SAlex Deucher case CHIP_RV380: 64740bacf16SAlex Deucher case CHIP_RS400: 64840bacf16SAlex Deucher case CHIP_RS480: 6496a93cb25SAlex Deucher switch (ddc_line) { 6506a93cb25SAlex Deucher case RADEON_GPIO_VGA_DDC: 6516a93cb25SAlex Deucher case RADEON_GPIO_DVI_DDC: 6526a93cb25SAlex Deucher i2c.hw_capable = true; 6536a93cb25SAlex Deucher break; 6546a93cb25SAlex Deucher case RADEON_GPIO_MONID: 6556a93cb25SAlex Deucher /* hw i2c on RADEON_GPIO_MONID doesn't seem to work 6566a93cb25SAlex Deucher * reliably on some pre-r4xx hardware; not sure why. 6576a93cb25SAlex Deucher */ 6586a93cb25SAlex Deucher i2c.hw_capable = false; 6596a93cb25SAlex Deucher break; 6606a93cb25SAlex Deucher default: 6616a93cb25SAlex Deucher i2c.hw_capable = false; 6626a93cb25SAlex Deucher break; 6636a93cb25SAlex Deucher } 66440bacf16SAlex Deucher break; 66540bacf16SAlex Deucher default: 66640bacf16SAlex Deucher i2c.hw_capable = false; 66740bacf16SAlex Deucher break; 6686a93cb25SAlex Deucher } 6696a93cb25SAlex Deucher i2c.mm_i2c = false; 670f376b94fSAlex Deucher 671179e8078SAlex Deucher i2c.i2c_id = ddc; 6728e36ed00SAlex Deucher i2c.hpd = RADEON_HPD_NONE; 6736a93cb25SAlex Deucher 674771fe6b9SJerome Glisse if (ddc_line) 675771fe6b9SJerome Glisse i2c.valid = true; 676771fe6b9SJerome Glisse else 677771fe6b9SJerome Glisse i2c.valid = false; 678771fe6b9SJerome Glisse 679771fe6b9SJerome Glisse return i2c; 680771fe6b9SJerome Glisse } 681771fe6b9SJerome Glisse 682f376b94fSAlex Deucher void radeon_combios_i2c_init(struct radeon_device *rdev) 683f376b94fSAlex Deucher { 684f376b94fSAlex Deucher struct drm_device *dev = rdev->ddev; 685f376b94fSAlex Deucher struct radeon_i2c_bus_rec i2c; 686f376b94fSAlex Deucher 687f376b94fSAlex Deucher 688179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 689179e8078SAlex Deucher rdev->i2c_bus[0] = radeon_i2c_create(dev, &i2c, "DVI_DDC"); 690f376b94fSAlex Deucher 691179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 692179e8078SAlex Deucher rdev->i2c_bus[1] = radeon_i2c_create(dev, &i2c, "VGA_DDC"); 693f376b94fSAlex Deucher 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 700179e8078SAlex Deucher if (rdev->family == CHIP_RS300 || 701179e8078SAlex Deucher rdev->family == CHIP_RS400 || 702179e8078SAlex Deucher rdev->family == CHIP_RS480) { 703179e8078SAlex Deucher u16 offset; 704179e8078SAlex Deucher u8 id, blocks, clk, data; 705179e8078SAlex Deucher int i; 706179e8078SAlex Deucher 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 710179e8078SAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE); 711179e8078SAlex Deucher if (offset) { 712179e8078SAlex Deucher blocks = RBIOS8(offset + 2); 713179e8078SAlex Deucher for (i = 0; i < blocks; i++) { 714179e8078SAlex Deucher id = RBIOS8(offset + 3 + (i * 5) + 0); 715179e8078SAlex Deucher if (id == 136) { 716179e8078SAlex Deucher clk = RBIOS8(offset + 3 + (i * 5) + 3); 717179e8078SAlex Deucher data = RBIOS8(offset + 3 + (i * 5) + 4); 718179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 719179e8078SAlex Deucher clk, data); 720179e8078SAlex Deucher rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "GPIOPAD_MASK"); 721179e8078SAlex Deucher break; 722179e8078SAlex Deucher } 723179e8078SAlex Deucher } 724179e8078SAlex Deucher } 725179e8078SAlex Deucher 726179e8078SAlex Deucher } else if (rdev->family >= CHIP_R300) { 727179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 728179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 729179e8078SAlex Deucher } else { 730179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 731179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 732179e8078SAlex Deucher 733179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 734179e8078SAlex Deucher rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "CRT2_DDC"); 735179e8078SAlex Deucher } 736f376b94fSAlex Deucher } 737f376b94fSAlex Deucher 738771fe6b9SJerome Glisse bool radeon_combios_get_clock_info(struct drm_device *dev) 739771fe6b9SJerome Glisse { 740771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 741771fe6b9SJerome Glisse uint16_t pll_info; 742771fe6b9SJerome Glisse struct radeon_pll *p1pll = &rdev->clock.p1pll; 743771fe6b9SJerome Glisse struct radeon_pll *p2pll = &rdev->clock.p2pll; 744771fe6b9SJerome Glisse struct radeon_pll *spll = &rdev->clock.spll; 745771fe6b9SJerome Glisse struct radeon_pll *mpll = &rdev->clock.mpll; 746771fe6b9SJerome Glisse int8_t rev; 747771fe6b9SJerome Glisse uint16_t sclk, mclk; 748771fe6b9SJerome Glisse 749771fe6b9SJerome Glisse pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE); 750771fe6b9SJerome Glisse if (pll_info) { 751771fe6b9SJerome Glisse rev = RBIOS8(pll_info); 752771fe6b9SJerome Glisse 753771fe6b9SJerome Glisse /* pixel clocks */ 754771fe6b9SJerome Glisse p1pll->reference_freq = RBIOS16(pll_info + 0xe); 755771fe6b9SJerome Glisse p1pll->reference_div = RBIOS16(pll_info + 0x10); 756771fe6b9SJerome Glisse p1pll->pll_out_min = RBIOS32(pll_info + 0x12); 757771fe6b9SJerome Glisse p1pll->pll_out_max = RBIOS32(pll_info + 0x16); 75886cb2bbfSAlex Deucher p1pll->lcd_pll_out_min = p1pll->pll_out_min; 75986cb2bbfSAlex Deucher p1pll->lcd_pll_out_max = p1pll->pll_out_max; 760771fe6b9SJerome Glisse 761771fe6b9SJerome Glisse if (rev > 9) { 762771fe6b9SJerome Glisse p1pll->pll_in_min = RBIOS32(pll_info + 0x36); 763771fe6b9SJerome Glisse p1pll->pll_in_max = RBIOS32(pll_info + 0x3a); 764771fe6b9SJerome Glisse } else { 765771fe6b9SJerome Glisse p1pll->pll_in_min = 40; 766771fe6b9SJerome Glisse p1pll->pll_in_max = 500; 767771fe6b9SJerome Glisse } 768771fe6b9SJerome Glisse *p2pll = *p1pll; 769771fe6b9SJerome Glisse 770771fe6b9SJerome Glisse /* system clock */ 771771fe6b9SJerome Glisse spll->reference_freq = RBIOS16(pll_info + 0x1a); 772771fe6b9SJerome Glisse spll->reference_div = RBIOS16(pll_info + 0x1c); 773771fe6b9SJerome Glisse spll->pll_out_min = RBIOS32(pll_info + 0x1e); 774771fe6b9SJerome Glisse spll->pll_out_max = RBIOS32(pll_info + 0x22); 775771fe6b9SJerome Glisse 776771fe6b9SJerome Glisse if (rev > 10) { 777771fe6b9SJerome Glisse spll->pll_in_min = RBIOS32(pll_info + 0x48); 778771fe6b9SJerome Glisse spll->pll_in_max = RBIOS32(pll_info + 0x4c); 779771fe6b9SJerome Glisse } else { 780771fe6b9SJerome Glisse /* ??? */ 781771fe6b9SJerome Glisse spll->pll_in_min = 40; 782771fe6b9SJerome Glisse spll->pll_in_max = 500; 783771fe6b9SJerome Glisse } 784771fe6b9SJerome Glisse 785771fe6b9SJerome Glisse /* memory clock */ 786771fe6b9SJerome Glisse mpll->reference_freq = RBIOS16(pll_info + 0x26); 787771fe6b9SJerome Glisse mpll->reference_div = RBIOS16(pll_info + 0x28); 788771fe6b9SJerome Glisse mpll->pll_out_min = RBIOS32(pll_info + 0x2a); 789771fe6b9SJerome Glisse mpll->pll_out_max = RBIOS32(pll_info + 0x2e); 790771fe6b9SJerome Glisse 791771fe6b9SJerome Glisse if (rev > 10) { 792771fe6b9SJerome Glisse mpll->pll_in_min = RBIOS32(pll_info + 0x5a); 793771fe6b9SJerome Glisse mpll->pll_in_max = RBIOS32(pll_info + 0x5e); 794771fe6b9SJerome Glisse } else { 795771fe6b9SJerome Glisse /* ??? */ 796771fe6b9SJerome Glisse mpll->pll_in_min = 40; 797771fe6b9SJerome Glisse mpll->pll_in_max = 500; 798771fe6b9SJerome Glisse } 799771fe6b9SJerome Glisse 800771fe6b9SJerome Glisse /* default sclk/mclk */ 801771fe6b9SJerome Glisse sclk = RBIOS16(pll_info + 0xa); 802771fe6b9SJerome Glisse mclk = RBIOS16(pll_info + 0x8); 803771fe6b9SJerome Glisse if (sclk == 0) 804771fe6b9SJerome Glisse sclk = 200 * 100; 805771fe6b9SJerome Glisse if (mclk == 0) 806771fe6b9SJerome Glisse mclk = 200 * 100; 807771fe6b9SJerome Glisse 808771fe6b9SJerome Glisse rdev->clock.default_sclk = sclk; 809771fe6b9SJerome Glisse rdev->clock.default_mclk = mclk; 810771fe6b9SJerome Glisse 811771fe6b9SJerome Glisse return true; 812771fe6b9SJerome Glisse } 813771fe6b9SJerome Glisse return false; 814771fe6b9SJerome Glisse } 815771fe6b9SJerome Glisse 81606b6476dSAlex Deucher bool radeon_combios_sideport_present(struct radeon_device *rdev) 81706b6476dSAlex Deucher { 81806b6476dSAlex Deucher struct drm_device *dev = rdev->ddev; 81906b6476dSAlex Deucher u16 igp_info; 82006b6476dSAlex Deucher 8214c70b2eaSAlex Deucher /* sideport is AMD only */ 8224c70b2eaSAlex Deucher if (rdev->family == CHIP_RS400) 8234c70b2eaSAlex Deucher return false; 8244c70b2eaSAlex Deucher 82506b6476dSAlex Deucher igp_info = combios_get_table_offset(dev, COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE); 82606b6476dSAlex Deucher 82706b6476dSAlex Deucher if (igp_info) { 82806b6476dSAlex Deucher if (RBIOS16(igp_info + 0x4)) 82906b6476dSAlex Deucher return true; 83006b6476dSAlex Deucher } 83106b6476dSAlex Deucher return false; 83206b6476dSAlex Deucher } 83306b6476dSAlex Deucher 834246263ccSAlex Deucher static const uint32_t default_primarydac_adj[CHIP_LAST] = { 835246263ccSAlex Deucher 0x00000808, /* r100 */ 836246263ccSAlex Deucher 0x00000808, /* rv100 */ 837246263ccSAlex Deucher 0x00000808, /* rs100 */ 838246263ccSAlex Deucher 0x00000808, /* rv200 */ 839246263ccSAlex Deucher 0x00000808, /* rs200 */ 840246263ccSAlex Deucher 0x00000808, /* r200 */ 841246263ccSAlex Deucher 0x00000808, /* rv250 */ 842246263ccSAlex Deucher 0x00000000, /* rs300 */ 843246263ccSAlex Deucher 0x00000808, /* rv280 */ 844246263ccSAlex Deucher 0x00000808, /* r300 */ 845246263ccSAlex Deucher 0x00000808, /* r350 */ 846246263ccSAlex Deucher 0x00000808, /* rv350 */ 847246263ccSAlex Deucher 0x00000808, /* rv380 */ 848246263ccSAlex Deucher 0x00000808, /* r420 */ 849246263ccSAlex Deucher 0x00000808, /* r423 */ 850246263ccSAlex Deucher 0x00000808, /* rv410 */ 851246263ccSAlex Deucher 0x00000000, /* rs400 */ 852246263ccSAlex Deucher 0x00000000, /* rs480 */ 853246263ccSAlex Deucher }; 854246263ccSAlex Deucher 855246263ccSAlex Deucher static void radeon_legacy_get_primary_dac_info_from_table(struct radeon_device *rdev, 856246263ccSAlex Deucher struct radeon_encoder_primary_dac *p_dac) 857246263ccSAlex Deucher { 858246263ccSAlex Deucher p_dac->ps2_pdac_adj = default_primarydac_adj[rdev->family]; 859246263ccSAlex Deucher return; 860246263ccSAlex Deucher } 861246263ccSAlex Deucher 862771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct 863771fe6b9SJerome Glisse radeon_encoder 864771fe6b9SJerome Glisse *encoder) 865771fe6b9SJerome Glisse { 866771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 867771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 868771fe6b9SJerome Glisse uint16_t dac_info; 869771fe6b9SJerome Glisse uint8_t rev, bg, dac; 870771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *p_dac = NULL; 871246263ccSAlex Deucher int found = 0; 872771fe6b9SJerome Glisse 873246263ccSAlex Deucher p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), 874771fe6b9SJerome Glisse GFP_KERNEL); 875771fe6b9SJerome Glisse 876771fe6b9SJerome Glisse if (!p_dac) 877771fe6b9SJerome Glisse return NULL; 878771fe6b9SJerome Glisse 879246263ccSAlex Deucher /* check CRT table */ 880246263ccSAlex Deucher dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 881246263ccSAlex Deucher if (dac_info) { 882771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 883771fe6b9SJerome Glisse if (rev < 2) { 884771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 885771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf; 886771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 887771fe6b9SJerome Glisse } else { 888771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 889771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x3) & 0xf; 890771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 891771fe6b9SJerome Glisse } 8923a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 8933a89b4a9SAlex Deucher if (p_dac->ps2_pdac_adj) 894246263ccSAlex Deucher found = 1; 895771fe6b9SJerome Glisse } 896771fe6b9SJerome Glisse 897246263ccSAlex Deucher if (!found) /* fallback to defaults */ 898246263ccSAlex Deucher radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac); 899246263ccSAlex Deucher 900771fe6b9SJerome Glisse return p_dac; 901771fe6b9SJerome Glisse } 902771fe6b9SJerome Glisse 903d79766faSAlex Deucher enum radeon_tv_std 904d79766faSAlex Deucher radeon_combios_get_tv_info(struct radeon_device *rdev) 905771fe6b9SJerome Glisse { 906d79766faSAlex Deucher struct drm_device *dev = rdev->ddev; 907771fe6b9SJerome Glisse uint16_t tv_info; 908771fe6b9SJerome Glisse enum radeon_tv_std tv_std = TV_STD_NTSC; 909771fe6b9SJerome Glisse 910771fe6b9SJerome Glisse tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 911771fe6b9SJerome Glisse if (tv_info) { 912771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 913771fe6b9SJerome Glisse switch (RBIOS8(tv_info + 7) & 0xf) { 914771fe6b9SJerome Glisse case 1: 915771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 916*40f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: NTSC\n"); 917771fe6b9SJerome Glisse break; 918771fe6b9SJerome Glisse case 2: 919771fe6b9SJerome Glisse tv_std = TV_STD_PAL; 920*40f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL\n"); 921771fe6b9SJerome Glisse break; 922771fe6b9SJerome Glisse case 3: 923771fe6b9SJerome Glisse tv_std = TV_STD_PAL_M; 924*40f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL-M\n"); 925771fe6b9SJerome Glisse break; 926771fe6b9SJerome Glisse case 4: 927771fe6b9SJerome Glisse tv_std = TV_STD_PAL_60; 928*40f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL-60\n"); 929771fe6b9SJerome Glisse break; 930771fe6b9SJerome Glisse case 5: 931771fe6b9SJerome Glisse tv_std = TV_STD_NTSC_J; 932*40f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: NTSC-J\n"); 933771fe6b9SJerome Glisse break; 934771fe6b9SJerome Glisse case 6: 935771fe6b9SJerome Glisse tv_std = TV_STD_SCART_PAL; 936*40f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: SCART-PAL\n"); 937771fe6b9SJerome Glisse break; 938771fe6b9SJerome Glisse default: 939771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 940*40f76d81SAlex Deucher DRM_DEBUG_KMS 941771fe6b9SJerome Glisse ("Unknown TV standard; defaulting to NTSC\n"); 942771fe6b9SJerome Glisse break; 943771fe6b9SJerome Glisse } 944771fe6b9SJerome Glisse 945771fe6b9SJerome Glisse switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) { 946771fe6b9SJerome Glisse case 0: 947*40f76d81SAlex Deucher DRM_DEBUG_KMS("29.498928713 MHz TV ref clk\n"); 948771fe6b9SJerome Glisse break; 949771fe6b9SJerome Glisse case 1: 950*40f76d81SAlex Deucher DRM_DEBUG_KMS("28.636360000 MHz TV ref clk\n"); 951771fe6b9SJerome Glisse break; 952771fe6b9SJerome Glisse case 2: 953*40f76d81SAlex Deucher DRM_DEBUG_KMS("14.318180000 MHz TV ref clk\n"); 954771fe6b9SJerome Glisse break; 955771fe6b9SJerome Glisse case 3: 956*40f76d81SAlex Deucher DRM_DEBUG_KMS("27.000000000 MHz TV ref clk\n"); 957771fe6b9SJerome Glisse break; 958771fe6b9SJerome Glisse default: 959771fe6b9SJerome Glisse break; 960771fe6b9SJerome Glisse } 961771fe6b9SJerome Glisse } 962771fe6b9SJerome Glisse } 963771fe6b9SJerome Glisse return tv_std; 964771fe6b9SJerome Glisse } 965771fe6b9SJerome Glisse 966771fe6b9SJerome Glisse static const uint32_t default_tvdac_adj[CHIP_LAST] = { 967771fe6b9SJerome Glisse 0x00000000, /* r100 */ 968771fe6b9SJerome Glisse 0x00280000, /* rv100 */ 969771fe6b9SJerome Glisse 0x00000000, /* rs100 */ 970771fe6b9SJerome Glisse 0x00880000, /* rv200 */ 971771fe6b9SJerome Glisse 0x00000000, /* rs200 */ 972771fe6b9SJerome Glisse 0x00000000, /* r200 */ 973771fe6b9SJerome Glisse 0x00770000, /* rv250 */ 974771fe6b9SJerome Glisse 0x00290000, /* rs300 */ 975771fe6b9SJerome Glisse 0x00560000, /* rv280 */ 976771fe6b9SJerome Glisse 0x00780000, /* r300 */ 977771fe6b9SJerome Glisse 0x00770000, /* r350 */ 978771fe6b9SJerome Glisse 0x00780000, /* rv350 */ 979771fe6b9SJerome Glisse 0x00780000, /* rv380 */ 980771fe6b9SJerome Glisse 0x01080000, /* r420 */ 981771fe6b9SJerome Glisse 0x01080000, /* r423 */ 982771fe6b9SJerome Glisse 0x01080000, /* rv410 */ 983771fe6b9SJerome Glisse 0x00780000, /* rs400 */ 984771fe6b9SJerome Glisse 0x00780000, /* rs480 */ 985771fe6b9SJerome Glisse }; 986771fe6b9SJerome Glisse 9876a719e05SDave Airlie static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev, 9886a719e05SDave Airlie struct radeon_encoder_tv_dac *tv_dac) 989771fe6b9SJerome Glisse { 990771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; 991771fe6b9SJerome Glisse if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) 992771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 0x00880000; 993771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 994771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 9956a719e05SDave Airlie return; 996771fe6b9SJerome Glisse } 997771fe6b9SJerome Glisse 998771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct 999771fe6b9SJerome Glisse radeon_encoder 1000771fe6b9SJerome Glisse *encoder) 1001771fe6b9SJerome Glisse { 1002771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1003771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1004771fe6b9SJerome Glisse uint16_t dac_info; 1005771fe6b9SJerome Glisse uint8_t rev, bg, dac; 1006771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *tv_dac = NULL; 10076a719e05SDave Airlie int found = 0; 10086a719e05SDave Airlie 10096a719e05SDave Airlie tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); 10106a719e05SDave Airlie if (!tv_dac) 10116a719e05SDave Airlie return NULL; 1012771fe6b9SJerome Glisse 1013771fe6b9SJerome Glisse /* first check TV table */ 1014771fe6b9SJerome Glisse dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 1015771fe6b9SJerome Glisse if (dac_info) { 1016771fe6b9SJerome Glisse rev = RBIOS8(dac_info + 0x3); 1017771fe6b9SJerome Glisse if (rev > 4) { 1018771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 1019771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xd) & 0xf; 1020771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 1021771fe6b9SJerome Glisse 1022771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 1023771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xf) & 0xf; 1024771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 1025771fe6b9SJerome Glisse 1026771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x10) & 0xf; 1027771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x11) & 0xf; 1028771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 10293a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10303a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10316a719e05SDave Airlie found = 1; 1032771fe6b9SJerome Glisse } else if (rev > 1) { 1033771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 1034771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; 1035771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 1036771fe6b9SJerome Glisse 1037771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xd) & 0xf; 1038771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf; 1039771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 1040771fe6b9SJerome Glisse 1041771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 1042771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; 1043771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 10443a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10453a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10466a719e05SDave Airlie found = 1; 1047771fe6b9SJerome Glisse } 1048d79766faSAlex Deucher tv_dac->tv_std = radeon_combios_get_tv_info(rdev); 10496a719e05SDave Airlie } 10506a719e05SDave Airlie if (!found) { 1051771fe6b9SJerome Glisse /* then check CRT table */ 1052771fe6b9SJerome Glisse dac_info = 1053771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 1054771fe6b9SJerome Glisse if (dac_info) { 1055771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 1056771fe6b9SJerome Glisse if (rev < 2) { 1057771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x3) & 0xf; 1058771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf; 1059771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 1060771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 1061771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1062771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10633a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10643a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10656a719e05SDave Airlie found = 1; 1066771fe6b9SJerome Glisse } else { 1067771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x4) & 0xf; 1068771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x5) & 0xf; 1069771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 1070771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 1071771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1072771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10733a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10743a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10756a719e05SDave Airlie found = 1; 1076771fe6b9SJerome Glisse } 10776fe7ac3fSAlex Deucher } else { 10786fe7ac3fSAlex Deucher DRM_INFO("No TV DAC info found in BIOS\n"); 1079771fe6b9SJerome Glisse } 1080771fe6b9SJerome Glisse } 1081771fe6b9SJerome Glisse 10826a719e05SDave Airlie if (!found) /* fallback to defaults */ 10836a719e05SDave Airlie radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac); 10846a719e05SDave Airlie 1085771fe6b9SJerome Glisse return tv_dac; 1086771fe6b9SJerome Glisse } 1087771fe6b9SJerome Glisse 1088771fe6b9SJerome Glisse static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct 1089771fe6b9SJerome Glisse radeon_device 1090771fe6b9SJerome Glisse *rdev) 1091771fe6b9SJerome Glisse { 1092771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 1093771fe6b9SJerome Glisse uint32_t fp_vert_stretch, fp_horz_stretch; 1094771fe6b9SJerome Glisse uint32_t ppll_div_sel, ppll_val; 10958b5c7444SMichel Dänzer uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL); 1096771fe6b9SJerome Glisse 1097771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 1098771fe6b9SJerome Glisse 1099771fe6b9SJerome Glisse if (!lvds) 1100771fe6b9SJerome Glisse return NULL; 1101771fe6b9SJerome Glisse 1102771fe6b9SJerome Glisse fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH); 1103771fe6b9SJerome Glisse fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH); 1104771fe6b9SJerome Glisse 11058b5c7444SMichel Dänzer /* These should be fail-safe defaults, fingers crossed */ 11068b5c7444SMichel Dänzer lvds->panel_pwr_delay = 200; 11078b5c7444SMichel Dänzer lvds->panel_vcc_delay = 2000; 11088b5c7444SMichel Dänzer 11098b5c7444SMichel Dänzer lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL); 11108b5c7444SMichel Dänzer lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf; 11118b5c7444SMichel Dänzer lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf; 11128b5c7444SMichel Dänzer 1113771fe6b9SJerome Glisse if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE) 1114de2103e4SAlex Deucher lvds->native_mode.vdisplay = 1115771fe6b9SJerome Glisse ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >> 1116771fe6b9SJerome Glisse RADEON_VERT_PANEL_SHIFT) + 1; 1117771fe6b9SJerome Glisse else 1118de2103e4SAlex Deucher lvds->native_mode.vdisplay = 1119771fe6b9SJerome Glisse (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1; 1120771fe6b9SJerome Glisse 1121771fe6b9SJerome Glisse if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE) 1122de2103e4SAlex Deucher lvds->native_mode.hdisplay = 1123771fe6b9SJerome Glisse (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >> 1124771fe6b9SJerome Glisse RADEON_HORZ_PANEL_SHIFT) + 1) * 8; 1125771fe6b9SJerome Glisse else 1126de2103e4SAlex Deucher lvds->native_mode.hdisplay = 1127771fe6b9SJerome Glisse ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8; 1128771fe6b9SJerome Glisse 1129de2103e4SAlex Deucher if ((lvds->native_mode.hdisplay < 640) || 1130de2103e4SAlex Deucher (lvds->native_mode.vdisplay < 480)) { 1131de2103e4SAlex Deucher lvds->native_mode.hdisplay = 640; 1132de2103e4SAlex Deucher lvds->native_mode.vdisplay = 480; 1133771fe6b9SJerome Glisse } 1134771fe6b9SJerome Glisse 1135771fe6b9SJerome Glisse ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3; 1136771fe6b9SJerome Glisse ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel); 1137771fe6b9SJerome Glisse if ((ppll_val & 0x000707ff) == 0x1bb) 1138771fe6b9SJerome Glisse lvds->use_bios_dividers = false; 1139771fe6b9SJerome Glisse else { 1140771fe6b9SJerome Glisse lvds->panel_ref_divider = 1141771fe6b9SJerome Glisse RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff; 1142771fe6b9SJerome Glisse lvds->panel_post_divider = (ppll_val >> 16) & 0x7; 1143771fe6b9SJerome Glisse lvds->panel_fb_divider = ppll_val & 0x7ff; 1144771fe6b9SJerome Glisse 1145771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1146771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1147771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1148771fe6b9SJerome Glisse } 1149771fe6b9SJerome Glisse lvds->panel_vcc_delay = 200; 1150771fe6b9SJerome Glisse 1151771fe6b9SJerome Glisse DRM_INFO("Panel info derived from registers\n"); 1152de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1153de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1154771fe6b9SJerome Glisse 1155771fe6b9SJerome Glisse return lvds; 1156771fe6b9SJerome Glisse } 1157771fe6b9SJerome Glisse 1158771fe6b9SJerome Glisse struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder 1159771fe6b9SJerome Glisse *encoder) 1160771fe6b9SJerome Glisse { 1161771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1162771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1163771fe6b9SJerome Glisse uint16_t lcd_info; 1164771fe6b9SJerome Glisse uint32_t panel_setup; 1165771fe6b9SJerome Glisse char stmp[30]; 1166771fe6b9SJerome Glisse int tmp, i; 1167771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 1168771fe6b9SJerome Glisse 1169771fe6b9SJerome Glisse lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 1170771fe6b9SJerome Glisse 1171771fe6b9SJerome Glisse if (lcd_info) { 1172771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 1173771fe6b9SJerome Glisse 1174771fe6b9SJerome Glisse if (!lvds) 1175771fe6b9SJerome Glisse return NULL; 1176771fe6b9SJerome Glisse 1177771fe6b9SJerome Glisse for (i = 0; i < 24; i++) 1178771fe6b9SJerome Glisse stmp[i] = RBIOS8(lcd_info + i + 1); 1179771fe6b9SJerome Glisse stmp[24] = 0; 1180771fe6b9SJerome Glisse 1181771fe6b9SJerome Glisse DRM_INFO("Panel ID String: %s\n", stmp); 1182771fe6b9SJerome Glisse 1183de2103e4SAlex Deucher lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19); 1184de2103e4SAlex Deucher lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b); 1185771fe6b9SJerome Glisse 1186de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1187de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1188771fe6b9SJerome Glisse 1189771fe6b9SJerome Glisse lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c); 119094cf6434SAndrew Morton lvds->panel_vcc_delay = min_t(u16, lvds->panel_vcc_delay, 2000); 1191771fe6b9SJerome Glisse 1192771fe6b9SJerome Glisse lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24); 1193771fe6b9SJerome Glisse lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf; 1194771fe6b9SJerome Glisse lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf; 1195771fe6b9SJerome Glisse 1196771fe6b9SJerome Glisse lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e); 1197771fe6b9SJerome Glisse lvds->panel_post_divider = RBIOS8(lcd_info + 0x30); 1198771fe6b9SJerome Glisse lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31); 1199771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1200771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1201771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1202771fe6b9SJerome Glisse 1203771fe6b9SJerome Glisse panel_setup = RBIOS32(lcd_info + 0x39); 1204771fe6b9SJerome Glisse lvds->lvds_gen_cntl = 0xff00; 1205771fe6b9SJerome Glisse if (panel_setup & 0x1) 1206771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT; 1207771fe6b9SJerome Glisse 1208771fe6b9SJerome Glisse if ((panel_setup >> 4) & 0x1) 1209771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE; 1210771fe6b9SJerome Glisse 1211771fe6b9SJerome Glisse switch ((panel_setup >> 8) & 0x7) { 1212771fe6b9SJerome Glisse case 0: 1213771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM; 1214771fe6b9SJerome Glisse break; 1215771fe6b9SJerome Glisse case 1: 1216771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY; 1217771fe6b9SJerome Glisse break; 1218771fe6b9SJerome Glisse case 2: 1219771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY; 1220771fe6b9SJerome Glisse break; 1221771fe6b9SJerome Glisse default: 1222771fe6b9SJerome Glisse break; 1223771fe6b9SJerome Glisse } 1224771fe6b9SJerome Glisse 1225771fe6b9SJerome Glisse if ((panel_setup >> 16) & 0x1) 1226771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW; 1227771fe6b9SJerome Glisse 1228771fe6b9SJerome Glisse if ((panel_setup >> 17) & 0x1) 1229771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW; 1230771fe6b9SJerome Glisse 1231771fe6b9SJerome Glisse if ((panel_setup >> 18) & 0x1) 1232771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW; 1233771fe6b9SJerome Glisse 1234771fe6b9SJerome Glisse if ((panel_setup >> 23) & 0x1) 1235771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL; 1236771fe6b9SJerome Glisse 1237771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000); 1238771fe6b9SJerome Glisse 1239771fe6b9SJerome Glisse for (i = 0; i < 32; i++) { 1240771fe6b9SJerome Glisse tmp = RBIOS16(lcd_info + 64 + i * 2); 1241771fe6b9SJerome Glisse if (tmp == 0) 1242771fe6b9SJerome Glisse break; 1243771fe6b9SJerome Glisse 1244de2103e4SAlex Deucher if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) && 124568b61a7fSAlex Deucher (RBIOS16(tmp + 2) == lvds->native_mode.vdisplay)) { 124668b61a7fSAlex Deucher lvds->native_mode.htotal = lvds->native_mode.hdisplay + 124768b61a7fSAlex Deucher (RBIOS16(tmp + 17) - RBIOS16(tmp + 19)) * 8; 124868b61a7fSAlex Deucher lvds->native_mode.hsync_start = lvds->native_mode.hdisplay + 124968b61a7fSAlex Deucher (RBIOS16(tmp + 21) - RBIOS16(tmp + 19) - 1) * 8; 125068b61a7fSAlex Deucher lvds->native_mode.hsync_end = lvds->native_mode.hsync_start + 125168b61a7fSAlex Deucher (RBIOS8(tmp + 23) * 8); 1252771fe6b9SJerome Glisse 125368b61a7fSAlex Deucher lvds->native_mode.vtotal = lvds->native_mode.vdisplay + 125468b61a7fSAlex Deucher (RBIOS16(tmp + 24) - RBIOS16(tmp + 26)); 125568b61a7fSAlex Deucher lvds->native_mode.vsync_start = lvds->native_mode.vdisplay + 125668b61a7fSAlex Deucher ((RBIOS16(tmp + 28) & 0x7ff) - RBIOS16(tmp + 26)); 125768b61a7fSAlex Deucher lvds->native_mode.vsync_end = lvds->native_mode.vsync_start + 125868b61a7fSAlex Deucher ((RBIOS16(tmp + 28) & 0xf800) >> 11); 1259de2103e4SAlex Deucher 1260de2103e4SAlex Deucher lvds->native_mode.clock = RBIOS16(tmp + 9) * 10; 1261771fe6b9SJerome Glisse lvds->native_mode.flags = 0; 1262de2103e4SAlex Deucher /* set crtc values */ 1263de2103e4SAlex Deucher drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V); 1264de2103e4SAlex Deucher 1265771fe6b9SJerome Glisse } 1266771fe6b9SJerome Glisse } 12676fe7ac3fSAlex Deucher } else { 1268771fe6b9SJerome Glisse DRM_INFO("No panel info found in BIOS\n"); 12698dfaa8a7SMichel Dänzer lvds = radeon_legacy_get_lvds_info_from_regs(rdev); 12706fe7ac3fSAlex Deucher } 127103047cdfSMichel Dänzer 12728dfaa8a7SMichel Dänzer if (lvds) 12738dfaa8a7SMichel Dänzer encoder->native_mode = lvds->native_mode; 1274771fe6b9SJerome Glisse return lvds; 1275771fe6b9SJerome Glisse } 1276771fe6b9SJerome Glisse 1277771fe6b9SJerome Glisse static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = { 1278771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */ 1279771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */ 1280771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */ 1281771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */ 1282771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */ 1283771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */ 1284771fe6b9SJerome Glisse {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */ 1285771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */ 1286771fe6b9SJerome Glisse {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */ 1287771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */ 1288771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */ 1289771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */ 1290771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */ 1291771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */ 1292771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */ 1293771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */ 1294fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */ 1295fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */ 1296771fe6b9SJerome Glisse }; 1297771fe6b9SJerome Glisse 1298445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder, 1299445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1300771fe6b9SJerome Glisse { 1301445282dbSDave Airlie struct drm_device *dev = encoder->base.dev; 1302445282dbSDave Airlie struct radeon_device *rdev = dev->dev_private; 1303771fe6b9SJerome Glisse int i; 1304771fe6b9SJerome Glisse 1305771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 1306771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1307771fe6b9SJerome Glisse default_tmds_pll[rdev->family][i].value; 1308771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq; 1309771fe6b9SJerome Glisse } 1310771fe6b9SJerome Glisse 1311445282dbSDave Airlie return true; 1312771fe6b9SJerome Glisse } 1313771fe6b9SJerome Glisse 1314445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder, 1315445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1316771fe6b9SJerome Glisse { 1317771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1318771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1319771fe6b9SJerome Glisse uint16_t tmds_info; 1320771fe6b9SJerome Glisse int i, n; 1321771fe6b9SJerome Glisse uint8_t ver; 1322771fe6b9SJerome Glisse 1323771fe6b9SJerome Glisse tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 1324771fe6b9SJerome Glisse 1325771fe6b9SJerome Glisse if (tmds_info) { 1326771fe6b9SJerome Glisse ver = RBIOS8(tmds_info); 1327*40f76d81SAlex Deucher DRM_DEBUG_KMS("DFP table revision: %d\n", ver); 1328771fe6b9SJerome Glisse if (ver == 3) { 1329771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1330771fe6b9SJerome Glisse if (n > 4) 1331771fe6b9SJerome Glisse n = 4; 1332771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1333771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1334771fe6b9SJerome Glisse RBIOS32(tmds_info + i * 10 + 0x08); 1335771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1336771fe6b9SJerome Glisse RBIOS16(tmds_info + i * 10 + 0x10); 1337d9fdaafbSDave Airlie DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", 1338771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1339771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1340771fe6b9SJerome Glisse } 1341771fe6b9SJerome Glisse } else if (ver == 4) { 1342771fe6b9SJerome Glisse int stride = 0; 1343771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1344771fe6b9SJerome Glisse if (n > 4) 1345771fe6b9SJerome Glisse n = 4; 1346771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1347771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1348771fe6b9SJerome Glisse RBIOS32(tmds_info + stride + 0x08); 1349771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1350771fe6b9SJerome Glisse RBIOS16(tmds_info + stride + 0x10); 1351771fe6b9SJerome Glisse if (i == 0) 1352771fe6b9SJerome Glisse stride += 10; 1353771fe6b9SJerome Glisse else 1354771fe6b9SJerome Glisse stride += 6; 1355d9fdaafbSDave Airlie DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", 1356771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1357771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1358771fe6b9SJerome Glisse } 1359771fe6b9SJerome Glisse } 1360fcec570bSAlex Deucher } else { 1361771fe6b9SJerome Glisse DRM_INFO("No TMDS info found in BIOS\n"); 1362fcec570bSAlex Deucher return false; 1363fcec570bSAlex Deucher } 1364445282dbSDave Airlie return true; 1365445282dbSDave Airlie } 1366445282dbSDave Airlie 1367fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder, 1368fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1369771fe6b9SJerome Glisse { 1370771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1371771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1372fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1373fcec570bSAlex Deucher 1374fcec570bSAlex Deucher /* default for macs */ 1375179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1376f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1377fcec570bSAlex Deucher 1378fcec570bSAlex Deucher /* XXX some macs have duallink chips */ 1379fcec570bSAlex Deucher switch (rdev->mode_info.connector_table) { 1380fcec570bSAlex Deucher case CT_POWERBOOK_EXTERNAL: 1381fcec570bSAlex Deucher case CT_MINI_EXTERNAL: 1382fcec570bSAlex Deucher default: 1383fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1384fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1385fcec570bSAlex Deucher break; 1386fcec570bSAlex Deucher } 1387fcec570bSAlex Deucher 1388fcec570bSAlex Deucher return true; 1389fcec570bSAlex Deucher } 1390fcec570bSAlex Deucher 1391fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder, 1392fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1393fcec570bSAlex Deucher { 1394fcec570bSAlex Deucher struct drm_device *dev = encoder->base.dev; 1395fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 1396fcec570bSAlex Deucher uint16_t offset; 1397179e8078SAlex Deucher uint8_t ver; 1398fcec570bSAlex Deucher enum radeon_combios_ddc gpio; 1399fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1400771fe6b9SJerome Glisse 1401fcec570bSAlex Deucher tmds->i2c_bus = NULL; 1402fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 1403179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1404f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1405fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1406fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1407fcec570bSAlex Deucher } else { 1408fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 1409fcec570bSAlex Deucher if (offset) { 1410fcec570bSAlex Deucher ver = RBIOS8(offset); 1411*40f76d81SAlex Deucher DRM_DEBUG_KMS("External TMDS Table revision: %d\n", ver); 1412fcec570bSAlex Deucher tmds->slave_addr = RBIOS8(offset + 4 + 2); 1413fcec570bSAlex Deucher tmds->slave_addr >>= 1; /* 7 bit addressing */ 1414fcec570bSAlex Deucher gpio = RBIOS8(offset + 4 + 3); 1415179e8078SAlex Deucher if (gpio == DDC_LCD) { 1416179e8078SAlex Deucher /* MM i2c */ 141740bacf16SAlex Deucher i2c_bus.valid = true; 141840bacf16SAlex Deucher i2c_bus.hw_capable = true; 141940bacf16SAlex Deucher i2c_bus.mm_i2c = true; 1420179e8078SAlex Deucher i2c_bus.i2c_id = 0xa0; 1421179e8078SAlex Deucher } else 1422179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0); 1423f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1424fcec570bSAlex Deucher } 1425fcec570bSAlex Deucher } 1426fcec570bSAlex Deucher 1427fcec570bSAlex Deucher if (!tmds->i2c_bus) { 1428fcec570bSAlex Deucher DRM_INFO("No valid Ext TMDS info found in BIOS\n"); 1429fcec570bSAlex Deucher return false; 1430fcec570bSAlex Deucher } 1431fcec570bSAlex Deucher 1432fcec570bSAlex Deucher return true; 1433fcec570bSAlex Deucher } 1434771fe6b9SJerome Glisse 1435771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) 1436771fe6b9SJerome Glisse { 1437771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1438771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 1439eed45b30SAlex Deucher struct radeon_hpd hpd; 1440771fe6b9SJerome Glisse 1441771fe6b9SJerome Glisse rdev->mode_info.connector_table = radeon_connector_table; 1442771fe6b9SJerome Glisse if (rdev->mode_info.connector_table == CT_NONE) { 1443771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 144471a157e8SGrant Likely if (of_machine_is_compatible("PowerBook3,3")) { 1445771fe6b9SJerome Glisse /* powerbook with VGA */ 1446771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_VGA; 144771a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook3,4") || 144871a157e8SGrant Likely of_machine_is_compatible("PowerBook3,5")) { 1449771fe6b9SJerome Glisse /* powerbook with internal tmds */ 1450771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; 145171a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,1") || 145271a157e8SGrant Likely of_machine_is_compatible("PowerBook5,2") || 145371a157e8SGrant Likely of_machine_is_compatible("PowerBook5,3") || 145471a157e8SGrant Likely of_machine_is_compatible("PowerBook5,4") || 145571a157e8SGrant Likely of_machine_is_compatible("PowerBook5,5")) { 1456771fe6b9SJerome Glisse /* powerbook with external single link tmds (sil164) */ 1457771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 145871a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,6")) { 1459771fe6b9SJerome Glisse /* powerbook with external dual or single link tmds */ 1460771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 146171a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,7") || 146271a157e8SGrant Likely of_machine_is_compatible("PowerBook5,8") || 146371a157e8SGrant Likely of_machine_is_compatible("PowerBook5,9")) { 1464771fe6b9SJerome Glisse /* PowerBook6,2 ? */ 1465771fe6b9SJerome Glisse /* powerbook with external dual link tmds (sil1178?) */ 1466771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 146771a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook4,1") || 146871a157e8SGrant Likely of_machine_is_compatible("PowerBook4,2") || 146971a157e8SGrant Likely of_machine_is_compatible("PowerBook4,3") || 147071a157e8SGrant Likely of_machine_is_compatible("PowerBook6,3") || 147171a157e8SGrant Likely of_machine_is_compatible("PowerBook6,5") || 147271a157e8SGrant Likely of_machine_is_compatible("PowerBook6,7")) { 1473771fe6b9SJerome Glisse /* ibook */ 1474771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IBOOK; 147571a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac4,4")) { 1476771fe6b9SJerome Glisse /* emac */ 1477771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_EMAC; 147871a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac10,1")) { 1479771fe6b9SJerome Glisse /* mini with internal tmds */ 1480771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_INTERNAL; 148171a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac10,2")) { 1482771fe6b9SJerome Glisse /* mini with external tmds */ 1483771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_EXTERNAL; 148471a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac12,1")) { 1485771fe6b9SJerome Glisse /* PowerMac8,1 ? */ 1486771fe6b9SJerome Glisse /* imac g5 isight */ 1487771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; 1488aa74fbb4SAlex Deucher } else if ((rdev->pdev->device == 0x4a48) && 1489aa74fbb4SAlex Deucher (rdev->pdev->subsystem_vendor == 0x1002) && 1490aa74fbb4SAlex Deucher (rdev->pdev->subsystem_device == 0x4a48)) { 1491aa74fbb4SAlex Deucher /* Mac X800 */ 1492aa74fbb4SAlex Deucher rdev->mode_info.connector_table = CT_MAC_X800; 1493771fe6b9SJerome Glisse } else 1494771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 149576a7142aSDave Airlie #ifdef CONFIG_PPC64 149676a7142aSDave Airlie if (ASIC_IS_RN50(rdev)) 149776a7142aSDave Airlie rdev->mode_info.connector_table = CT_RN50_POWER; 149876a7142aSDave Airlie else 149976a7142aSDave Airlie #endif 1500771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_GENERIC; 1501771fe6b9SJerome Glisse } 1502771fe6b9SJerome Glisse 1503771fe6b9SJerome Glisse switch (rdev->mode_info.connector_table) { 1504771fe6b9SJerome Glisse case CT_GENERIC: 1505771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (generic)\n", 1506771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1507771fe6b9SJerome Glisse /* these are the most common settings */ 1508771fe6b9SJerome Glisse if (rdev->flags & RADEON_SINGLE_CRTC) { 1509771fe6b9SJerome Glisse /* VGA - primary dac */ 1510179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1511eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1512771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15135137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1514771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1515771fe6b9SJerome Glisse 1), 1516771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1517771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1518771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1519771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1520b75fad06SAlex Deucher &ddc_i2c, 1521eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1522eed45b30SAlex Deucher &hpd); 1523771fe6b9SJerome Glisse } else if (rdev->flags & RADEON_IS_MOBILITY) { 1524771fe6b9SJerome Glisse /* LVDS */ 1525179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_NONE_DETECTED, 0, 0); 1526eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1527771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15285137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1529771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1530771fe6b9SJerome Glisse 0), 1531771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1532771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1533771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1534771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 1535b75fad06SAlex Deucher &ddc_i2c, 1536eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1537eed45b30SAlex Deucher &hpd); 1538771fe6b9SJerome Glisse 1539771fe6b9SJerome Glisse /* VGA - primary dac */ 1540179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1541eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1542771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15435137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1544771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1545771fe6b9SJerome Glisse 1), 1546771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1547771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1548771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1549771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1550b75fad06SAlex Deucher &ddc_i2c, 1551eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1552eed45b30SAlex Deucher &hpd); 1553771fe6b9SJerome Glisse } else { 1554771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1555179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1556eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 1557771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15585137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1559771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1560771fe6b9SJerome Glisse 0), 1561771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1562771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15635137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1564771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1565771fe6b9SJerome Glisse 2), 1566771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1567771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1568771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1569771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1570771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 1571b75fad06SAlex Deucher &ddc_i2c, 1572eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1573eed45b30SAlex Deucher &hpd); 1574771fe6b9SJerome Glisse 1575771fe6b9SJerome Glisse /* VGA - primary dac */ 1576179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1577eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1578771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15795137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1580771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1581771fe6b9SJerome Glisse 1), 1582771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1583771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1584771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1585771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1586b75fad06SAlex Deucher &ddc_i2c, 1587eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1588eed45b30SAlex Deucher &hpd); 1589771fe6b9SJerome Glisse } 1590771fe6b9SJerome Glisse 1591771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 1592771fe6b9SJerome Glisse /* TV - tv dac */ 1593eed45b30SAlex Deucher ddc_i2c.valid = false; 1594eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1595771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15965137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1597771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1598771fe6b9SJerome Glisse 2), 1599771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1600771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, 1601771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1602771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1603b75fad06SAlex Deucher &ddc_i2c, 1604eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1605eed45b30SAlex Deucher &hpd); 1606771fe6b9SJerome Glisse } 1607771fe6b9SJerome Glisse break; 1608771fe6b9SJerome Glisse case CT_IBOOK: 1609771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (ibook)\n", 1610771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1611771fe6b9SJerome Glisse /* LVDS */ 1612179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1613eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1614771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16155137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1616771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1617771fe6b9SJerome Glisse 0), 1618771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1619771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1620b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1621eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1622eed45b30SAlex Deucher &hpd); 1623771fe6b9SJerome Glisse /* VGA - TV DAC */ 1624179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 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_CRT2_SUPPORT, 1629771fe6b9SJerome Glisse 2), 1630771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1631771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1632b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1633eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1634eed45b30SAlex Deucher &hpd); 1635771fe6b9SJerome Glisse /* TV - TV DAC */ 1636eed45b30SAlex Deucher ddc_i2c.valid = false; 1637eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1638771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16395137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1640771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1641771fe6b9SJerome Glisse 2), 1642771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1643771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1644771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1645b75fad06SAlex Deucher &ddc_i2c, 1646eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1647eed45b30SAlex Deucher &hpd); 1648771fe6b9SJerome Glisse break; 1649771fe6b9SJerome Glisse case CT_POWERBOOK_EXTERNAL: 1650771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook external tmds)\n", 1651771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1652771fe6b9SJerome Glisse /* LVDS */ 1653179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1654eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1655771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16565137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1657771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1658771fe6b9SJerome Glisse 0), 1659771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1660771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1661b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1662eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1663eed45b30SAlex Deucher &hpd); 1664771fe6b9SJerome Glisse /* DVI-I - primary dac, ext tmds */ 1665179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1666eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1667771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16685137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1669771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1670771fe6b9SJerome Glisse 0), 1671771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1672771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16735137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1674771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1675771fe6b9SJerome Glisse 1), 1676771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1677b75fad06SAlex Deucher /* XXX some are SL */ 1678771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1679771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1680771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1681b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1682eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 1683eed45b30SAlex Deucher &hpd); 1684771fe6b9SJerome Glisse /* TV - TV DAC */ 1685eed45b30SAlex Deucher ddc_i2c.valid = false; 1686eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1687771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16885137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1689771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1690771fe6b9SJerome Glisse 2), 1691771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1692771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1693771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1694b75fad06SAlex Deucher &ddc_i2c, 1695eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1696eed45b30SAlex Deucher &hpd); 1697771fe6b9SJerome Glisse break; 1698771fe6b9SJerome Glisse case CT_POWERBOOK_INTERNAL: 1699771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook internal tmds)\n", 1700771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1701771fe6b9SJerome Glisse /* LVDS */ 1702179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1703eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1704771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17055137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1706771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1707771fe6b9SJerome Glisse 0), 1708771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1709771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1710b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1711eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1712eed45b30SAlex Deucher &hpd); 1713771fe6b9SJerome Glisse /* DVI-I - primary dac, int tmds */ 1714179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1715eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1716771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17175137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1718771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1719771fe6b9SJerome Glisse 0), 1720771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1721771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17225137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1723771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1724771fe6b9SJerome Glisse 1), 1725771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1726771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1727771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1728771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1729b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1730eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1731eed45b30SAlex Deucher &hpd); 1732771fe6b9SJerome Glisse /* TV - TV DAC */ 1733eed45b30SAlex Deucher ddc_i2c.valid = false; 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_TV1_SUPPORT, 1738771fe6b9SJerome Glisse 2), 1739771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1740771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1741771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1742b75fad06SAlex Deucher &ddc_i2c, 1743eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1744eed45b30SAlex Deucher &hpd); 1745771fe6b9SJerome Glisse break; 1746771fe6b9SJerome Glisse case CT_POWERBOOK_VGA: 1747771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook vga)\n", 1748771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1749771fe6b9SJerome Glisse /* LVDS */ 1750179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1751eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1752771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17535137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1754771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1755771fe6b9SJerome Glisse 0), 1756771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1757771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1758b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1759eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1760eed45b30SAlex Deucher &hpd); 1761771fe6b9SJerome Glisse /* VGA - primary dac */ 1762179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1763eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1764771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17655137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1766771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1767771fe6b9SJerome Glisse 1), 1768771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1769771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT, 1770b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1771eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1772eed45b30SAlex Deucher &hpd); 1773771fe6b9SJerome Glisse /* TV - TV DAC */ 1774eed45b30SAlex Deucher ddc_i2c.valid = false; 1775eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1776771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17775137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1778771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1779771fe6b9SJerome Glisse 2), 1780771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1781771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1782771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1783b75fad06SAlex Deucher &ddc_i2c, 1784eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1785eed45b30SAlex Deucher &hpd); 1786771fe6b9SJerome Glisse break; 1787771fe6b9SJerome Glisse case CT_MINI_EXTERNAL: 1788771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini external tmds)\n", 1789771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1790771fe6b9SJerome Glisse /* DVI-I - tv dac, ext tmds */ 1791179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1792eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1793771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17945137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1795771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1796771fe6b9SJerome Glisse 0), 1797771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1798771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17995137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1800771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1801771fe6b9SJerome Glisse 2), 1802771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1803b75fad06SAlex Deucher /* XXX are any DL? */ 1804771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1805771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1806771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1807b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1808eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1809eed45b30SAlex Deucher &hpd); 1810771fe6b9SJerome Glisse /* TV - TV DAC */ 1811eed45b30SAlex Deucher ddc_i2c.valid = false; 1812eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1813771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18145137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1815771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1816771fe6b9SJerome Glisse 2), 1817771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1818771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1819771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1820b75fad06SAlex Deucher &ddc_i2c, 1821eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1822eed45b30SAlex Deucher &hpd); 1823771fe6b9SJerome Glisse break; 1824771fe6b9SJerome Glisse case CT_MINI_INTERNAL: 1825771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini internal tmds)\n", 1826771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1827771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1828179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1829eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1830771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18315137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1832771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1833771fe6b9SJerome Glisse 0), 1834771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1835771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18365137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1837771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1838771fe6b9SJerome Glisse 2), 1839771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1840771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1841771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1842771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1843b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1844eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1845eed45b30SAlex Deucher &hpd); 1846771fe6b9SJerome Glisse /* TV - TV DAC */ 1847eed45b30SAlex Deucher ddc_i2c.valid = false; 1848eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1849771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18505137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1851771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1852771fe6b9SJerome Glisse 2), 1853771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1854771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1855771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1856b75fad06SAlex Deucher &ddc_i2c, 1857eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1858eed45b30SAlex Deucher &hpd); 1859771fe6b9SJerome Glisse break; 1860771fe6b9SJerome Glisse case CT_IMAC_G5_ISIGHT: 1861771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (imac g5 isight)\n", 1862771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1863771fe6b9SJerome Glisse /* DVI-D - int tmds */ 1864179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1865eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1866771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18675137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1868771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1869771fe6b9SJerome Glisse 0), 1870771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1871771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT, 1872b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVID, &ddc_i2c, 1873eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 1874eed45b30SAlex Deucher &hpd); 1875771fe6b9SJerome Glisse /* VGA - tv dac */ 1876179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1877eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1878771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18795137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1880771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1881771fe6b9SJerome Glisse 2), 1882771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1883771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1884b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1885eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1886eed45b30SAlex Deucher &hpd); 1887771fe6b9SJerome Glisse /* TV - TV DAC */ 1888eed45b30SAlex Deucher ddc_i2c.valid = false; 1889eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1890771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18915137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1892771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1893771fe6b9SJerome Glisse 2), 1894771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1895771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1896771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1897b75fad06SAlex Deucher &ddc_i2c, 1898eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1899eed45b30SAlex Deucher &hpd); 1900771fe6b9SJerome Glisse break; 1901771fe6b9SJerome Glisse case CT_EMAC: 1902771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (emac)\n", 1903771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1904771fe6b9SJerome Glisse /* VGA - primary dac */ 1905179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1906eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1907771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19085137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1909771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1910771fe6b9SJerome Glisse 1), 1911771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1912771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 1913b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1914eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1915eed45b30SAlex Deucher &hpd); 1916771fe6b9SJerome Glisse /* VGA - tv dac */ 1917179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1918eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1919771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19205137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1921771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1922771fe6b9SJerome Glisse 2), 1923771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1924771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1925b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1926eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1927eed45b30SAlex Deucher &hpd); 1928771fe6b9SJerome Glisse /* TV - TV DAC */ 1929eed45b30SAlex Deucher ddc_i2c.valid = false; 1930eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1931771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19325137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1933771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1934771fe6b9SJerome Glisse 2), 1935771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1936771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1937771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1938b75fad06SAlex Deucher &ddc_i2c, 1939eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1940eed45b30SAlex Deucher &hpd); 1941771fe6b9SJerome Glisse break; 194276a7142aSDave Airlie case CT_RN50_POWER: 194376a7142aSDave Airlie DRM_INFO("Connector Table: %d (rn50-power)\n", 194476a7142aSDave Airlie rdev->mode_info.connector_table); 194576a7142aSDave Airlie /* VGA - primary dac */ 1946179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 194776a7142aSDave Airlie hpd.hpd = RADEON_HPD_NONE; 194876a7142aSDave Airlie radeon_add_legacy_encoder(dev, 19495137ee94SAlex Deucher radeon_get_encoder_enum(dev, 195076a7142aSDave Airlie ATOM_DEVICE_CRT1_SUPPORT, 195176a7142aSDave Airlie 1), 195276a7142aSDave Airlie ATOM_DEVICE_CRT1_SUPPORT); 195376a7142aSDave Airlie radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 195476a7142aSDave Airlie DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 195576a7142aSDave Airlie CONNECTOR_OBJECT_ID_VGA, 195676a7142aSDave Airlie &hpd); 1957179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 195876a7142aSDave Airlie hpd.hpd = RADEON_HPD_NONE; 195976a7142aSDave Airlie radeon_add_legacy_encoder(dev, 19605137ee94SAlex Deucher radeon_get_encoder_enum(dev, 196176a7142aSDave Airlie ATOM_DEVICE_CRT2_SUPPORT, 196276a7142aSDave Airlie 2), 196376a7142aSDave Airlie ATOM_DEVICE_CRT2_SUPPORT); 196476a7142aSDave Airlie radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 196576a7142aSDave Airlie DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 196676a7142aSDave Airlie CONNECTOR_OBJECT_ID_VGA, 196776a7142aSDave Airlie &hpd); 196876a7142aSDave Airlie break; 1969aa74fbb4SAlex Deucher case CT_MAC_X800: 1970aa74fbb4SAlex Deucher DRM_INFO("Connector Table: %d (mac x800)\n", 1971aa74fbb4SAlex Deucher rdev->mode_info.connector_table); 1972aa74fbb4SAlex Deucher /* DVI - primary dac, internal tmds */ 1973aa74fbb4SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1974aa74fbb4SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1975aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 1976aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 1977aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 1978aa74fbb4SAlex Deucher 0), 1979aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 1980aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 1981aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 1982aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 1983aa74fbb4SAlex Deucher 1), 1984aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 1985aa74fbb4SAlex Deucher radeon_add_legacy_connector(dev, 0, 1986aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 1987aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 1988aa74fbb4SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1989aa74fbb4SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1990aa74fbb4SAlex Deucher &hpd); 1991aa74fbb4SAlex Deucher /* DVI - tv dac, dvo */ 1992aa74fbb4SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1993aa74fbb4SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1994aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 1995aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 1996aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT, 1997aa74fbb4SAlex Deucher 0), 1998aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT); 1999aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2000aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2001aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2002aa74fbb4SAlex Deucher 2), 2003aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 2004aa74fbb4SAlex Deucher radeon_add_legacy_connector(dev, 1, 2005aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT | 2006aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2007aa74fbb4SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 2008aa74fbb4SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 2009aa74fbb4SAlex Deucher &hpd); 2010aa74fbb4SAlex Deucher break; 2011771fe6b9SJerome Glisse default: 2012771fe6b9SJerome Glisse DRM_INFO("Connector table: %d (invalid)\n", 2013771fe6b9SJerome Glisse rdev->mode_info.connector_table); 2014771fe6b9SJerome Glisse return false; 2015771fe6b9SJerome Glisse } 2016771fe6b9SJerome Glisse 2017771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2018771fe6b9SJerome Glisse 2019771fe6b9SJerome Glisse return true; 2020771fe6b9SJerome Glisse } 2021771fe6b9SJerome Glisse 2022771fe6b9SJerome Glisse static bool radeon_apply_legacy_quirks(struct drm_device *dev, 2023771fe6b9SJerome Glisse int bios_index, 2024771fe6b9SJerome Glisse enum radeon_combios_connector 2025771fe6b9SJerome Glisse *legacy_connector, 2026eed45b30SAlex Deucher struct radeon_i2c_bus_rec *ddc_i2c, 2027eed45b30SAlex Deucher struct radeon_hpd *hpd) 2028771fe6b9SJerome Glisse { 2029fcec570bSAlex Deucher 2030771fe6b9SJerome Glisse /* Certain IBM chipset RN50s have a BIOS reporting two VGAs, 2031771fe6b9SJerome Glisse one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */ 2032771fe6b9SJerome Glisse if (dev->pdev->device == 0x515e && 2033771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x1014) { 2034771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_CRT_LEGACY && 2035771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 2036771fe6b9SJerome Glisse return false; 2037771fe6b9SJerome Glisse } 2038771fe6b9SJerome Glisse 2039771fe6b9SJerome Glisse /* X300 card with extra non-existent DVI port */ 2040771fe6b9SJerome Glisse if (dev->pdev->device == 0x5B60 && 2041771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x17af && 2042771fe6b9SJerome Glisse dev->pdev->subsystem_device == 0x201e && bios_index == 2) { 2043771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_DVI_I_LEGACY) 2044771fe6b9SJerome Glisse return false; 2045771fe6b9SJerome Glisse } 2046771fe6b9SJerome Glisse 2047771fe6b9SJerome Glisse return true; 2048771fe6b9SJerome Glisse } 2049771fe6b9SJerome Glisse 2050790cfb34SAlex Deucher static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev) 2051790cfb34SAlex Deucher { 2052790cfb34SAlex Deucher /* Acer 5102 has non-existent TV port */ 2053790cfb34SAlex Deucher if (dev->pdev->device == 0x5975 && 2054790cfb34SAlex Deucher dev->pdev->subsystem_vendor == 0x1025 && 2055790cfb34SAlex Deucher dev->pdev->subsystem_device == 0x009f) 2056790cfb34SAlex Deucher return false; 2057790cfb34SAlex Deucher 2058fc7f7119SAlex Deucher /* HP dc5750 has non-existent TV port */ 2059fc7f7119SAlex Deucher if (dev->pdev->device == 0x5974 && 2060fc7f7119SAlex Deucher dev->pdev->subsystem_vendor == 0x103c && 2061fc7f7119SAlex Deucher dev->pdev->subsystem_device == 0x280a) 2062fc7f7119SAlex Deucher return false; 2063fc7f7119SAlex Deucher 2064fd874ad0SAlex Deucher /* MSI S270 has non-existent TV port */ 2065fd874ad0SAlex Deucher if (dev->pdev->device == 0x5955 && 2066fd874ad0SAlex Deucher dev->pdev->subsystem_vendor == 0x1462 && 2067fd874ad0SAlex Deucher dev->pdev->subsystem_device == 0x0131) 2068fd874ad0SAlex Deucher return false; 2069fd874ad0SAlex Deucher 2070790cfb34SAlex Deucher return true; 2071790cfb34SAlex Deucher } 2072790cfb34SAlex Deucher 2073b75fad06SAlex Deucher static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d) 2074b75fad06SAlex Deucher { 2075b75fad06SAlex Deucher struct radeon_device *rdev = dev->dev_private; 2076b75fad06SAlex Deucher uint32_t ext_tmds_info; 2077b75fad06SAlex Deucher 2078b75fad06SAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2079b75fad06SAlex Deucher if (is_dvi_d) 2080b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 2081b75fad06SAlex Deucher else 2082b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2083b75fad06SAlex Deucher } 2084b75fad06SAlex Deucher ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2085b75fad06SAlex Deucher if (ext_tmds_info) { 2086b75fad06SAlex Deucher uint8_t rev = RBIOS8(ext_tmds_info); 2087b75fad06SAlex Deucher uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5); 2088b75fad06SAlex Deucher if (rev >= 3) { 2089b75fad06SAlex Deucher if (is_dvi_d) 2090b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 2091b75fad06SAlex Deucher else 2092b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 2093b75fad06SAlex Deucher } else { 2094b75fad06SAlex Deucher if (flags & 1) { 2095b75fad06SAlex Deucher if (is_dvi_d) 2096b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 2097b75fad06SAlex Deucher else 2098b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 2099b75fad06SAlex Deucher } 2100b75fad06SAlex Deucher } 2101b75fad06SAlex Deucher } 2102b75fad06SAlex Deucher if (is_dvi_d) 2103b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 2104b75fad06SAlex Deucher else 2105b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2106b75fad06SAlex Deucher } 2107b75fad06SAlex Deucher 2108771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) 2109771fe6b9SJerome Glisse { 2110771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2111771fe6b9SJerome Glisse uint32_t conn_info, entry, devices; 2112b75fad06SAlex Deucher uint16_t tmp, connector_object_id; 2113771fe6b9SJerome Glisse enum radeon_combios_ddc ddc_type; 2114771fe6b9SJerome Glisse enum radeon_combios_connector connector; 2115771fe6b9SJerome Glisse int i = 0; 2116771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 2117eed45b30SAlex Deucher struct radeon_hpd hpd; 2118771fe6b9SJerome Glisse 2119771fe6b9SJerome Glisse conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE); 2120771fe6b9SJerome Glisse if (conn_info) { 2121771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 2122771fe6b9SJerome Glisse entry = conn_info + 2 + i * 2; 2123771fe6b9SJerome Glisse 2124771fe6b9SJerome Glisse if (!RBIOS16(entry)) 2125771fe6b9SJerome Glisse break; 2126771fe6b9SJerome Glisse 2127771fe6b9SJerome Glisse tmp = RBIOS16(entry); 2128771fe6b9SJerome Glisse 2129771fe6b9SJerome Glisse connector = (tmp >> 12) & 0xf; 2130771fe6b9SJerome Glisse 2131771fe6b9SJerome Glisse ddc_type = (tmp >> 8) & 0xf; 2132179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, ddc_type, 0, 0); 2133771fe6b9SJerome Glisse 2134eed45b30SAlex Deucher switch (connector) { 2135eed45b30SAlex Deucher case CONNECTOR_PROPRIETARY_LEGACY: 2136eed45b30SAlex Deucher case CONNECTOR_DVI_I_LEGACY: 2137eed45b30SAlex Deucher case CONNECTOR_DVI_D_LEGACY: 2138eed45b30SAlex Deucher if ((tmp >> 4) & 0x1) 2139eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; 2140eed45b30SAlex Deucher else 2141eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 2142eed45b30SAlex Deucher break; 2143eed45b30SAlex Deucher default: 2144eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2145eed45b30SAlex Deucher break; 2146eed45b30SAlex Deucher } 2147eed45b30SAlex Deucher 21482d152c6bSAlex Deucher if (!radeon_apply_legacy_quirks(dev, i, &connector, 2149eed45b30SAlex Deucher &ddc_i2c, &hpd)) 21502d152c6bSAlex Deucher continue; 2151771fe6b9SJerome Glisse 2152771fe6b9SJerome Glisse switch (connector) { 2153771fe6b9SJerome Glisse case CONNECTOR_PROPRIETARY_LEGACY: 2154771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) 2155771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2156771fe6b9SJerome Glisse else 2157771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2158771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 21595137ee94SAlex Deucher radeon_get_encoder_enum 2160771fe6b9SJerome Glisse (dev, devices, 0), 2161771fe6b9SJerome Glisse devices); 2162771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2163771fe6b9SJerome Glisse legacy_connector_convert 2164771fe6b9SJerome Glisse [connector], 2165b75fad06SAlex Deucher &ddc_i2c, 2166eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 2167eed45b30SAlex Deucher &hpd); 2168771fe6b9SJerome Glisse break; 2169771fe6b9SJerome Glisse case CONNECTOR_CRT_LEGACY: 2170771fe6b9SJerome Glisse if (tmp & 0x1) { 2171771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT2_SUPPORT; 2172771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 21735137ee94SAlex Deucher radeon_get_encoder_enum 2174771fe6b9SJerome Glisse (dev, 2175771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2176771fe6b9SJerome Glisse 2), 2177771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2178771fe6b9SJerome Glisse } else { 2179771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT1_SUPPORT; 2180771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 21815137ee94SAlex Deucher radeon_get_encoder_enum 2182771fe6b9SJerome Glisse (dev, 2183771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2184771fe6b9SJerome Glisse 1), 2185771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2186771fe6b9SJerome Glisse } 2187771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2188771fe6b9SJerome Glisse i, 2189771fe6b9SJerome Glisse devices, 2190771fe6b9SJerome Glisse legacy_connector_convert 2191771fe6b9SJerome Glisse [connector], 2192b75fad06SAlex Deucher &ddc_i2c, 2193eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2194eed45b30SAlex Deucher &hpd); 2195771fe6b9SJerome Glisse break; 2196771fe6b9SJerome Glisse case CONNECTOR_DVI_I_LEGACY: 2197771fe6b9SJerome Glisse devices = 0; 2198771fe6b9SJerome Glisse if (tmp & 0x1) { 2199771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT2_SUPPORT; 2200771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22015137ee94SAlex Deucher radeon_get_encoder_enum 2202771fe6b9SJerome Glisse (dev, 2203771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2204771fe6b9SJerome Glisse 2), 2205771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2206771fe6b9SJerome Glisse } else { 2207771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT1_SUPPORT; 2208771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22095137ee94SAlex Deucher radeon_get_encoder_enum 2210771fe6b9SJerome Glisse (dev, 2211771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2212771fe6b9SJerome Glisse 1), 2213771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2214771fe6b9SJerome Glisse } 2215771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) { 2216771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP2_SUPPORT; 2217771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22185137ee94SAlex Deucher radeon_get_encoder_enum 2219771fe6b9SJerome Glisse (dev, 2220771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 2221771fe6b9SJerome Glisse 0), 2222771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 2223b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 0); 2224771fe6b9SJerome Glisse } else { 2225771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP1_SUPPORT; 2226771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22275137ee94SAlex Deucher radeon_get_encoder_enum 2228771fe6b9SJerome Glisse (dev, 2229771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2230771fe6b9SJerome Glisse 0), 2231771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2232b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2233771fe6b9SJerome Glisse } 2234771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2235771fe6b9SJerome Glisse i, 2236771fe6b9SJerome Glisse devices, 2237771fe6b9SJerome Glisse legacy_connector_convert 2238771fe6b9SJerome Glisse [connector], 2239b75fad06SAlex Deucher &ddc_i2c, 2240eed45b30SAlex Deucher connector_object_id, 2241eed45b30SAlex Deucher &hpd); 2242771fe6b9SJerome Glisse break; 2243771fe6b9SJerome Glisse case CONNECTOR_DVI_D_LEGACY: 2244b75fad06SAlex Deucher if ((tmp >> 4) & 0x1) { 2245771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2246b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 1); 2247b75fad06SAlex Deucher } else { 2248771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2249b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2250b75fad06SAlex Deucher } 2251771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22525137ee94SAlex Deucher radeon_get_encoder_enum 2253771fe6b9SJerome Glisse (dev, devices, 0), 2254771fe6b9SJerome Glisse devices); 2255771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2256771fe6b9SJerome Glisse legacy_connector_convert 2257771fe6b9SJerome Glisse [connector], 2258b75fad06SAlex Deucher &ddc_i2c, 2259eed45b30SAlex Deucher connector_object_id, 2260eed45b30SAlex Deucher &hpd); 2261771fe6b9SJerome Glisse break; 2262771fe6b9SJerome Glisse case CONNECTOR_CTV_LEGACY: 2263771fe6b9SJerome Glisse case CONNECTOR_STV_LEGACY: 2264771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22655137ee94SAlex Deucher radeon_get_encoder_enum 2266771fe6b9SJerome Glisse (dev, 2267771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2268771fe6b9SJerome Glisse 2), 2269771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2270771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, 2271771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2272771fe6b9SJerome Glisse legacy_connector_convert 2273771fe6b9SJerome Glisse [connector], 2274b75fad06SAlex Deucher &ddc_i2c, 2275eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2276eed45b30SAlex Deucher &hpd); 2277771fe6b9SJerome Glisse break; 2278771fe6b9SJerome Glisse default: 2279771fe6b9SJerome Glisse DRM_ERROR("Unknown connector type: %d\n", 2280771fe6b9SJerome Glisse connector); 2281771fe6b9SJerome Glisse continue; 2282771fe6b9SJerome Glisse } 2283771fe6b9SJerome Glisse 2284771fe6b9SJerome Glisse } 2285771fe6b9SJerome Glisse } else { 2286771fe6b9SJerome Glisse uint16_t tmds_info = 2287771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 2288771fe6b9SJerome Glisse if (tmds_info) { 2289d9fdaafbSDave Airlie DRM_DEBUG_KMS("Found DFP table, assuming DVI connector\n"); 2290771fe6b9SJerome Glisse 2291771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22925137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2293771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2294771fe6b9SJerome Glisse 1), 2295771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2296771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22975137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2298771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2299771fe6b9SJerome Glisse 0), 2300771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2301771fe6b9SJerome Glisse 2302179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 23038e36ed00SAlex Deucher hpd.hpd = RADEON_HPD_1; 2304771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2305771fe6b9SJerome Glisse 0, 2306771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT | 2307771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2308771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 2309b75fad06SAlex Deucher &ddc_i2c, 2310eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2311eed45b30SAlex Deucher &hpd); 2312771fe6b9SJerome Glisse } else { 2313d0c403e9SAlex Deucher uint16_t crt_info = 2314d0c403e9SAlex Deucher combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 2315d9fdaafbSDave Airlie DRM_DEBUG_KMS("Found CRT table, assuming VGA connector\n"); 2316d0c403e9SAlex Deucher if (crt_info) { 2317d0c403e9SAlex Deucher radeon_add_legacy_encoder(dev, 23185137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2319d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2320d0c403e9SAlex Deucher 1), 2321d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 2322179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 2323eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2324d0c403e9SAlex Deucher radeon_add_legacy_connector(dev, 2325d0c403e9SAlex Deucher 0, 2326d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2327d0c403e9SAlex Deucher DRM_MODE_CONNECTOR_VGA, 2328b75fad06SAlex Deucher &ddc_i2c, 2329eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2330eed45b30SAlex Deucher &hpd); 2331d0c403e9SAlex Deucher } else { 2332d9fdaafbSDave Airlie DRM_DEBUG_KMS("No connector info found\n"); 2333771fe6b9SJerome Glisse return false; 2334771fe6b9SJerome Glisse } 2335771fe6b9SJerome Glisse } 2336d0c403e9SAlex Deucher } 2337771fe6b9SJerome Glisse 2338771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) { 2339771fe6b9SJerome Glisse uint16_t lcd_info = 2340771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 2341771fe6b9SJerome Glisse if (lcd_info) { 2342771fe6b9SJerome Glisse uint16_t lcd_ddc_info = 2343771fe6b9SJerome Glisse combios_get_table_offset(dev, 2344771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE); 2345771fe6b9SJerome Glisse 2346771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23475137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2348771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2349771fe6b9SJerome Glisse 0), 2350771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 2351771fe6b9SJerome Glisse 2352771fe6b9SJerome Glisse if (lcd_ddc_info) { 2353771fe6b9SJerome Glisse ddc_type = RBIOS8(lcd_ddc_info + 2); 2354771fe6b9SJerome Glisse switch (ddc_type) { 2355771fe6b9SJerome Glisse case DDC_LCD: 2356771fe6b9SJerome Glisse ddc_i2c = 2357179e8078SAlex Deucher combios_setup_i2c_bus(rdev, 2358179e8078SAlex Deucher DDC_LCD, 2359179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 3), 2360179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 7)); 2361f376b94fSAlex Deucher radeon_i2c_add(rdev, &ddc_i2c, "LCD"); 2362771fe6b9SJerome Glisse break; 2363771fe6b9SJerome Glisse case DDC_GPIO: 2364771fe6b9SJerome Glisse ddc_i2c = 2365179e8078SAlex Deucher combios_setup_i2c_bus(rdev, 2366179e8078SAlex Deucher DDC_GPIO, 2367179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 3), 2368179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 7)); 2369f376b94fSAlex Deucher radeon_i2c_add(rdev, &ddc_i2c, "LCD"); 2370771fe6b9SJerome Glisse break; 2371771fe6b9SJerome Glisse default: 2372179e8078SAlex Deucher ddc_i2c = 2373179e8078SAlex Deucher combios_setup_i2c_bus(rdev, ddc_type, 0, 0); 2374771fe6b9SJerome Glisse break; 2375771fe6b9SJerome Glisse } 2376d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD DDC Info Table found!\n"); 2377771fe6b9SJerome Glisse } else 2378771fe6b9SJerome Glisse ddc_i2c.valid = false; 2379771fe6b9SJerome Glisse 2380eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2381771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2382771fe6b9SJerome Glisse 5, 2383771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2384771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 2385b75fad06SAlex Deucher &ddc_i2c, 2386eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 2387eed45b30SAlex Deucher &hpd); 2388771fe6b9SJerome Glisse } 2389771fe6b9SJerome Glisse } 2390771fe6b9SJerome Glisse 2391771fe6b9SJerome Glisse /* check TV table */ 2392771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 2393771fe6b9SJerome Glisse uint32_t tv_info = 2394771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 2395771fe6b9SJerome Glisse if (tv_info) { 2396771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 2397790cfb34SAlex Deucher if (radeon_apply_legacy_tv_quirks(dev)) { 2398eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2399d294ed69SDave Airlie ddc_i2c.valid = false; 2400771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24015137ee94SAlex Deucher radeon_get_encoder_enum 2402771fe6b9SJerome Glisse (dev, 2403771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2404771fe6b9SJerome Glisse 2), 2405771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2406771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 6, 2407771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2408771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 2409b75fad06SAlex Deucher &ddc_i2c, 2410eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2411eed45b30SAlex Deucher &hpd); 2412771fe6b9SJerome Glisse } 2413771fe6b9SJerome Glisse } 2414771fe6b9SJerome Glisse } 2415790cfb34SAlex Deucher } 2416771fe6b9SJerome Glisse 2417771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2418771fe6b9SJerome Glisse 2419771fe6b9SJerome Glisse return true; 2420771fe6b9SJerome Glisse } 2421771fe6b9SJerome Glisse 242256278a8eSAlex Deucher void radeon_combios_get_power_modes(struct radeon_device *rdev) 242356278a8eSAlex Deucher { 242456278a8eSAlex Deucher struct drm_device *dev = rdev->ddev; 242556278a8eSAlex Deucher u16 offset, misc, misc2 = 0; 242656278a8eSAlex Deucher u8 rev, blocks, tmp; 242756278a8eSAlex Deucher int state_index = 0; 242856278a8eSAlex Deucher 2429a48b9b4eSAlex Deucher rdev->pm.default_power_state_index = -1; 243056278a8eSAlex Deucher 243156278a8eSAlex Deucher if (rdev->flags & RADEON_IS_MOBILITY) { 243256278a8eSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE); 243356278a8eSAlex Deucher if (offset) { 243456278a8eSAlex Deucher rev = RBIOS8(offset); 243556278a8eSAlex Deucher blocks = RBIOS8(offset + 0x2); 243656278a8eSAlex Deucher /* power mode 0 tends to be the only valid one */ 243756278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 243856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = RBIOS32(offset + 0x5 + 0x2); 243956278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = RBIOS32(offset + 0x5 + 0x6); 244056278a8eSAlex Deucher if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) || 244156278a8eSAlex Deucher (rdev->pm.power_state[state_index].clock_info[0].sclk == 0)) 244256278a8eSAlex Deucher goto default_mode; 24430ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 24440ec0e74fSAlex Deucher POWER_STATE_TYPE_BATTERY; 244556278a8eSAlex Deucher misc = RBIOS16(offset + 0x5 + 0x0); 244656278a8eSAlex Deucher if (rev > 4) 244756278a8eSAlex Deucher misc2 = RBIOS16(offset + 0x5 + 0xe); 244879daedc9SAlex Deucher rdev->pm.power_state[state_index].misc = misc; 244979daedc9SAlex Deucher rdev->pm.power_state[state_index].misc2 = misc2; 245056278a8eSAlex Deucher if (misc & 0x4) { 245156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_GPIO; 245256278a8eSAlex Deucher if (misc & 0x8) 245356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 245456278a8eSAlex Deucher true; 245556278a8eSAlex Deucher else 245656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 245756278a8eSAlex Deucher false; 245856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = true; 245956278a8eSAlex Deucher if (rev < 6) { 246056278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 246156278a8eSAlex Deucher RBIOS16(offset + 0x5 + 0xb) * 4; 246256278a8eSAlex Deucher tmp = RBIOS8(offset + 0x5 + 0xd); 246356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 246456278a8eSAlex Deucher } else { 246556278a8eSAlex Deucher u8 entries = RBIOS8(offset + 0x5 + 0xb); 246656278a8eSAlex Deucher u16 voltage_table_offset = RBIOS16(offset + 0x5 + 0xc); 246756278a8eSAlex Deucher if (entries && voltage_table_offset) { 246856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 246956278a8eSAlex Deucher RBIOS16(voltage_table_offset) * 4; 247056278a8eSAlex Deucher tmp = RBIOS8(voltage_table_offset + 0x2); 247156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 247256278a8eSAlex Deucher } else 247356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = false; 247456278a8eSAlex Deucher } 247556278a8eSAlex Deucher switch ((misc2 & 0x700) >> 8) { 247656278a8eSAlex Deucher case 0: 247756278a8eSAlex Deucher default: 247856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 0; 247956278a8eSAlex Deucher break; 248056278a8eSAlex Deucher case 1: 248156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 33; 248256278a8eSAlex Deucher break; 248356278a8eSAlex Deucher case 2: 248456278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 66; 248556278a8eSAlex Deucher break; 248656278a8eSAlex Deucher case 3: 248756278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 99; 248856278a8eSAlex Deucher break; 248956278a8eSAlex Deucher case 4: 249056278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 132; 249156278a8eSAlex Deucher break; 249256278a8eSAlex Deucher } 249356278a8eSAlex Deucher } else 249456278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 249556278a8eSAlex Deucher if (rev > 6) 249679daedc9SAlex Deucher rdev->pm.power_state[state_index].pcie_lanes = 249756278a8eSAlex Deucher RBIOS8(offset + 0x5 + 0x10); 2498d7311171SAlex Deucher rdev->pm.power_state[state_index].flags = RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; 249956278a8eSAlex Deucher state_index++; 250056278a8eSAlex Deucher } else { 250156278a8eSAlex Deucher /* XXX figure out some good default low power mode for mobility cards w/out power tables */ 250256278a8eSAlex Deucher } 250356278a8eSAlex Deucher } else { 250456278a8eSAlex Deucher /* XXX figure out some good default low power mode for desktop cards */ 250556278a8eSAlex Deucher } 250656278a8eSAlex Deucher 250756278a8eSAlex Deucher default_mode: 250856278a8eSAlex Deucher /* add the default mode */ 25090ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 25100ec0e74fSAlex Deucher POWER_STATE_TYPE_DEFAULT; 251156278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 251256278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk; 251356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk; 251456278a8eSAlex Deucher rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0]; 251584d88f4cSAlex Deucher if ((state_index > 0) && 25168de016e2SAlex Deucher (rdev->pm.power_state[0].clock_info[0].voltage.type == VOLTAGE_GPIO)) 251784d88f4cSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage = 251884d88f4cSAlex Deucher rdev->pm.power_state[0].clock_info[0].voltage; 251984d88f4cSAlex Deucher else 252056278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 252179daedc9SAlex Deucher rdev->pm.power_state[state_index].pcie_lanes = 16; 2522a48b9b4eSAlex Deucher rdev->pm.power_state[state_index].flags = 0; 2523a48b9b4eSAlex Deucher rdev->pm.default_power_state_index = state_index; 252456278a8eSAlex Deucher rdev->pm.num_power_states = state_index + 1; 25259038dfdfSRafał Miłecki 2526a48b9b4eSAlex Deucher rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; 2527a48b9b4eSAlex Deucher rdev->pm.current_clock_mode_index = 0; 252856278a8eSAlex Deucher } 252956278a8eSAlex Deucher 2530fcec570bSAlex Deucher void radeon_external_tmds_setup(struct drm_encoder *encoder) 2531fcec570bSAlex Deucher { 2532fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2533fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2534fcec570bSAlex Deucher 2535fcec570bSAlex Deucher if (!tmds) 2536fcec570bSAlex Deucher return; 2537fcec570bSAlex Deucher 2538fcec570bSAlex Deucher switch (tmds->dvo_chip) { 2539fcec570bSAlex Deucher case DVO_SIL164: 2540fcec570bSAlex Deucher /* sil 164 */ 25415a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2542fcec570bSAlex Deucher tmds->slave_addr, 2543fcec570bSAlex Deucher 0x08, 0x30); 25445a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2545fcec570bSAlex Deucher tmds->slave_addr, 2546fcec570bSAlex Deucher 0x09, 0x00); 25475a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2548fcec570bSAlex Deucher tmds->slave_addr, 2549fcec570bSAlex Deucher 0x0a, 0x90); 25505a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2551fcec570bSAlex Deucher tmds->slave_addr, 2552fcec570bSAlex Deucher 0x0c, 0x89); 25535a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2554fcec570bSAlex Deucher tmds->slave_addr, 2555fcec570bSAlex Deucher 0x08, 0x3b); 2556fcec570bSAlex Deucher break; 2557fcec570bSAlex Deucher case DVO_SIL1178: 2558fcec570bSAlex Deucher /* sil 1178 - untested */ 2559fcec570bSAlex Deucher /* 2560fcec570bSAlex Deucher * 0x0f, 0x44 2561fcec570bSAlex Deucher * 0x0f, 0x4c 2562fcec570bSAlex Deucher * 0x0e, 0x01 2563fcec570bSAlex Deucher * 0x0a, 0x80 2564fcec570bSAlex Deucher * 0x09, 0x30 2565fcec570bSAlex Deucher * 0x0c, 0xc9 2566fcec570bSAlex Deucher * 0x0d, 0x70 2567fcec570bSAlex Deucher * 0x08, 0x32 2568fcec570bSAlex Deucher * 0x08, 0x33 2569fcec570bSAlex Deucher */ 2570fcec570bSAlex Deucher break; 2571fcec570bSAlex Deucher default: 2572fcec570bSAlex Deucher break; 2573fcec570bSAlex Deucher } 2574fcec570bSAlex Deucher 2575fcec570bSAlex Deucher } 2576fcec570bSAlex Deucher 2577fcec570bSAlex Deucher bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder) 2578fcec570bSAlex Deucher { 2579fcec570bSAlex Deucher struct drm_device *dev = encoder->dev; 2580fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 2581fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2582fcec570bSAlex Deucher uint16_t offset; 2583fcec570bSAlex Deucher uint8_t blocks, slave_addr, rev; 2584fcec570bSAlex Deucher uint32_t index, id; 2585fcec570bSAlex Deucher uint32_t reg, val, and_mask, or_mask; 2586fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2587fcec570bSAlex Deucher 2588fcec570bSAlex Deucher if (!tmds) 2589fcec570bSAlex Deucher return false; 2590fcec570bSAlex Deucher 2591fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2592fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE); 2593fcec570bSAlex Deucher rev = RBIOS8(offset); 2594fcec570bSAlex Deucher if (offset) { 2595fcec570bSAlex Deucher rev = RBIOS8(offset); 2596fcec570bSAlex Deucher if (rev > 1) { 2597fcec570bSAlex Deucher blocks = RBIOS8(offset + 3); 2598fcec570bSAlex Deucher index = offset + 4; 2599fcec570bSAlex Deucher while (blocks > 0) { 2600fcec570bSAlex Deucher id = RBIOS16(index); 2601fcec570bSAlex Deucher index += 2; 2602fcec570bSAlex Deucher switch (id >> 13) { 2603fcec570bSAlex Deucher case 0: 2604fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2605fcec570bSAlex Deucher val = RBIOS32(index); 2606fcec570bSAlex Deucher index += 4; 2607fcec570bSAlex Deucher WREG32(reg, val); 2608fcec570bSAlex Deucher break; 2609fcec570bSAlex Deucher case 2: 2610fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2611fcec570bSAlex Deucher and_mask = RBIOS32(index); 2612fcec570bSAlex Deucher index += 4; 2613fcec570bSAlex Deucher or_mask = RBIOS32(index); 2614fcec570bSAlex Deucher index += 4; 2615fcec570bSAlex Deucher val = RREG32(reg); 2616fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2617fcec570bSAlex Deucher WREG32(reg, val); 2618fcec570bSAlex Deucher break; 2619fcec570bSAlex Deucher case 3: 2620fcec570bSAlex Deucher val = RBIOS16(index); 2621fcec570bSAlex Deucher index += 2; 2622fcec570bSAlex Deucher udelay(val); 2623fcec570bSAlex Deucher break; 2624fcec570bSAlex Deucher case 4: 2625fcec570bSAlex Deucher val = RBIOS16(index); 2626fcec570bSAlex Deucher index += 2; 2627fcec570bSAlex Deucher udelay(val * 1000); 2628fcec570bSAlex Deucher break; 2629fcec570bSAlex Deucher case 6: 2630fcec570bSAlex Deucher slave_addr = id & 0xff; 2631fcec570bSAlex Deucher slave_addr >>= 1; /* 7 bit addressing */ 2632fcec570bSAlex Deucher index++; 2633fcec570bSAlex Deucher reg = RBIOS8(index); 2634fcec570bSAlex Deucher index++; 2635fcec570bSAlex Deucher val = RBIOS8(index); 2636fcec570bSAlex Deucher index++; 26375a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2638fcec570bSAlex Deucher slave_addr, 2639fcec570bSAlex Deucher reg, val); 2640fcec570bSAlex Deucher break; 2641fcec570bSAlex Deucher default: 2642fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2643fcec570bSAlex Deucher break; 2644fcec570bSAlex Deucher } 2645fcec570bSAlex Deucher blocks--; 2646fcec570bSAlex Deucher } 2647fcec570bSAlex Deucher return true; 2648fcec570bSAlex Deucher } 2649fcec570bSAlex Deucher } 2650fcec570bSAlex Deucher } else { 2651fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2652fcec570bSAlex Deucher if (offset) { 2653fcec570bSAlex Deucher index = offset + 10; 2654fcec570bSAlex Deucher id = RBIOS16(index); 2655fcec570bSAlex Deucher while (id != 0xffff) { 2656fcec570bSAlex Deucher index += 2; 2657fcec570bSAlex Deucher switch (id >> 13) { 2658fcec570bSAlex Deucher case 0: 2659fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2660fcec570bSAlex Deucher val = RBIOS32(index); 2661fcec570bSAlex Deucher WREG32(reg, val); 2662fcec570bSAlex Deucher break; 2663fcec570bSAlex Deucher case 2: 2664fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2665fcec570bSAlex Deucher and_mask = RBIOS32(index); 2666fcec570bSAlex Deucher index += 4; 2667fcec570bSAlex Deucher or_mask = RBIOS32(index); 2668fcec570bSAlex Deucher index += 4; 2669fcec570bSAlex Deucher val = RREG32(reg); 2670fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2671fcec570bSAlex Deucher WREG32(reg, val); 2672fcec570bSAlex Deucher break; 2673fcec570bSAlex Deucher case 4: 2674fcec570bSAlex Deucher val = RBIOS16(index); 2675fcec570bSAlex Deucher index += 2; 2676fcec570bSAlex Deucher udelay(val); 2677fcec570bSAlex Deucher break; 2678fcec570bSAlex Deucher case 5: 2679fcec570bSAlex Deucher reg = id & 0x1fff; 2680fcec570bSAlex Deucher and_mask = RBIOS32(index); 2681fcec570bSAlex Deucher index += 4; 2682fcec570bSAlex Deucher or_mask = RBIOS32(index); 2683fcec570bSAlex Deucher index += 4; 2684fcec570bSAlex Deucher val = RREG32_PLL(reg); 2685fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2686fcec570bSAlex Deucher WREG32_PLL(reg, val); 2687fcec570bSAlex Deucher break; 2688fcec570bSAlex Deucher case 6: 2689fcec570bSAlex Deucher reg = id & 0x1fff; 2690fcec570bSAlex Deucher val = RBIOS8(index); 2691fcec570bSAlex Deucher index += 1; 26925a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2693fcec570bSAlex Deucher tmds->slave_addr, 2694fcec570bSAlex Deucher reg, val); 2695fcec570bSAlex Deucher break; 2696fcec570bSAlex Deucher default: 2697fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2698fcec570bSAlex Deucher break; 2699fcec570bSAlex Deucher } 2700fcec570bSAlex Deucher id = RBIOS16(index); 2701fcec570bSAlex Deucher } 2702fcec570bSAlex Deucher return true; 2703fcec570bSAlex Deucher } 2704fcec570bSAlex Deucher } 2705fcec570bSAlex Deucher return false; 2706fcec570bSAlex Deucher } 2707fcec570bSAlex Deucher 2708771fe6b9SJerome Glisse static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset) 2709771fe6b9SJerome Glisse { 2710771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2711771fe6b9SJerome Glisse 2712771fe6b9SJerome Glisse if (offset) { 2713771fe6b9SJerome Glisse while (RBIOS16(offset)) { 2714771fe6b9SJerome Glisse uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13); 2715771fe6b9SJerome Glisse uint32_t addr = (RBIOS16(offset) & 0x1fff); 2716771fe6b9SJerome Glisse uint32_t val, and_mask, or_mask; 2717771fe6b9SJerome Glisse uint32_t tmp; 2718771fe6b9SJerome Glisse 2719771fe6b9SJerome Glisse offset += 2; 2720771fe6b9SJerome Glisse switch (cmd) { 2721771fe6b9SJerome Glisse case 0: 2722771fe6b9SJerome Glisse val = RBIOS32(offset); 2723771fe6b9SJerome Glisse offset += 4; 2724771fe6b9SJerome Glisse WREG32(addr, val); 2725771fe6b9SJerome Glisse break; 2726771fe6b9SJerome Glisse case 1: 2727771fe6b9SJerome Glisse val = RBIOS32(offset); 2728771fe6b9SJerome Glisse offset += 4; 2729771fe6b9SJerome Glisse WREG32(addr, val); 2730771fe6b9SJerome Glisse break; 2731771fe6b9SJerome Glisse case 2: 2732771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2733771fe6b9SJerome Glisse offset += 4; 2734771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2735771fe6b9SJerome Glisse offset += 4; 2736771fe6b9SJerome Glisse tmp = RREG32(addr); 2737771fe6b9SJerome Glisse tmp &= and_mask; 2738771fe6b9SJerome Glisse tmp |= or_mask; 2739771fe6b9SJerome Glisse WREG32(addr, tmp); 2740771fe6b9SJerome Glisse break; 2741771fe6b9SJerome Glisse case 3: 2742771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2743771fe6b9SJerome Glisse offset += 4; 2744771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2745771fe6b9SJerome Glisse offset += 4; 2746771fe6b9SJerome Glisse tmp = RREG32(addr); 2747771fe6b9SJerome Glisse tmp &= and_mask; 2748771fe6b9SJerome Glisse tmp |= or_mask; 2749771fe6b9SJerome Glisse WREG32(addr, tmp); 2750771fe6b9SJerome Glisse break; 2751771fe6b9SJerome Glisse case 4: 2752771fe6b9SJerome Glisse val = RBIOS16(offset); 2753771fe6b9SJerome Glisse offset += 2; 2754771fe6b9SJerome Glisse udelay(val); 2755771fe6b9SJerome Glisse break; 2756771fe6b9SJerome Glisse case 5: 2757771fe6b9SJerome Glisse val = RBIOS16(offset); 2758771fe6b9SJerome Glisse offset += 2; 2759771fe6b9SJerome Glisse switch (addr) { 2760771fe6b9SJerome Glisse case 8: 2761771fe6b9SJerome Glisse while (val--) { 2762771fe6b9SJerome Glisse if (! 2763771fe6b9SJerome Glisse (RREG32_PLL 2764771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2765771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2766771fe6b9SJerome Glisse break; 2767771fe6b9SJerome Glisse } 2768771fe6b9SJerome Glisse break; 2769771fe6b9SJerome Glisse case 9: 2770771fe6b9SJerome Glisse while (val--) { 2771771fe6b9SJerome Glisse if ((RREG32(RADEON_MC_STATUS) & 2772771fe6b9SJerome Glisse RADEON_MC_IDLE)) 2773771fe6b9SJerome Glisse break; 2774771fe6b9SJerome Glisse } 2775771fe6b9SJerome Glisse break; 2776771fe6b9SJerome Glisse default: 2777771fe6b9SJerome Glisse break; 2778771fe6b9SJerome Glisse } 2779771fe6b9SJerome Glisse break; 2780771fe6b9SJerome Glisse default: 2781771fe6b9SJerome Glisse break; 2782771fe6b9SJerome Glisse } 2783771fe6b9SJerome Glisse } 2784771fe6b9SJerome Glisse } 2785771fe6b9SJerome Glisse } 2786771fe6b9SJerome Glisse 2787771fe6b9SJerome Glisse static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset) 2788771fe6b9SJerome Glisse { 2789771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2790771fe6b9SJerome Glisse 2791771fe6b9SJerome Glisse if (offset) { 2792771fe6b9SJerome Glisse while (RBIOS8(offset)) { 2793771fe6b9SJerome Glisse uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6); 2794771fe6b9SJerome Glisse uint8_t addr = (RBIOS8(offset) & 0x3f); 2795771fe6b9SJerome Glisse uint32_t val, shift, tmp; 2796771fe6b9SJerome Glisse uint32_t and_mask, or_mask; 2797771fe6b9SJerome Glisse 2798771fe6b9SJerome Glisse offset++; 2799771fe6b9SJerome Glisse switch (cmd) { 2800771fe6b9SJerome Glisse case 0: 2801771fe6b9SJerome Glisse val = RBIOS32(offset); 2802771fe6b9SJerome Glisse offset += 4; 2803771fe6b9SJerome Glisse WREG32_PLL(addr, val); 2804771fe6b9SJerome Glisse break; 2805771fe6b9SJerome Glisse case 1: 2806771fe6b9SJerome Glisse shift = RBIOS8(offset) * 8; 2807771fe6b9SJerome Glisse offset++; 2808771fe6b9SJerome Glisse and_mask = RBIOS8(offset) << shift; 2809771fe6b9SJerome Glisse and_mask |= ~(0xff << shift); 2810771fe6b9SJerome Glisse offset++; 2811771fe6b9SJerome Glisse or_mask = RBIOS8(offset) << shift; 2812771fe6b9SJerome Glisse offset++; 2813771fe6b9SJerome Glisse tmp = RREG32_PLL(addr); 2814771fe6b9SJerome Glisse tmp &= and_mask; 2815771fe6b9SJerome Glisse tmp |= or_mask; 2816771fe6b9SJerome Glisse WREG32_PLL(addr, tmp); 2817771fe6b9SJerome Glisse break; 2818771fe6b9SJerome Glisse case 2: 2819771fe6b9SJerome Glisse case 3: 2820771fe6b9SJerome Glisse tmp = 1000; 2821771fe6b9SJerome Glisse switch (addr) { 2822771fe6b9SJerome Glisse case 1: 2823771fe6b9SJerome Glisse udelay(150); 2824771fe6b9SJerome Glisse break; 2825771fe6b9SJerome Glisse case 2: 2826771fe6b9SJerome Glisse udelay(1000); 2827771fe6b9SJerome Glisse break; 2828771fe6b9SJerome Glisse case 3: 2829771fe6b9SJerome Glisse while (tmp--) { 2830771fe6b9SJerome Glisse if (! 2831771fe6b9SJerome Glisse (RREG32_PLL 2832771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2833771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2834771fe6b9SJerome Glisse break; 2835771fe6b9SJerome Glisse } 2836771fe6b9SJerome Glisse break; 2837771fe6b9SJerome Glisse case 4: 2838771fe6b9SJerome Glisse while (tmp--) { 2839771fe6b9SJerome Glisse if (RREG32_PLL 2840771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2841771fe6b9SJerome Glisse RADEON_DLL_READY) 2842771fe6b9SJerome Glisse break; 2843771fe6b9SJerome Glisse } 2844771fe6b9SJerome Glisse break; 2845771fe6b9SJerome Glisse case 5: 2846771fe6b9SJerome Glisse tmp = 2847771fe6b9SJerome Glisse RREG32_PLL(RADEON_CLK_PWRMGT_CNTL); 2848771fe6b9SJerome Glisse if (tmp & RADEON_CG_NO1_DEBUG_0) { 2849771fe6b9SJerome Glisse #if 0 2850771fe6b9SJerome Glisse uint32_t mclk_cntl = 2851771fe6b9SJerome Glisse RREG32_PLL 2852771fe6b9SJerome Glisse (RADEON_MCLK_CNTL); 2853771fe6b9SJerome Glisse mclk_cntl &= 0xffff0000; 2854771fe6b9SJerome Glisse /*mclk_cntl |= 0x00001111;*//* ??? */ 2855771fe6b9SJerome Glisse WREG32_PLL(RADEON_MCLK_CNTL, 2856771fe6b9SJerome Glisse mclk_cntl); 2857771fe6b9SJerome Glisse udelay(10000); 2858771fe6b9SJerome Glisse #endif 2859771fe6b9SJerome Glisse WREG32_PLL 2860771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL, 2861771fe6b9SJerome Glisse tmp & 2862771fe6b9SJerome Glisse ~RADEON_CG_NO1_DEBUG_0); 2863771fe6b9SJerome Glisse udelay(10000); 2864771fe6b9SJerome Glisse } 2865771fe6b9SJerome Glisse break; 2866771fe6b9SJerome Glisse default: 2867771fe6b9SJerome Glisse break; 2868771fe6b9SJerome Glisse } 2869771fe6b9SJerome Glisse break; 2870771fe6b9SJerome Glisse default: 2871771fe6b9SJerome Glisse break; 2872771fe6b9SJerome Glisse } 2873771fe6b9SJerome Glisse } 2874771fe6b9SJerome Glisse } 2875771fe6b9SJerome Glisse } 2876771fe6b9SJerome Glisse 2877771fe6b9SJerome Glisse static void combios_parse_ram_reset_table(struct drm_device *dev, 2878771fe6b9SJerome Glisse uint16_t offset) 2879771fe6b9SJerome Glisse { 2880771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2881771fe6b9SJerome Glisse uint32_t tmp; 2882771fe6b9SJerome Glisse 2883771fe6b9SJerome Glisse if (offset) { 2884771fe6b9SJerome Glisse uint8_t val = RBIOS8(offset); 2885771fe6b9SJerome Glisse while (val != 0xff) { 2886771fe6b9SJerome Glisse offset++; 2887771fe6b9SJerome Glisse 2888771fe6b9SJerome Glisse if (val == 0x0f) { 2889771fe6b9SJerome Glisse uint32_t channel_complete_mask; 2890771fe6b9SJerome Glisse 2891771fe6b9SJerome Glisse if (ASIC_IS_R300(rdev)) 2892771fe6b9SJerome Glisse channel_complete_mask = 2893771fe6b9SJerome Glisse R300_MEM_PWRUP_COMPLETE; 2894771fe6b9SJerome Glisse else 2895771fe6b9SJerome Glisse channel_complete_mask = 2896771fe6b9SJerome Glisse RADEON_MEM_PWRUP_COMPLETE; 2897771fe6b9SJerome Glisse tmp = 20000; 2898771fe6b9SJerome Glisse while (tmp--) { 2899771fe6b9SJerome Glisse if ((RREG32(RADEON_MEM_STR_CNTL) & 2900771fe6b9SJerome Glisse channel_complete_mask) == 2901771fe6b9SJerome Glisse channel_complete_mask) 2902771fe6b9SJerome Glisse break; 2903771fe6b9SJerome Glisse } 2904771fe6b9SJerome Glisse } else { 2905771fe6b9SJerome Glisse uint32_t or_mask = RBIOS16(offset); 2906771fe6b9SJerome Glisse offset += 2; 2907771fe6b9SJerome Glisse 2908771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 2909771fe6b9SJerome Glisse tmp &= RADEON_SDRAM_MODE_MASK; 2910771fe6b9SJerome Glisse tmp |= or_mask; 2911771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 2912771fe6b9SJerome Glisse 2913771fe6b9SJerome Glisse or_mask = val << 24; 2914771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 2915771fe6b9SJerome Glisse tmp &= RADEON_B3MEM_RESET_MASK; 2916771fe6b9SJerome Glisse tmp |= or_mask; 2917771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 2918771fe6b9SJerome Glisse } 2919771fe6b9SJerome Glisse val = RBIOS8(offset); 2920771fe6b9SJerome Glisse } 2921771fe6b9SJerome Glisse } 2922771fe6b9SJerome Glisse } 2923771fe6b9SJerome Glisse 2924771fe6b9SJerome Glisse static uint32_t combios_detect_ram(struct drm_device *dev, int ram, 2925771fe6b9SJerome Glisse int mem_addr_mapping) 2926771fe6b9SJerome Glisse { 2927771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2928771fe6b9SJerome Glisse uint32_t mem_cntl; 2929771fe6b9SJerome Glisse uint32_t mem_size; 2930771fe6b9SJerome Glisse uint32_t addr = 0; 2931771fe6b9SJerome Glisse 2932771fe6b9SJerome Glisse mem_cntl = RREG32(RADEON_MEM_CNTL); 2933771fe6b9SJerome Glisse if (mem_cntl & RV100_HALF_MODE) 2934771fe6b9SJerome Glisse ram /= 2; 2935771fe6b9SJerome Glisse mem_size = ram; 2936771fe6b9SJerome Glisse mem_cntl &= ~(0xff << 8); 2937771fe6b9SJerome Glisse mem_cntl |= (mem_addr_mapping & 0xff) << 8; 2938771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 2939771fe6b9SJerome Glisse RREG32(RADEON_MEM_CNTL); 2940771fe6b9SJerome Glisse 2941771fe6b9SJerome Glisse /* sdram reset ? */ 2942771fe6b9SJerome Glisse 2943771fe6b9SJerome Glisse /* something like this???? */ 2944771fe6b9SJerome Glisse while (ram--) { 2945771fe6b9SJerome Glisse addr = ram * 1024 * 1024; 2946771fe6b9SJerome Glisse /* write to each page */ 2947771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 2948771fe6b9SJerome Glisse WREG32(RADEON_MM_DATA, 0xdeadbeef); 2949771fe6b9SJerome Glisse /* read back and verify */ 2950771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 2951771fe6b9SJerome Glisse if (RREG32(RADEON_MM_DATA) != 0xdeadbeef) 2952771fe6b9SJerome Glisse return 0; 2953771fe6b9SJerome Glisse } 2954771fe6b9SJerome Glisse 2955771fe6b9SJerome Glisse return mem_size; 2956771fe6b9SJerome Glisse } 2957771fe6b9SJerome Glisse 2958771fe6b9SJerome Glisse static void combios_write_ram_size(struct drm_device *dev) 2959771fe6b9SJerome Glisse { 2960771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2961771fe6b9SJerome Glisse uint8_t rev; 2962771fe6b9SJerome Glisse uint16_t offset; 2963771fe6b9SJerome Glisse uint32_t mem_size = 0; 2964771fe6b9SJerome Glisse uint32_t mem_cntl = 0; 2965771fe6b9SJerome Glisse 2966771fe6b9SJerome Glisse /* should do something smarter here I guess... */ 2967771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_IGP) 2968771fe6b9SJerome Glisse return; 2969771fe6b9SJerome Glisse 2970771fe6b9SJerome Glisse /* first check detected mem table */ 2971771fe6b9SJerome Glisse offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE); 2972771fe6b9SJerome Glisse if (offset) { 2973771fe6b9SJerome Glisse rev = RBIOS8(offset); 2974771fe6b9SJerome Glisse if (rev < 3) { 2975771fe6b9SJerome Glisse mem_cntl = RBIOS32(offset + 1); 2976771fe6b9SJerome Glisse mem_size = RBIOS16(offset + 5); 29774ce9198eSAlex Deucher if ((rdev->family < CHIP_R200) && 29784ce9198eSAlex Deucher !ASIC_IS_RN50(rdev)) 2979771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 2980771fe6b9SJerome Glisse } 2981771fe6b9SJerome Glisse } 2982771fe6b9SJerome Glisse 2983771fe6b9SJerome Glisse if (!mem_size) { 2984771fe6b9SJerome Glisse offset = 2985771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 2986771fe6b9SJerome Glisse if (offset) { 2987771fe6b9SJerome Glisse rev = RBIOS8(offset - 1); 2988771fe6b9SJerome Glisse if (rev < 1) { 29894ce9198eSAlex Deucher if ((rdev->family < CHIP_R200) 29904ce9198eSAlex Deucher && !ASIC_IS_RN50(rdev)) { 2991771fe6b9SJerome Glisse int ram = 0; 2992771fe6b9SJerome Glisse int mem_addr_mapping = 0; 2993771fe6b9SJerome Glisse 2994771fe6b9SJerome Glisse while (RBIOS8(offset)) { 2995771fe6b9SJerome Glisse ram = RBIOS8(offset); 2996771fe6b9SJerome Glisse mem_addr_mapping = 2997771fe6b9SJerome Glisse RBIOS8(offset + 1); 2998771fe6b9SJerome Glisse if (mem_addr_mapping != 0x25) 2999771fe6b9SJerome Glisse ram *= 2; 3000771fe6b9SJerome Glisse mem_size = 3001771fe6b9SJerome Glisse combios_detect_ram(dev, ram, 3002771fe6b9SJerome Glisse mem_addr_mapping); 3003771fe6b9SJerome Glisse if (mem_size) 3004771fe6b9SJerome Glisse break; 3005771fe6b9SJerome Glisse offset += 2; 3006771fe6b9SJerome Glisse } 3007771fe6b9SJerome Glisse } else 3008771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 3009771fe6b9SJerome Glisse } else { 3010771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 3011771fe6b9SJerome Glisse mem_size *= 2; /* convert to MB */ 3012771fe6b9SJerome Glisse } 3013771fe6b9SJerome Glisse } 3014771fe6b9SJerome Glisse } 3015771fe6b9SJerome Glisse 3016771fe6b9SJerome Glisse mem_size *= (1024 * 1024); /* convert to bytes */ 3017771fe6b9SJerome Glisse WREG32(RADEON_CONFIG_MEMSIZE, mem_size); 3018771fe6b9SJerome Glisse } 3019771fe6b9SJerome Glisse 3020771fe6b9SJerome Glisse void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable) 3021771fe6b9SJerome Glisse { 3022771fe6b9SJerome Glisse uint16_t dyn_clk_info = 3023771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 3024771fe6b9SJerome Glisse 3025771fe6b9SJerome Glisse if (dyn_clk_info) 3026771fe6b9SJerome Glisse combios_parse_pll_table(dev, dyn_clk_info); 3027771fe6b9SJerome Glisse } 3028771fe6b9SJerome Glisse 3029771fe6b9SJerome Glisse void radeon_combios_asic_init(struct drm_device *dev) 3030771fe6b9SJerome Glisse { 3031771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3032771fe6b9SJerome Glisse uint16_t table; 3033771fe6b9SJerome Glisse 3034771fe6b9SJerome Glisse /* port hardcoded mac stuff from radeonfb */ 3035771fe6b9SJerome Glisse if (rdev->bios == NULL) 3036771fe6b9SJerome Glisse return; 3037771fe6b9SJerome Glisse 3038771fe6b9SJerome Glisse /* ASIC INIT 1 */ 3039771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE); 3040771fe6b9SJerome Glisse if (table) 3041771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3042771fe6b9SJerome Glisse 3043771fe6b9SJerome Glisse /* PLL INIT */ 3044771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE); 3045771fe6b9SJerome Glisse if (table) 3046771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 3047771fe6b9SJerome Glisse 3048771fe6b9SJerome Glisse /* ASIC INIT 2 */ 3049771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE); 3050771fe6b9SJerome Glisse if (table) 3051771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3052771fe6b9SJerome Glisse 3053771fe6b9SJerome Glisse if (!(rdev->flags & RADEON_IS_IGP)) { 3054771fe6b9SJerome Glisse /* ASIC INIT 4 */ 3055771fe6b9SJerome Glisse table = 3056771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE); 3057771fe6b9SJerome Glisse if (table) 3058771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3059771fe6b9SJerome Glisse 3060771fe6b9SJerome Glisse /* RAM RESET */ 3061771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE); 3062771fe6b9SJerome Glisse if (table) 3063771fe6b9SJerome Glisse combios_parse_ram_reset_table(dev, table); 3064771fe6b9SJerome Glisse 3065771fe6b9SJerome Glisse /* ASIC INIT 3 */ 3066771fe6b9SJerome Glisse table = 3067771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE); 3068771fe6b9SJerome Glisse if (table) 3069771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3070771fe6b9SJerome Glisse 3071771fe6b9SJerome Glisse /* write CONFIG_MEMSIZE */ 3072771fe6b9SJerome Glisse combios_write_ram_size(dev); 3073771fe6b9SJerome Glisse } 3074771fe6b9SJerome Glisse 3075580b4fffSDave Airlie /* quirk for rs4xx HP nx6125 laptop to make it resume 3076580b4fffSDave Airlie * - it hangs on resume inside the dynclk 1 table. 3077580b4fffSDave Airlie */ 3078580b4fffSDave Airlie if (rdev->family == CHIP_RS480 && 3079580b4fffSDave Airlie rdev->pdev->subsystem_vendor == 0x103c && 3080580b4fffSDave Airlie rdev->pdev->subsystem_device == 0x308b) 3081580b4fffSDave Airlie return; 3082580b4fffSDave Airlie 308352fa2bbcSAlex Deucher /* quirk for rs4xx HP dv5000 laptop to make it resume 308452fa2bbcSAlex Deucher * - it hangs on resume inside the dynclk 1 table. 308552fa2bbcSAlex Deucher */ 308652fa2bbcSAlex Deucher if (rdev->family == CHIP_RS480 && 308752fa2bbcSAlex Deucher rdev->pdev->subsystem_vendor == 0x103c && 308852fa2bbcSAlex Deucher rdev->pdev->subsystem_device == 0x30a4) 308952fa2bbcSAlex Deucher return; 309052fa2bbcSAlex Deucher 3091771fe6b9SJerome Glisse /* DYN CLK 1 */ 3092771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 3093771fe6b9SJerome Glisse if (table) 3094771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 3095771fe6b9SJerome Glisse 3096771fe6b9SJerome Glisse } 3097771fe6b9SJerome Glisse 3098771fe6b9SJerome Glisse void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev) 3099771fe6b9SJerome Glisse { 3100771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3101771fe6b9SJerome Glisse uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch; 3102771fe6b9SJerome Glisse 3103771fe6b9SJerome Glisse bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); 3104771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3105771fe6b9SJerome Glisse bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH); 3106771fe6b9SJerome Glisse 3107771fe6b9SJerome Glisse /* let the bios control the backlight */ 3108771fe6b9SJerome Glisse bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN; 3109771fe6b9SJerome Glisse 3110771fe6b9SJerome Glisse /* tell the bios not to handle mode switching */ 3111771fe6b9SJerome Glisse bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS | 3112771fe6b9SJerome Glisse RADEON_ACC_MODE_CHANGE); 3113771fe6b9SJerome Glisse 3114771fe6b9SJerome Glisse /* tell the bios a driver is loaded */ 3115771fe6b9SJerome Glisse bios_7_scratch |= RADEON_DRV_LOADED; 3116771fe6b9SJerome Glisse 3117771fe6b9SJerome Glisse WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch); 3118771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3119771fe6b9SJerome Glisse WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch); 3120771fe6b9SJerome Glisse } 3121771fe6b9SJerome Glisse 3122771fe6b9SJerome Glisse void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock) 3123771fe6b9SJerome Glisse { 3124771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3125771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3126771fe6b9SJerome Glisse uint32_t bios_6_scratch; 3127771fe6b9SJerome Glisse 3128771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3129771fe6b9SJerome Glisse 3130771fe6b9SJerome Glisse if (lock) 3131771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DRIVER_CRITICAL; 3132771fe6b9SJerome Glisse else 3133771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DRIVER_CRITICAL; 3134771fe6b9SJerome Glisse 3135771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3136771fe6b9SJerome Glisse } 3137771fe6b9SJerome Glisse 3138771fe6b9SJerome Glisse void 3139771fe6b9SJerome Glisse radeon_combios_connected_scratch_regs(struct drm_connector *connector, 3140771fe6b9SJerome Glisse struct drm_encoder *encoder, 3141771fe6b9SJerome Glisse bool connected) 3142771fe6b9SJerome Glisse { 3143771fe6b9SJerome Glisse struct drm_device *dev = connector->dev; 3144771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3145771fe6b9SJerome Glisse struct radeon_connector *radeon_connector = 3146771fe6b9SJerome Glisse to_radeon_connector(connector); 3147771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3148771fe6b9SJerome Glisse uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH); 3149771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3150771fe6b9SJerome Glisse 3151771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) && 3152771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) { 3153771fe6b9SJerome Glisse if (connected) { 3154d9fdaafbSDave Airlie DRM_DEBUG_KMS("TV1 connected\n"); 3155771fe6b9SJerome Glisse /* fix me */ 3156771fe6b9SJerome Glisse bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO; 3157771fe6b9SJerome Glisse /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */ 3158771fe6b9SJerome Glisse bios_5_scratch |= RADEON_TV1_ON; 3159771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_TV1; 3160771fe6b9SJerome Glisse } else { 3161d9fdaafbSDave Airlie DRM_DEBUG_KMS("TV1 disconnected\n"); 3162771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK; 3163771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_ON; 3164771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_TV1; 3165771fe6b9SJerome Glisse } 3166771fe6b9SJerome Glisse } 3167771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) && 3168771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) { 3169771fe6b9SJerome Glisse if (connected) { 3170d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD1 connected\n"); 3171771fe6b9SJerome Glisse bios_4_scratch |= RADEON_LCD1_ATTACHED; 3172771fe6b9SJerome Glisse bios_5_scratch |= RADEON_LCD1_ON; 3173771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_LCD1; 3174771fe6b9SJerome Glisse } else { 3175d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD1 disconnected\n"); 3176771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_LCD1_ATTACHED; 3177771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_ON; 3178771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_LCD1; 3179771fe6b9SJerome Glisse } 3180771fe6b9SJerome Glisse } 3181771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) && 3182771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) { 3183771fe6b9SJerome Glisse if (connected) { 3184d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT1 connected\n"); 3185771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR; 3186771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT1_ON; 3187771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT1; 3188771fe6b9SJerome Glisse } else { 3189d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT1 disconnected\n"); 3190771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK; 3191771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_ON; 3192771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT1; 3193771fe6b9SJerome Glisse } 3194771fe6b9SJerome Glisse } 3195771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) && 3196771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) { 3197771fe6b9SJerome Glisse if (connected) { 3198d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT2 connected\n"); 3199771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR; 3200771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT2_ON; 3201771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT2; 3202771fe6b9SJerome Glisse } else { 3203d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT2 disconnected\n"); 3204771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK; 3205771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_ON; 3206771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT2; 3207771fe6b9SJerome Glisse } 3208771fe6b9SJerome Glisse } 3209771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) && 3210771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) { 3211771fe6b9SJerome Glisse if (connected) { 3212d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP1 connected\n"); 3213771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP1_ATTACHED; 3214771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP1_ON; 3215771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP1; 3216771fe6b9SJerome Glisse } else { 3217d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP1 disconnected\n"); 3218771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP1_ATTACHED; 3219771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_ON; 3220771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP1; 3221771fe6b9SJerome Glisse } 3222771fe6b9SJerome Glisse } 3223771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) && 3224771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) { 3225771fe6b9SJerome Glisse if (connected) { 3226d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP2 connected\n"); 3227771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP2_ATTACHED; 3228771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP2_ON; 3229771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP2; 3230771fe6b9SJerome Glisse } else { 3231d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP2 disconnected\n"); 3232771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP2_ATTACHED; 3233771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_ON; 3234771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP2; 3235771fe6b9SJerome Glisse } 3236771fe6b9SJerome Glisse } 3237771fe6b9SJerome Glisse WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch); 3238771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3239771fe6b9SJerome Glisse } 3240771fe6b9SJerome Glisse 3241771fe6b9SJerome Glisse void 3242771fe6b9SJerome Glisse radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc) 3243771fe6b9SJerome Glisse { 3244771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3245771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3246771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3247771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3248771fe6b9SJerome Glisse 3249771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { 3250771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_CRTC_MASK; 3251771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT); 3252771fe6b9SJerome Glisse } 3253771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { 3254771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK; 3255771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT); 3256771fe6b9SJerome Glisse } 3257771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { 3258771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK; 3259771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT); 3260771fe6b9SJerome Glisse } 3261771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { 3262771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK; 3263771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT); 3264771fe6b9SJerome Glisse } 3265771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { 3266771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK; 3267771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT); 3268771fe6b9SJerome Glisse } 3269771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { 3270771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK; 3271771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT); 3272771fe6b9SJerome Glisse } 3273771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3274771fe6b9SJerome Glisse } 3275771fe6b9SJerome Glisse 3276771fe6b9SJerome Glisse void 3277771fe6b9SJerome Glisse radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on) 3278771fe6b9SJerome Glisse { 3279771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3280771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3281771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3282771fe6b9SJerome Glisse uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3283771fe6b9SJerome Glisse 3284771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { 3285771fe6b9SJerome Glisse if (on) 3286771fe6b9SJerome Glisse bios_6_scratch |= RADEON_TV_DPMS_ON; 3287771fe6b9SJerome Glisse else 3288771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_TV_DPMS_ON; 3289771fe6b9SJerome Glisse } 3290771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) { 3291771fe6b9SJerome Glisse if (on) 3292771fe6b9SJerome Glisse bios_6_scratch |= RADEON_CRT_DPMS_ON; 3293771fe6b9SJerome Glisse else 3294771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_CRT_DPMS_ON; 3295771fe6b9SJerome Glisse } 3296771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 3297771fe6b9SJerome Glisse if (on) 3298771fe6b9SJerome Glisse bios_6_scratch |= RADEON_LCD_DPMS_ON; 3299771fe6b9SJerome Glisse else 3300771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_LCD_DPMS_ON; 3301771fe6b9SJerome Glisse } 3302771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 3303771fe6b9SJerome Glisse if (on) 3304771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DFP_DPMS_ON; 3305771fe6b9SJerome Glisse else 3306771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DFP_DPMS_ON; 3307771fe6b9SJerome Glisse } 3308771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3309771fe6b9SJerome Glisse } 3310