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 474c324acd5SAlex Deucher /* this is used for atom LCDs as well */ 4753c537889SAlex Deucher struct edid * 476c324acd5SAlex Deucher radeon_bios_get_hardcoded_edid(struct radeon_device *rdev) 4773c537889SAlex Deucher { 4783c537889SAlex Deucher if (rdev->mode_info.bios_hardcoded_edid) 4793c537889SAlex Deucher return rdev->mode_info.bios_hardcoded_edid; 4803c537889SAlex Deucher return NULL; 4813c537889SAlex Deucher } 4823c537889SAlex Deucher 4836a93cb25SAlex Deucher static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev, 484179e8078SAlex Deucher enum radeon_combios_ddc ddc, 485179e8078SAlex Deucher u32 clk_mask, 486179e8078SAlex Deucher u32 data_mask) 487771fe6b9SJerome Glisse { 488771fe6b9SJerome Glisse struct radeon_i2c_bus_rec i2c; 489179e8078SAlex Deucher int ddc_line = 0; 490179e8078SAlex Deucher 491179e8078SAlex Deucher /* ddc id = mask reg 492179e8078SAlex Deucher * DDC_NONE_DETECTED = none 493179e8078SAlex Deucher * DDC_DVI = RADEON_GPIO_DVI_DDC 494179e8078SAlex Deucher * DDC_VGA = RADEON_GPIO_VGA_DDC 495179e8078SAlex Deucher * DDC_LCD = RADEON_GPIOPAD_MASK 496179e8078SAlex Deucher * DDC_GPIO = RADEON_MDGPIO_MASK 497179e8078SAlex Deucher * r1xx/r2xx 498179e8078SAlex Deucher * DDC_MONID = RADEON_GPIO_MONID 499179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_CRT2_DDC 500179e8078SAlex Deucher * r3xx 501179e8078SAlex Deucher * DDC_MONID = RADEON_GPIO_MONID 502179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_DVI_DDC 503179e8078SAlex Deucher * rs3xx/rs4xx 504179e8078SAlex Deucher * DDC_MONID = RADEON_GPIOPAD_MASK 505179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_MONID 506179e8078SAlex Deucher */ 507179e8078SAlex Deucher switch (ddc) { 508179e8078SAlex Deucher case DDC_NONE_DETECTED: 509179e8078SAlex Deucher default: 510179e8078SAlex Deucher ddc_line = 0; 511179e8078SAlex Deucher break; 512179e8078SAlex Deucher case DDC_DVI: 513179e8078SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 514179e8078SAlex Deucher break; 515179e8078SAlex Deucher case DDC_VGA: 516179e8078SAlex Deucher ddc_line = RADEON_GPIO_VGA_DDC; 517179e8078SAlex Deucher break; 518179e8078SAlex Deucher case DDC_LCD: 519179e8078SAlex Deucher ddc_line = RADEON_GPIOPAD_MASK; 520179e8078SAlex Deucher break; 521179e8078SAlex Deucher case DDC_GPIO: 522179e8078SAlex Deucher ddc_line = RADEON_MDGPIO_MASK; 523179e8078SAlex Deucher break; 524179e8078SAlex Deucher case DDC_MONID: 525179e8078SAlex Deucher if (rdev->family == CHIP_RS300 || 526179e8078SAlex Deucher rdev->family == CHIP_RS400 || 527179e8078SAlex Deucher rdev->family == CHIP_RS480) 528179e8078SAlex Deucher ddc_line = RADEON_GPIOPAD_MASK; 529179e8078SAlex Deucher else 530179e8078SAlex Deucher ddc_line = RADEON_GPIO_MONID; 531179e8078SAlex Deucher break; 532179e8078SAlex Deucher case DDC_CRT2: 533179e8078SAlex Deucher if (rdev->family == CHIP_RS300 || 534179e8078SAlex Deucher rdev->family == CHIP_RS400 || 535179e8078SAlex Deucher rdev->family == CHIP_RS480) 536179e8078SAlex Deucher ddc_line = RADEON_GPIO_MONID; 537179e8078SAlex Deucher else if (rdev->family >= CHIP_R300) { 538179e8078SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 539179e8078SAlex Deucher ddc = DDC_DVI; 540179e8078SAlex Deucher } else 541179e8078SAlex Deucher ddc_line = RADEON_GPIO_CRT2_DDC; 542179e8078SAlex Deucher break; 543179e8078SAlex Deucher } 544771fe6b9SJerome Glisse 5456a93cb25SAlex Deucher if (ddc_line == RADEON_GPIOPAD_MASK) { 5466a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_GPIOPAD_MASK; 5476a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_GPIOPAD_MASK; 5486a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_GPIOPAD_A; 5496a93cb25SAlex Deucher i2c.a_data_reg = RADEON_GPIOPAD_A; 5506a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_GPIOPAD_EN; 5516a93cb25SAlex Deucher i2c.en_data_reg = RADEON_GPIOPAD_EN; 5526a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_GPIOPAD_Y; 5536a93cb25SAlex Deucher i2c.y_data_reg = RADEON_GPIOPAD_Y; 5546a93cb25SAlex Deucher } else if (ddc_line == RADEON_MDGPIO_MASK) { 5556a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_MDGPIO_MASK; 5566a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_MDGPIO_MASK; 5576a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_MDGPIO_A; 5586a93cb25SAlex Deucher i2c.a_data_reg = RADEON_MDGPIO_A; 5596a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_MDGPIO_EN; 5606a93cb25SAlex Deucher i2c.en_data_reg = RADEON_MDGPIO_EN; 5616a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_MDGPIO_Y; 5626a93cb25SAlex Deucher i2c.y_data_reg = RADEON_MDGPIO_Y; 5636a93cb25SAlex Deucher } else { 564771fe6b9SJerome Glisse i2c.mask_clk_reg = ddc_line; 565771fe6b9SJerome Glisse i2c.mask_data_reg = ddc_line; 566771fe6b9SJerome Glisse i2c.a_clk_reg = ddc_line; 567771fe6b9SJerome Glisse i2c.a_data_reg = ddc_line; 5689b9fe724SAlex Deucher i2c.en_clk_reg = ddc_line; 5699b9fe724SAlex Deucher i2c.en_data_reg = ddc_line; 5709b9fe724SAlex Deucher i2c.y_clk_reg = ddc_line; 5719b9fe724SAlex Deucher i2c.y_data_reg = ddc_line; 572771fe6b9SJerome Glisse } 573771fe6b9SJerome Glisse 574179e8078SAlex Deucher if (clk_mask && data_mask) { 575be663057SAlex Deucher /* system specific masks */ 576179e8078SAlex Deucher i2c.mask_clk_mask = clk_mask; 577179e8078SAlex Deucher i2c.mask_data_mask = data_mask; 578179e8078SAlex Deucher i2c.a_clk_mask = clk_mask; 579179e8078SAlex Deucher i2c.a_data_mask = data_mask; 580179e8078SAlex Deucher i2c.en_clk_mask = clk_mask; 581179e8078SAlex Deucher i2c.en_data_mask = data_mask; 582179e8078SAlex Deucher i2c.y_clk_mask = clk_mask; 583179e8078SAlex Deucher i2c.y_data_mask = data_mask; 584be663057SAlex Deucher } else if ((ddc_line == RADEON_GPIOPAD_MASK) || 585be663057SAlex Deucher (ddc_line == RADEON_MDGPIO_MASK)) { 586be663057SAlex Deucher /* default gpiopad masks */ 587be663057SAlex Deucher i2c.mask_clk_mask = (0x20 << 8); 588be663057SAlex Deucher i2c.mask_data_mask = 0x80; 589be663057SAlex Deucher i2c.a_clk_mask = (0x20 << 8); 590be663057SAlex Deucher i2c.a_data_mask = 0x80; 591be663057SAlex Deucher i2c.en_clk_mask = (0x20 << 8); 592be663057SAlex Deucher i2c.en_data_mask = 0x80; 593be663057SAlex Deucher i2c.y_clk_mask = (0x20 << 8); 594be663057SAlex Deucher i2c.y_data_mask = 0x80; 595179e8078SAlex Deucher } else { 596be663057SAlex Deucher /* default masks for ddc pads */ 597179e8078SAlex Deucher i2c.mask_clk_mask = RADEON_GPIO_EN_1; 598179e8078SAlex Deucher i2c.mask_data_mask = RADEON_GPIO_EN_0; 599179e8078SAlex Deucher i2c.a_clk_mask = RADEON_GPIO_A_1; 600179e8078SAlex Deucher i2c.a_data_mask = RADEON_GPIO_A_0; 601179e8078SAlex Deucher i2c.en_clk_mask = RADEON_GPIO_EN_1; 602179e8078SAlex Deucher i2c.en_data_mask = RADEON_GPIO_EN_0; 603179e8078SAlex Deucher i2c.y_clk_mask = RADEON_GPIO_Y_1; 604179e8078SAlex Deucher i2c.y_data_mask = RADEON_GPIO_Y_0; 605179e8078SAlex Deucher } 606179e8078SAlex Deucher 60740bacf16SAlex Deucher switch (rdev->family) { 60840bacf16SAlex Deucher case CHIP_R100: 60940bacf16SAlex Deucher case CHIP_RV100: 61040bacf16SAlex Deucher case CHIP_RS100: 61140bacf16SAlex Deucher case CHIP_RV200: 61240bacf16SAlex Deucher case CHIP_RS200: 61340bacf16SAlex Deucher case CHIP_RS300: 61440bacf16SAlex Deucher switch (ddc_line) { 61540bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 616b28ea411SAlex Deucher i2c.hw_capable = true; 61740bacf16SAlex Deucher break; 61840bacf16SAlex Deucher default: 61940bacf16SAlex Deucher i2c.hw_capable = false; 62040bacf16SAlex Deucher break; 62140bacf16SAlex Deucher } 62240bacf16SAlex Deucher break; 62340bacf16SAlex Deucher case CHIP_R200: 62440bacf16SAlex Deucher switch (ddc_line) { 62540bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 62640bacf16SAlex Deucher case RADEON_GPIO_MONID: 62740bacf16SAlex Deucher i2c.hw_capable = true; 62840bacf16SAlex Deucher break; 62940bacf16SAlex Deucher default: 63040bacf16SAlex Deucher i2c.hw_capable = false; 63140bacf16SAlex Deucher break; 63240bacf16SAlex Deucher } 63340bacf16SAlex Deucher break; 63440bacf16SAlex Deucher case CHIP_RV250: 63540bacf16SAlex Deucher case CHIP_RV280: 63640bacf16SAlex Deucher switch (ddc_line) { 63740bacf16SAlex Deucher case RADEON_GPIO_VGA_DDC: 63840bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 63940bacf16SAlex Deucher case RADEON_GPIO_CRT2_DDC: 64040bacf16SAlex Deucher i2c.hw_capable = true; 64140bacf16SAlex Deucher break; 64240bacf16SAlex Deucher default: 64340bacf16SAlex Deucher i2c.hw_capable = false; 64440bacf16SAlex Deucher break; 64540bacf16SAlex Deucher } 64640bacf16SAlex Deucher break; 64740bacf16SAlex Deucher case CHIP_R300: 64840bacf16SAlex Deucher case CHIP_R350: 64940bacf16SAlex Deucher switch (ddc_line) { 65040bacf16SAlex Deucher case RADEON_GPIO_VGA_DDC: 65140bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 65240bacf16SAlex Deucher i2c.hw_capable = true; 65340bacf16SAlex Deucher break; 65440bacf16SAlex Deucher default: 65540bacf16SAlex Deucher i2c.hw_capable = false; 65640bacf16SAlex Deucher break; 65740bacf16SAlex Deucher } 65840bacf16SAlex Deucher break; 65940bacf16SAlex Deucher case CHIP_RV350: 66040bacf16SAlex Deucher case CHIP_RV380: 66140bacf16SAlex Deucher case CHIP_RS400: 66240bacf16SAlex Deucher case CHIP_RS480: 6636a93cb25SAlex Deucher switch (ddc_line) { 6646a93cb25SAlex Deucher case RADEON_GPIO_VGA_DDC: 6656a93cb25SAlex Deucher case RADEON_GPIO_DVI_DDC: 6666a93cb25SAlex Deucher i2c.hw_capable = true; 6676a93cb25SAlex Deucher break; 6686a93cb25SAlex Deucher case RADEON_GPIO_MONID: 6696a93cb25SAlex Deucher /* hw i2c on RADEON_GPIO_MONID doesn't seem to work 6706a93cb25SAlex Deucher * reliably on some pre-r4xx hardware; not sure why. 6716a93cb25SAlex Deucher */ 6726a93cb25SAlex Deucher i2c.hw_capable = false; 6736a93cb25SAlex Deucher break; 6746a93cb25SAlex Deucher default: 6756a93cb25SAlex Deucher i2c.hw_capable = false; 6766a93cb25SAlex Deucher break; 6776a93cb25SAlex Deucher } 67840bacf16SAlex Deucher break; 67940bacf16SAlex Deucher default: 68040bacf16SAlex Deucher i2c.hw_capable = false; 68140bacf16SAlex Deucher break; 6826a93cb25SAlex Deucher } 6836a93cb25SAlex Deucher i2c.mm_i2c = false; 684f376b94fSAlex Deucher 685179e8078SAlex Deucher i2c.i2c_id = ddc; 6868e36ed00SAlex Deucher i2c.hpd = RADEON_HPD_NONE; 6876a93cb25SAlex Deucher 688771fe6b9SJerome Glisse if (ddc_line) 689771fe6b9SJerome Glisse i2c.valid = true; 690771fe6b9SJerome Glisse else 691771fe6b9SJerome Glisse i2c.valid = false; 692771fe6b9SJerome Glisse 693771fe6b9SJerome Glisse return i2c; 694771fe6b9SJerome Glisse } 695771fe6b9SJerome Glisse 696f376b94fSAlex Deucher void radeon_combios_i2c_init(struct radeon_device *rdev) 697f376b94fSAlex Deucher { 698f376b94fSAlex Deucher struct drm_device *dev = rdev->ddev; 699f376b94fSAlex Deucher struct radeon_i2c_bus_rec i2c; 700f376b94fSAlex Deucher 701f376b94fSAlex Deucher 702179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 703179e8078SAlex Deucher rdev->i2c_bus[0] = radeon_i2c_create(dev, &i2c, "DVI_DDC"); 704f376b94fSAlex Deucher 705179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 706179e8078SAlex Deucher rdev->i2c_bus[1] = radeon_i2c_create(dev, &i2c, "VGA_DDC"); 707f376b94fSAlex Deucher 708f376b94fSAlex Deucher i2c.valid = true; 709f376b94fSAlex Deucher i2c.hw_capable = true; 710f376b94fSAlex Deucher i2c.mm_i2c = true; 711179e8078SAlex Deucher i2c.i2c_id = 0xa0; 712179e8078SAlex Deucher rdev->i2c_bus[2] = radeon_i2c_create(dev, &i2c, "MM_I2C"); 713179e8078SAlex Deucher 714179e8078SAlex Deucher if (rdev->family == CHIP_RS300 || 715179e8078SAlex Deucher rdev->family == CHIP_RS400 || 716179e8078SAlex Deucher rdev->family == CHIP_RS480) { 717179e8078SAlex Deucher u16 offset; 718179e8078SAlex Deucher u8 id, blocks, clk, data; 719179e8078SAlex Deucher int i; 720179e8078SAlex Deucher 721179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 722179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 723179e8078SAlex Deucher 724179e8078SAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE); 725179e8078SAlex Deucher if (offset) { 726179e8078SAlex Deucher blocks = RBIOS8(offset + 2); 727179e8078SAlex Deucher for (i = 0; i < blocks; i++) { 728179e8078SAlex Deucher id = RBIOS8(offset + 3 + (i * 5) + 0); 729179e8078SAlex Deucher if (id == 136) { 730179e8078SAlex Deucher clk = RBIOS8(offset + 3 + (i * 5) + 3); 731179e8078SAlex Deucher data = RBIOS8(offset + 3 + (i * 5) + 4); 732179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 733791cfe26SAlex Deucher (1 << clk), (1 << data)); 734179e8078SAlex Deucher rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "GPIOPAD_MASK"); 735179e8078SAlex Deucher break; 736179e8078SAlex Deucher } 737179e8078SAlex Deucher } 738179e8078SAlex Deucher } 739179e8078SAlex Deucher 740179e8078SAlex Deucher } else if (rdev->family >= CHIP_R300) { 741179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 742179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 743179e8078SAlex Deucher } else { 744179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 745179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 746179e8078SAlex Deucher 747179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 748179e8078SAlex Deucher rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "CRT2_DDC"); 749179e8078SAlex Deucher } 750f376b94fSAlex Deucher } 751f376b94fSAlex Deucher 752771fe6b9SJerome Glisse bool radeon_combios_get_clock_info(struct drm_device *dev) 753771fe6b9SJerome Glisse { 754771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 755771fe6b9SJerome Glisse uint16_t pll_info; 756771fe6b9SJerome Glisse struct radeon_pll *p1pll = &rdev->clock.p1pll; 757771fe6b9SJerome Glisse struct radeon_pll *p2pll = &rdev->clock.p2pll; 758771fe6b9SJerome Glisse struct radeon_pll *spll = &rdev->clock.spll; 759771fe6b9SJerome Glisse struct radeon_pll *mpll = &rdev->clock.mpll; 760771fe6b9SJerome Glisse int8_t rev; 761771fe6b9SJerome Glisse uint16_t sclk, mclk; 762771fe6b9SJerome Glisse 763771fe6b9SJerome Glisse pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE); 764771fe6b9SJerome Glisse if (pll_info) { 765771fe6b9SJerome Glisse rev = RBIOS8(pll_info); 766771fe6b9SJerome Glisse 767771fe6b9SJerome Glisse /* pixel clocks */ 768771fe6b9SJerome Glisse p1pll->reference_freq = RBIOS16(pll_info + 0xe); 769771fe6b9SJerome Glisse p1pll->reference_div = RBIOS16(pll_info + 0x10); 770771fe6b9SJerome Glisse p1pll->pll_out_min = RBIOS32(pll_info + 0x12); 771771fe6b9SJerome Glisse p1pll->pll_out_max = RBIOS32(pll_info + 0x16); 77286cb2bbfSAlex Deucher p1pll->lcd_pll_out_min = p1pll->pll_out_min; 77386cb2bbfSAlex Deucher p1pll->lcd_pll_out_max = p1pll->pll_out_max; 774771fe6b9SJerome Glisse 775771fe6b9SJerome Glisse if (rev > 9) { 776771fe6b9SJerome Glisse p1pll->pll_in_min = RBIOS32(pll_info + 0x36); 777771fe6b9SJerome Glisse p1pll->pll_in_max = RBIOS32(pll_info + 0x3a); 778771fe6b9SJerome Glisse } else { 779771fe6b9SJerome Glisse p1pll->pll_in_min = 40; 780771fe6b9SJerome Glisse p1pll->pll_in_max = 500; 781771fe6b9SJerome Glisse } 782771fe6b9SJerome Glisse *p2pll = *p1pll; 783771fe6b9SJerome Glisse 784771fe6b9SJerome Glisse /* system clock */ 785771fe6b9SJerome Glisse spll->reference_freq = RBIOS16(pll_info + 0x1a); 786771fe6b9SJerome Glisse spll->reference_div = RBIOS16(pll_info + 0x1c); 787771fe6b9SJerome Glisse spll->pll_out_min = RBIOS32(pll_info + 0x1e); 788771fe6b9SJerome Glisse spll->pll_out_max = RBIOS32(pll_info + 0x22); 789771fe6b9SJerome Glisse 790771fe6b9SJerome Glisse if (rev > 10) { 791771fe6b9SJerome Glisse spll->pll_in_min = RBIOS32(pll_info + 0x48); 792771fe6b9SJerome Glisse spll->pll_in_max = RBIOS32(pll_info + 0x4c); 793771fe6b9SJerome Glisse } else { 794771fe6b9SJerome Glisse /* ??? */ 795771fe6b9SJerome Glisse spll->pll_in_min = 40; 796771fe6b9SJerome Glisse spll->pll_in_max = 500; 797771fe6b9SJerome Glisse } 798771fe6b9SJerome Glisse 799771fe6b9SJerome Glisse /* memory clock */ 800771fe6b9SJerome Glisse mpll->reference_freq = RBIOS16(pll_info + 0x26); 801771fe6b9SJerome Glisse mpll->reference_div = RBIOS16(pll_info + 0x28); 802771fe6b9SJerome Glisse mpll->pll_out_min = RBIOS32(pll_info + 0x2a); 803771fe6b9SJerome Glisse mpll->pll_out_max = RBIOS32(pll_info + 0x2e); 804771fe6b9SJerome Glisse 805771fe6b9SJerome Glisse if (rev > 10) { 806771fe6b9SJerome Glisse mpll->pll_in_min = RBIOS32(pll_info + 0x5a); 807771fe6b9SJerome Glisse mpll->pll_in_max = RBIOS32(pll_info + 0x5e); 808771fe6b9SJerome Glisse } else { 809771fe6b9SJerome Glisse /* ??? */ 810771fe6b9SJerome Glisse mpll->pll_in_min = 40; 811771fe6b9SJerome Glisse mpll->pll_in_max = 500; 812771fe6b9SJerome Glisse } 813771fe6b9SJerome Glisse 814771fe6b9SJerome Glisse /* default sclk/mclk */ 815771fe6b9SJerome Glisse sclk = RBIOS16(pll_info + 0xa); 816771fe6b9SJerome Glisse mclk = RBIOS16(pll_info + 0x8); 817771fe6b9SJerome Glisse if (sclk == 0) 818771fe6b9SJerome Glisse sclk = 200 * 100; 819771fe6b9SJerome Glisse if (mclk == 0) 820771fe6b9SJerome Glisse mclk = 200 * 100; 821771fe6b9SJerome Glisse 822771fe6b9SJerome Glisse rdev->clock.default_sclk = sclk; 823771fe6b9SJerome Glisse rdev->clock.default_mclk = mclk; 824771fe6b9SJerome Glisse 825771fe6b9SJerome Glisse return true; 826771fe6b9SJerome Glisse } 827771fe6b9SJerome Glisse return false; 828771fe6b9SJerome Glisse } 829771fe6b9SJerome Glisse 83006b6476dSAlex Deucher bool radeon_combios_sideport_present(struct radeon_device *rdev) 83106b6476dSAlex Deucher { 83206b6476dSAlex Deucher struct drm_device *dev = rdev->ddev; 83306b6476dSAlex Deucher u16 igp_info; 83406b6476dSAlex Deucher 8354c70b2eaSAlex Deucher /* sideport is AMD only */ 8364c70b2eaSAlex Deucher if (rdev->family == CHIP_RS400) 8374c70b2eaSAlex Deucher return false; 8384c70b2eaSAlex Deucher 83906b6476dSAlex Deucher igp_info = combios_get_table_offset(dev, COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE); 84006b6476dSAlex Deucher 84106b6476dSAlex Deucher if (igp_info) { 84206b6476dSAlex Deucher if (RBIOS16(igp_info + 0x4)) 84306b6476dSAlex Deucher return true; 84406b6476dSAlex Deucher } 84506b6476dSAlex Deucher return false; 84606b6476dSAlex Deucher } 84706b6476dSAlex Deucher 848246263ccSAlex Deucher static const uint32_t default_primarydac_adj[CHIP_LAST] = { 849246263ccSAlex Deucher 0x00000808, /* r100 */ 850246263ccSAlex Deucher 0x00000808, /* rv100 */ 851246263ccSAlex Deucher 0x00000808, /* rs100 */ 852246263ccSAlex Deucher 0x00000808, /* rv200 */ 853246263ccSAlex Deucher 0x00000808, /* rs200 */ 854246263ccSAlex Deucher 0x00000808, /* r200 */ 855246263ccSAlex Deucher 0x00000808, /* rv250 */ 856246263ccSAlex Deucher 0x00000000, /* rs300 */ 857246263ccSAlex Deucher 0x00000808, /* rv280 */ 858246263ccSAlex Deucher 0x00000808, /* r300 */ 859246263ccSAlex Deucher 0x00000808, /* r350 */ 860246263ccSAlex Deucher 0x00000808, /* rv350 */ 861246263ccSAlex Deucher 0x00000808, /* rv380 */ 862246263ccSAlex Deucher 0x00000808, /* r420 */ 863246263ccSAlex Deucher 0x00000808, /* r423 */ 864246263ccSAlex Deucher 0x00000808, /* rv410 */ 865246263ccSAlex Deucher 0x00000000, /* rs400 */ 866246263ccSAlex Deucher 0x00000000, /* rs480 */ 867246263ccSAlex Deucher }; 868246263ccSAlex Deucher 869246263ccSAlex Deucher static void radeon_legacy_get_primary_dac_info_from_table(struct radeon_device *rdev, 870246263ccSAlex Deucher struct radeon_encoder_primary_dac *p_dac) 871246263ccSAlex Deucher { 872246263ccSAlex Deucher p_dac->ps2_pdac_adj = default_primarydac_adj[rdev->family]; 873246263ccSAlex Deucher return; 874246263ccSAlex Deucher } 875246263ccSAlex Deucher 876771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct 877771fe6b9SJerome Glisse radeon_encoder 878771fe6b9SJerome Glisse *encoder) 879771fe6b9SJerome Glisse { 880771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 881771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 882771fe6b9SJerome Glisse uint16_t dac_info; 883771fe6b9SJerome Glisse uint8_t rev, bg, dac; 884771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *p_dac = NULL; 885246263ccSAlex Deucher int found = 0; 886771fe6b9SJerome Glisse 887246263ccSAlex Deucher p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), 888771fe6b9SJerome Glisse GFP_KERNEL); 889771fe6b9SJerome Glisse 890771fe6b9SJerome Glisse if (!p_dac) 891771fe6b9SJerome Glisse return NULL; 892771fe6b9SJerome Glisse 893246263ccSAlex Deucher /* check CRT table */ 894246263ccSAlex Deucher dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 895246263ccSAlex Deucher if (dac_info) { 896771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 897771fe6b9SJerome Glisse if (rev < 2) { 898771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 899771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf; 900771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 901771fe6b9SJerome Glisse } else { 902771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 903771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x3) & 0xf; 904771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 905771fe6b9SJerome Glisse } 9063a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 9073a89b4a9SAlex Deucher if (p_dac->ps2_pdac_adj) 908246263ccSAlex Deucher found = 1; 909771fe6b9SJerome Glisse } 910771fe6b9SJerome Glisse 911246263ccSAlex Deucher if (!found) /* fallback to defaults */ 912246263ccSAlex Deucher radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac); 913246263ccSAlex Deucher 914771fe6b9SJerome Glisse return p_dac; 915771fe6b9SJerome Glisse } 916771fe6b9SJerome Glisse 917d79766faSAlex Deucher enum radeon_tv_std 918d79766faSAlex Deucher radeon_combios_get_tv_info(struct radeon_device *rdev) 919771fe6b9SJerome Glisse { 920d79766faSAlex Deucher struct drm_device *dev = rdev->ddev; 921771fe6b9SJerome Glisse uint16_t tv_info; 922771fe6b9SJerome Glisse enum radeon_tv_std tv_std = TV_STD_NTSC; 923771fe6b9SJerome Glisse 924771fe6b9SJerome Glisse tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 925771fe6b9SJerome Glisse if (tv_info) { 926771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 927771fe6b9SJerome Glisse switch (RBIOS8(tv_info + 7) & 0xf) { 928771fe6b9SJerome Glisse case 1: 929771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 93040f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: NTSC\n"); 931771fe6b9SJerome Glisse break; 932771fe6b9SJerome Glisse case 2: 933771fe6b9SJerome Glisse tv_std = TV_STD_PAL; 93440f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL\n"); 935771fe6b9SJerome Glisse break; 936771fe6b9SJerome Glisse case 3: 937771fe6b9SJerome Glisse tv_std = TV_STD_PAL_M; 93840f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL-M\n"); 939771fe6b9SJerome Glisse break; 940771fe6b9SJerome Glisse case 4: 941771fe6b9SJerome Glisse tv_std = TV_STD_PAL_60; 94240f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL-60\n"); 943771fe6b9SJerome Glisse break; 944771fe6b9SJerome Glisse case 5: 945771fe6b9SJerome Glisse tv_std = TV_STD_NTSC_J; 94640f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: NTSC-J\n"); 947771fe6b9SJerome Glisse break; 948771fe6b9SJerome Glisse case 6: 949771fe6b9SJerome Glisse tv_std = TV_STD_SCART_PAL; 95040f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: SCART-PAL\n"); 951771fe6b9SJerome Glisse break; 952771fe6b9SJerome Glisse default: 953771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 95440f76d81SAlex Deucher DRM_DEBUG_KMS 955771fe6b9SJerome Glisse ("Unknown TV standard; defaulting to NTSC\n"); 956771fe6b9SJerome Glisse break; 957771fe6b9SJerome Glisse } 958771fe6b9SJerome Glisse 959771fe6b9SJerome Glisse switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) { 960771fe6b9SJerome Glisse case 0: 96140f76d81SAlex Deucher DRM_DEBUG_KMS("29.498928713 MHz TV ref clk\n"); 962771fe6b9SJerome Glisse break; 963771fe6b9SJerome Glisse case 1: 96440f76d81SAlex Deucher DRM_DEBUG_KMS("28.636360000 MHz TV ref clk\n"); 965771fe6b9SJerome Glisse break; 966771fe6b9SJerome Glisse case 2: 96740f76d81SAlex Deucher DRM_DEBUG_KMS("14.318180000 MHz TV ref clk\n"); 968771fe6b9SJerome Glisse break; 969771fe6b9SJerome Glisse case 3: 97040f76d81SAlex Deucher DRM_DEBUG_KMS("27.000000000 MHz TV ref clk\n"); 971771fe6b9SJerome Glisse break; 972771fe6b9SJerome Glisse default: 973771fe6b9SJerome Glisse break; 974771fe6b9SJerome Glisse } 975771fe6b9SJerome Glisse } 976771fe6b9SJerome Glisse } 977771fe6b9SJerome Glisse return tv_std; 978771fe6b9SJerome Glisse } 979771fe6b9SJerome Glisse 980771fe6b9SJerome Glisse static const uint32_t default_tvdac_adj[CHIP_LAST] = { 981771fe6b9SJerome Glisse 0x00000000, /* r100 */ 982771fe6b9SJerome Glisse 0x00280000, /* rv100 */ 983771fe6b9SJerome Glisse 0x00000000, /* rs100 */ 984771fe6b9SJerome Glisse 0x00880000, /* rv200 */ 985771fe6b9SJerome Glisse 0x00000000, /* rs200 */ 986771fe6b9SJerome Glisse 0x00000000, /* r200 */ 987771fe6b9SJerome Glisse 0x00770000, /* rv250 */ 988771fe6b9SJerome Glisse 0x00290000, /* rs300 */ 989771fe6b9SJerome Glisse 0x00560000, /* rv280 */ 990771fe6b9SJerome Glisse 0x00780000, /* r300 */ 991771fe6b9SJerome Glisse 0x00770000, /* r350 */ 992771fe6b9SJerome Glisse 0x00780000, /* rv350 */ 993771fe6b9SJerome Glisse 0x00780000, /* rv380 */ 994771fe6b9SJerome Glisse 0x01080000, /* r420 */ 995771fe6b9SJerome Glisse 0x01080000, /* r423 */ 996771fe6b9SJerome Glisse 0x01080000, /* rv410 */ 997771fe6b9SJerome Glisse 0x00780000, /* rs400 */ 998771fe6b9SJerome Glisse 0x00780000, /* rs480 */ 999771fe6b9SJerome Glisse }; 1000771fe6b9SJerome Glisse 10016a719e05SDave Airlie static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev, 10026a719e05SDave Airlie struct radeon_encoder_tv_dac *tv_dac) 1003771fe6b9SJerome Glisse { 1004771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; 1005771fe6b9SJerome Glisse if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) 1006771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 0x00880000; 1007771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1008771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10096a719e05SDave Airlie return; 1010771fe6b9SJerome Glisse } 1011771fe6b9SJerome Glisse 1012771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct 1013771fe6b9SJerome Glisse radeon_encoder 1014771fe6b9SJerome Glisse *encoder) 1015771fe6b9SJerome Glisse { 1016771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1017771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1018771fe6b9SJerome Glisse uint16_t dac_info; 1019771fe6b9SJerome Glisse uint8_t rev, bg, dac; 1020771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *tv_dac = NULL; 10216a719e05SDave Airlie int found = 0; 10226a719e05SDave Airlie 10236a719e05SDave Airlie tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); 10246a719e05SDave Airlie if (!tv_dac) 10256a719e05SDave Airlie return NULL; 1026771fe6b9SJerome Glisse 1027771fe6b9SJerome Glisse /* first check TV table */ 1028771fe6b9SJerome Glisse dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 1029771fe6b9SJerome Glisse if (dac_info) { 1030771fe6b9SJerome Glisse rev = RBIOS8(dac_info + 0x3); 1031771fe6b9SJerome Glisse if (rev > 4) { 1032771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 1033771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xd) & 0xf; 1034771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 1035771fe6b9SJerome Glisse 1036771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 1037771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xf) & 0xf; 1038771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 1039771fe6b9SJerome Glisse 1040771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x10) & 0xf; 1041771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x11) & 0xf; 1042771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 10433a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10443a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10456a719e05SDave Airlie found = 1; 1046771fe6b9SJerome Glisse } else if (rev > 1) { 1047771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 1048771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; 1049771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 1050771fe6b9SJerome Glisse 1051771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xd) & 0xf; 1052771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf; 1053771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 1054771fe6b9SJerome Glisse 1055771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 1056771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; 1057771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 10583a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10593a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10606a719e05SDave Airlie found = 1; 1061771fe6b9SJerome Glisse } 1062d79766faSAlex Deucher tv_dac->tv_std = radeon_combios_get_tv_info(rdev); 10636a719e05SDave Airlie } 10646a719e05SDave Airlie if (!found) { 1065771fe6b9SJerome Glisse /* then check CRT table */ 1066771fe6b9SJerome Glisse dac_info = 1067771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 1068771fe6b9SJerome Glisse if (dac_info) { 1069771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 1070771fe6b9SJerome Glisse if (rev < 2) { 1071771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x3) & 0xf; 1072771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf; 1073771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 1074771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 1075771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1076771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10773a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10783a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10796a719e05SDave Airlie found = 1; 1080771fe6b9SJerome Glisse } else { 1081771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x4) & 0xf; 1082771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x5) & 0xf; 1083771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 1084771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 1085771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1086771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10873a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10883a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10896a719e05SDave Airlie found = 1; 1090771fe6b9SJerome Glisse } 10916fe7ac3fSAlex Deucher } else { 10926fe7ac3fSAlex Deucher DRM_INFO("No TV DAC info found in BIOS\n"); 1093771fe6b9SJerome Glisse } 1094771fe6b9SJerome Glisse } 1095771fe6b9SJerome Glisse 10966a719e05SDave Airlie if (!found) /* fallback to defaults */ 10976a719e05SDave Airlie radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac); 10986a719e05SDave Airlie 1099771fe6b9SJerome Glisse return tv_dac; 1100771fe6b9SJerome Glisse } 1101771fe6b9SJerome Glisse 1102771fe6b9SJerome Glisse static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct 1103771fe6b9SJerome Glisse radeon_device 1104771fe6b9SJerome Glisse *rdev) 1105771fe6b9SJerome Glisse { 1106771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 1107771fe6b9SJerome Glisse uint32_t fp_vert_stretch, fp_horz_stretch; 1108771fe6b9SJerome Glisse uint32_t ppll_div_sel, ppll_val; 11098b5c7444SMichel Dänzer uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL); 1110771fe6b9SJerome Glisse 1111771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 1112771fe6b9SJerome Glisse 1113771fe6b9SJerome Glisse if (!lvds) 1114771fe6b9SJerome Glisse return NULL; 1115771fe6b9SJerome Glisse 1116771fe6b9SJerome Glisse fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH); 1117771fe6b9SJerome Glisse fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH); 1118771fe6b9SJerome Glisse 11198b5c7444SMichel Dänzer /* These should be fail-safe defaults, fingers crossed */ 11208b5c7444SMichel Dänzer lvds->panel_pwr_delay = 200; 11218b5c7444SMichel Dänzer lvds->panel_vcc_delay = 2000; 11228b5c7444SMichel Dänzer 11238b5c7444SMichel Dänzer lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL); 11248b5c7444SMichel Dänzer lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf; 11258b5c7444SMichel Dänzer lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf; 11268b5c7444SMichel Dänzer 1127771fe6b9SJerome Glisse if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE) 1128de2103e4SAlex Deucher lvds->native_mode.vdisplay = 1129771fe6b9SJerome Glisse ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >> 1130771fe6b9SJerome Glisse RADEON_VERT_PANEL_SHIFT) + 1; 1131771fe6b9SJerome Glisse else 1132de2103e4SAlex Deucher lvds->native_mode.vdisplay = 1133771fe6b9SJerome Glisse (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1; 1134771fe6b9SJerome Glisse 1135771fe6b9SJerome Glisse if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE) 1136de2103e4SAlex Deucher lvds->native_mode.hdisplay = 1137771fe6b9SJerome Glisse (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >> 1138771fe6b9SJerome Glisse RADEON_HORZ_PANEL_SHIFT) + 1) * 8; 1139771fe6b9SJerome Glisse else 1140de2103e4SAlex Deucher lvds->native_mode.hdisplay = 1141771fe6b9SJerome Glisse ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8; 1142771fe6b9SJerome Glisse 1143de2103e4SAlex Deucher if ((lvds->native_mode.hdisplay < 640) || 1144de2103e4SAlex Deucher (lvds->native_mode.vdisplay < 480)) { 1145de2103e4SAlex Deucher lvds->native_mode.hdisplay = 640; 1146de2103e4SAlex Deucher lvds->native_mode.vdisplay = 480; 1147771fe6b9SJerome Glisse } 1148771fe6b9SJerome Glisse 1149771fe6b9SJerome Glisse ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3; 1150771fe6b9SJerome Glisse ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel); 1151771fe6b9SJerome Glisse if ((ppll_val & 0x000707ff) == 0x1bb) 1152771fe6b9SJerome Glisse lvds->use_bios_dividers = false; 1153771fe6b9SJerome Glisse else { 1154771fe6b9SJerome Glisse lvds->panel_ref_divider = 1155771fe6b9SJerome Glisse RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff; 1156771fe6b9SJerome Glisse lvds->panel_post_divider = (ppll_val >> 16) & 0x7; 1157771fe6b9SJerome Glisse lvds->panel_fb_divider = ppll_val & 0x7ff; 1158771fe6b9SJerome Glisse 1159771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1160771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1161771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1162771fe6b9SJerome Glisse } 1163771fe6b9SJerome Glisse lvds->panel_vcc_delay = 200; 1164771fe6b9SJerome Glisse 1165771fe6b9SJerome Glisse DRM_INFO("Panel info derived from registers\n"); 1166de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1167de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1168771fe6b9SJerome Glisse 1169771fe6b9SJerome Glisse return lvds; 1170771fe6b9SJerome Glisse } 1171771fe6b9SJerome Glisse 1172771fe6b9SJerome Glisse struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder 1173771fe6b9SJerome Glisse *encoder) 1174771fe6b9SJerome Glisse { 1175771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1176771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1177771fe6b9SJerome Glisse uint16_t lcd_info; 1178771fe6b9SJerome Glisse uint32_t panel_setup; 1179771fe6b9SJerome Glisse char stmp[30]; 1180771fe6b9SJerome Glisse int tmp, i; 1181771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 1182771fe6b9SJerome Glisse 1183771fe6b9SJerome Glisse lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 1184771fe6b9SJerome Glisse 1185771fe6b9SJerome Glisse if (lcd_info) { 1186771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 1187771fe6b9SJerome Glisse 1188771fe6b9SJerome Glisse if (!lvds) 1189771fe6b9SJerome Glisse return NULL; 1190771fe6b9SJerome Glisse 1191771fe6b9SJerome Glisse for (i = 0; i < 24; i++) 1192771fe6b9SJerome Glisse stmp[i] = RBIOS8(lcd_info + i + 1); 1193771fe6b9SJerome Glisse stmp[24] = 0; 1194771fe6b9SJerome Glisse 1195771fe6b9SJerome Glisse DRM_INFO("Panel ID String: %s\n", stmp); 1196771fe6b9SJerome Glisse 1197de2103e4SAlex Deucher lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19); 1198de2103e4SAlex Deucher lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b); 1199771fe6b9SJerome Glisse 1200de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1201de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1202771fe6b9SJerome Glisse 1203771fe6b9SJerome Glisse lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c); 120494cf6434SAndrew Morton lvds->panel_vcc_delay = min_t(u16, lvds->panel_vcc_delay, 2000); 1205771fe6b9SJerome Glisse 1206771fe6b9SJerome Glisse lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24); 1207771fe6b9SJerome Glisse lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf; 1208771fe6b9SJerome Glisse lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf; 1209771fe6b9SJerome Glisse 1210771fe6b9SJerome Glisse lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e); 1211771fe6b9SJerome Glisse lvds->panel_post_divider = RBIOS8(lcd_info + 0x30); 1212771fe6b9SJerome Glisse lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31); 1213771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1214771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1215771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1216771fe6b9SJerome Glisse 1217771fe6b9SJerome Glisse panel_setup = RBIOS32(lcd_info + 0x39); 1218771fe6b9SJerome Glisse lvds->lvds_gen_cntl = 0xff00; 1219771fe6b9SJerome Glisse if (panel_setup & 0x1) 1220771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT; 1221771fe6b9SJerome Glisse 1222771fe6b9SJerome Glisse if ((panel_setup >> 4) & 0x1) 1223771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE; 1224771fe6b9SJerome Glisse 1225771fe6b9SJerome Glisse switch ((panel_setup >> 8) & 0x7) { 1226771fe6b9SJerome Glisse case 0: 1227771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM; 1228771fe6b9SJerome Glisse break; 1229771fe6b9SJerome Glisse case 1: 1230771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY; 1231771fe6b9SJerome Glisse break; 1232771fe6b9SJerome Glisse case 2: 1233771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY; 1234771fe6b9SJerome Glisse break; 1235771fe6b9SJerome Glisse default: 1236771fe6b9SJerome Glisse break; 1237771fe6b9SJerome Glisse } 1238771fe6b9SJerome Glisse 1239771fe6b9SJerome Glisse if ((panel_setup >> 16) & 0x1) 1240771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW; 1241771fe6b9SJerome Glisse 1242771fe6b9SJerome Glisse if ((panel_setup >> 17) & 0x1) 1243771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW; 1244771fe6b9SJerome Glisse 1245771fe6b9SJerome Glisse if ((panel_setup >> 18) & 0x1) 1246771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW; 1247771fe6b9SJerome Glisse 1248771fe6b9SJerome Glisse if ((panel_setup >> 23) & 0x1) 1249771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL; 1250771fe6b9SJerome Glisse 1251771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000); 1252771fe6b9SJerome Glisse 1253771fe6b9SJerome Glisse for (i = 0; i < 32; i++) { 1254771fe6b9SJerome Glisse tmp = RBIOS16(lcd_info + 64 + i * 2); 1255771fe6b9SJerome Glisse if (tmp == 0) 1256771fe6b9SJerome Glisse break; 1257771fe6b9SJerome Glisse 1258de2103e4SAlex Deucher if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) && 125968b61a7fSAlex Deucher (RBIOS16(tmp + 2) == lvds->native_mode.vdisplay)) { 126068b61a7fSAlex Deucher lvds->native_mode.htotal = lvds->native_mode.hdisplay + 126168b61a7fSAlex Deucher (RBIOS16(tmp + 17) - RBIOS16(tmp + 19)) * 8; 126268b61a7fSAlex Deucher lvds->native_mode.hsync_start = lvds->native_mode.hdisplay + 126368b61a7fSAlex Deucher (RBIOS16(tmp + 21) - RBIOS16(tmp + 19) - 1) * 8; 126468b61a7fSAlex Deucher lvds->native_mode.hsync_end = lvds->native_mode.hsync_start + 126568b61a7fSAlex Deucher (RBIOS8(tmp + 23) * 8); 1266771fe6b9SJerome Glisse 126768b61a7fSAlex Deucher lvds->native_mode.vtotal = lvds->native_mode.vdisplay + 126868b61a7fSAlex Deucher (RBIOS16(tmp + 24) - RBIOS16(tmp + 26)); 126968b61a7fSAlex Deucher lvds->native_mode.vsync_start = lvds->native_mode.vdisplay + 127068b61a7fSAlex Deucher ((RBIOS16(tmp + 28) & 0x7ff) - RBIOS16(tmp + 26)); 127168b61a7fSAlex Deucher lvds->native_mode.vsync_end = lvds->native_mode.vsync_start + 127268b61a7fSAlex Deucher ((RBIOS16(tmp + 28) & 0xf800) >> 11); 1273de2103e4SAlex Deucher 1274de2103e4SAlex Deucher lvds->native_mode.clock = RBIOS16(tmp + 9) * 10; 1275771fe6b9SJerome Glisse lvds->native_mode.flags = 0; 1276de2103e4SAlex Deucher /* set crtc values */ 1277de2103e4SAlex Deucher drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V); 1278de2103e4SAlex Deucher 1279771fe6b9SJerome Glisse } 1280771fe6b9SJerome Glisse } 12816fe7ac3fSAlex Deucher } else { 1282771fe6b9SJerome Glisse DRM_INFO("No panel info found in BIOS\n"); 12838dfaa8a7SMichel Dänzer lvds = radeon_legacy_get_lvds_info_from_regs(rdev); 12846fe7ac3fSAlex Deucher } 128503047cdfSMichel Dänzer 12868dfaa8a7SMichel Dänzer if (lvds) 12878dfaa8a7SMichel Dänzer encoder->native_mode = lvds->native_mode; 1288771fe6b9SJerome Glisse return lvds; 1289771fe6b9SJerome Glisse } 1290771fe6b9SJerome Glisse 1291771fe6b9SJerome Glisse static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = { 1292771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */ 1293771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */ 1294771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */ 1295771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */ 1296771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */ 1297771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */ 1298771fe6b9SJerome Glisse {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */ 1299771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */ 1300771fe6b9SJerome Glisse {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */ 1301771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */ 1302771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */ 1303771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */ 1304771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */ 1305771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */ 1306771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */ 1307771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */ 1308fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */ 1309fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */ 1310771fe6b9SJerome Glisse }; 1311771fe6b9SJerome Glisse 1312445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder, 1313445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1314771fe6b9SJerome Glisse { 1315445282dbSDave Airlie struct drm_device *dev = encoder->base.dev; 1316445282dbSDave Airlie struct radeon_device *rdev = dev->dev_private; 1317771fe6b9SJerome Glisse int i; 1318771fe6b9SJerome Glisse 1319771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 1320771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1321771fe6b9SJerome Glisse default_tmds_pll[rdev->family][i].value; 1322771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq; 1323771fe6b9SJerome Glisse } 1324771fe6b9SJerome Glisse 1325445282dbSDave Airlie return true; 1326771fe6b9SJerome Glisse } 1327771fe6b9SJerome Glisse 1328445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder, 1329445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1330771fe6b9SJerome Glisse { 1331771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1332771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1333771fe6b9SJerome Glisse uint16_t tmds_info; 1334771fe6b9SJerome Glisse int i, n; 1335771fe6b9SJerome Glisse uint8_t ver; 1336771fe6b9SJerome Glisse 1337771fe6b9SJerome Glisse tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 1338771fe6b9SJerome Glisse 1339771fe6b9SJerome Glisse if (tmds_info) { 1340771fe6b9SJerome Glisse ver = RBIOS8(tmds_info); 134140f76d81SAlex Deucher DRM_DEBUG_KMS("DFP table revision: %d\n", ver); 1342771fe6b9SJerome Glisse if (ver == 3) { 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 + i * 10 + 0x08); 1349771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1350771fe6b9SJerome Glisse RBIOS16(tmds_info + i * 10 + 0x10); 1351d9fdaafbSDave Airlie DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", 1352771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1353771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1354771fe6b9SJerome Glisse } 1355771fe6b9SJerome Glisse } else if (ver == 4) { 1356771fe6b9SJerome Glisse int stride = 0; 1357771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1358771fe6b9SJerome Glisse if (n > 4) 1359771fe6b9SJerome Glisse n = 4; 1360771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1361771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1362771fe6b9SJerome Glisse RBIOS32(tmds_info + stride + 0x08); 1363771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1364771fe6b9SJerome Glisse RBIOS16(tmds_info + stride + 0x10); 1365771fe6b9SJerome Glisse if (i == 0) 1366771fe6b9SJerome Glisse stride += 10; 1367771fe6b9SJerome Glisse else 1368771fe6b9SJerome Glisse stride += 6; 1369d9fdaafbSDave Airlie DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", 1370771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1371771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1372771fe6b9SJerome Glisse } 1373771fe6b9SJerome Glisse } 1374fcec570bSAlex Deucher } else { 1375771fe6b9SJerome Glisse DRM_INFO("No TMDS info found in BIOS\n"); 1376fcec570bSAlex Deucher return false; 1377fcec570bSAlex Deucher } 1378445282dbSDave Airlie return true; 1379445282dbSDave Airlie } 1380445282dbSDave Airlie 1381fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder, 1382fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1383771fe6b9SJerome Glisse { 1384771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1385771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1386fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1387fcec570bSAlex Deucher 1388fcec570bSAlex Deucher /* default for macs */ 1389179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1390f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1391fcec570bSAlex Deucher 1392fcec570bSAlex Deucher /* XXX some macs have duallink chips */ 1393fcec570bSAlex Deucher switch (rdev->mode_info.connector_table) { 1394fcec570bSAlex Deucher case CT_POWERBOOK_EXTERNAL: 1395fcec570bSAlex Deucher case CT_MINI_EXTERNAL: 1396fcec570bSAlex Deucher default: 1397fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1398fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1399fcec570bSAlex Deucher break; 1400fcec570bSAlex Deucher } 1401fcec570bSAlex Deucher 1402fcec570bSAlex Deucher return true; 1403fcec570bSAlex Deucher } 1404fcec570bSAlex Deucher 1405fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder, 1406fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1407fcec570bSAlex Deucher { 1408fcec570bSAlex Deucher struct drm_device *dev = encoder->base.dev; 1409fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 1410fcec570bSAlex Deucher uint16_t offset; 1411179e8078SAlex Deucher uint8_t ver; 1412fcec570bSAlex Deucher enum radeon_combios_ddc gpio; 1413fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1414771fe6b9SJerome Glisse 1415fcec570bSAlex Deucher tmds->i2c_bus = NULL; 1416fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 1417179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1418f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1419fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1420fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1421fcec570bSAlex Deucher } else { 1422fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 1423fcec570bSAlex Deucher if (offset) { 1424fcec570bSAlex Deucher ver = RBIOS8(offset); 142540f76d81SAlex Deucher DRM_DEBUG_KMS("External TMDS Table revision: %d\n", ver); 1426fcec570bSAlex Deucher tmds->slave_addr = RBIOS8(offset + 4 + 2); 1427fcec570bSAlex Deucher tmds->slave_addr >>= 1; /* 7 bit addressing */ 1428fcec570bSAlex Deucher gpio = RBIOS8(offset + 4 + 3); 1429179e8078SAlex Deucher if (gpio == DDC_LCD) { 1430179e8078SAlex Deucher /* MM i2c */ 143140bacf16SAlex Deucher i2c_bus.valid = true; 143240bacf16SAlex Deucher i2c_bus.hw_capable = true; 143340bacf16SAlex Deucher i2c_bus.mm_i2c = true; 1434179e8078SAlex Deucher i2c_bus.i2c_id = 0xa0; 1435179e8078SAlex Deucher } else 1436179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0); 1437f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1438fcec570bSAlex Deucher } 1439fcec570bSAlex Deucher } 1440fcec570bSAlex Deucher 1441fcec570bSAlex Deucher if (!tmds->i2c_bus) { 1442fcec570bSAlex Deucher DRM_INFO("No valid Ext TMDS info found in BIOS\n"); 1443fcec570bSAlex Deucher return false; 1444fcec570bSAlex Deucher } 1445fcec570bSAlex Deucher 1446fcec570bSAlex Deucher return true; 1447fcec570bSAlex Deucher } 1448771fe6b9SJerome Glisse 1449771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) 1450771fe6b9SJerome Glisse { 1451771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1452771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 1453eed45b30SAlex Deucher struct radeon_hpd hpd; 1454771fe6b9SJerome Glisse 1455771fe6b9SJerome Glisse rdev->mode_info.connector_table = radeon_connector_table; 1456771fe6b9SJerome Glisse if (rdev->mode_info.connector_table == CT_NONE) { 1457771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 145871a157e8SGrant Likely if (of_machine_is_compatible("PowerBook3,3")) { 1459771fe6b9SJerome Glisse /* powerbook with VGA */ 1460771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_VGA; 146171a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook3,4") || 146271a157e8SGrant Likely of_machine_is_compatible("PowerBook3,5")) { 1463771fe6b9SJerome Glisse /* powerbook with internal tmds */ 1464771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; 146571a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,1") || 146671a157e8SGrant Likely of_machine_is_compatible("PowerBook5,2") || 146771a157e8SGrant Likely of_machine_is_compatible("PowerBook5,3") || 146871a157e8SGrant Likely of_machine_is_compatible("PowerBook5,4") || 146971a157e8SGrant Likely of_machine_is_compatible("PowerBook5,5")) { 1470771fe6b9SJerome Glisse /* powerbook with external single link tmds (sil164) */ 1471771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 147271a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,6")) { 1473771fe6b9SJerome Glisse /* powerbook with external dual or single link tmds */ 1474771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 147571a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,7") || 147671a157e8SGrant Likely of_machine_is_compatible("PowerBook5,8") || 147771a157e8SGrant Likely of_machine_is_compatible("PowerBook5,9")) { 1478771fe6b9SJerome Glisse /* PowerBook6,2 ? */ 1479771fe6b9SJerome Glisse /* powerbook with external dual link tmds (sil1178?) */ 1480771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 148171a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook4,1") || 148271a157e8SGrant Likely of_machine_is_compatible("PowerBook4,2") || 148371a157e8SGrant Likely of_machine_is_compatible("PowerBook4,3") || 148471a157e8SGrant Likely of_machine_is_compatible("PowerBook6,3") || 148571a157e8SGrant Likely of_machine_is_compatible("PowerBook6,5") || 148671a157e8SGrant Likely of_machine_is_compatible("PowerBook6,7")) { 1487771fe6b9SJerome Glisse /* ibook */ 1488771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IBOOK; 148971a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac4,4")) { 1490771fe6b9SJerome Glisse /* emac */ 1491771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_EMAC; 149271a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac10,1")) { 1493771fe6b9SJerome Glisse /* mini with internal tmds */ 1494771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_INTERNAL; 149571a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac10,2")) { 1496771fe6b9SJerome Glisse /* mini with external tmds */ 1497771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_EXTERNAL; 149871a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac12,1")) { 1499771fe6b9SJerome Glisse /* PowerMac8,1 ? */ 1500771fe6b9SJerome Glisse /* imac g5 isight */ 1501771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; 1502aa74fbb4SAlex Deucher } else if ((rdev->pdev->device == 0x4a48) && 1503aa74fbb4SAlex Deucher (rdev->pdev->subsystem_vendor == 0x1002) && 1504aa74fbb4SAlex Deucher (rdev->pdev->subsystem_device == 0x4a48)) { 1505aa74fbb4SAlex Deucher /* Mac X800 */ 1506aa74fbb4SAlex Deucher rdev->mode_info.connector_table = CT_MAC_X800; 1507771fe6b9SJerome Glisse } else 1508771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 150976a7142aSDave Airlie #ifdef CONFIG_PPC64 151076a7142aSDave Airlie if (ASIC_IS_RN50(rdev)) 151176a7142aSDave Airlie rdev->mode_info.connector_table = CT_RN50_POWER; 151276a7142aSDave Airlie else 151376a7142aSDave Airlie #endif 1514771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_GENERIC; 1515771fe6b9SJerome Glisse } 1516771fe6b9SJerome Glisse 1517771fe6b9SJerome Glisse switch (rdev->mode_info.connector_table) { 1518771fe6b9SJerome Glisse case CT_GENERIC: 1519771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (generic)\n", 1520771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1521771fe6b9SJerome Glisse /* these are the most common settings */ 1522771fe6b9SJerome Glisse if (rdev->flags & RADEON_SINGLE_CRTC) { 1523771fe6b9SJerome Glisse /* VGA - primary dac */ 1524179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1525eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1526771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15275137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1528771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1529771fe6b9SJerome Glisse 1), 1530771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1531771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1532771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1533771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1534b75fad06SAlex Deucher &ddc_i2c, 1535eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1536eed45b30SAlex Deucher &hpd); 1537771fe6b9SJerome Glisse } else if (rdev->flags & RADEON_IS_MOBILITY) { 1538771fe6b9SJerome Glisse /* LVDS */ 1539179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_NONE_DETECTED, 0, 0); 1540eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1541771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15425137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1543771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1544771fe6b9SJerome Glisse 0), 1545771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1546771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1547771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1548771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 1549b75fad06SAlex Deucher &ddc_i2c, 1550eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1551eed45b30SAlex Deucher &hpd); 1552771fe6b9SJerome Glisse 1553771fe6b9SJerome Glisse /* VGA - primary dac */ 1554179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1555eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1556771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15575137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1558771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1559771fe6b9SJerome Glisse 1), 1560771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1561771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1562771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1563771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1564b75fad06SAlex Deucher &ddc_i2c, 1565eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1566eed45b30SAlex Deucher &hpd); 1567771fe6b9SJerome Glisse } else { 1568771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1569179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1570eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 1571771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15725137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1573771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1574771fe6b9SJerome Glisse 0), 1575771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1576771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15775137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1578771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1579771fe6b9SJerome Glisse 2), 1580771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1581771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1582771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1583771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1584771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 1585b75fad06SAlex Deucher &ddc_i2c, 1586eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1587eed45b30SAlex Deucher &hpd); 1588771fe6b9SJerome Glisse 1589771fe6b9SJerome Glisse /* VGA - primary dac */ 1590179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1591eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1592771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15935137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1594771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1595771fe6b9SJerome Glisse 1), 1596771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1597771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1598771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1599771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1600b75fad06SAlex Deucher &ddc_i2c, 1601eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1602eed45b30SAlex Deucher &hpd); 1603771fe6b9SJerome Glisse } 1604771fe6b9SJerome Glisse 1605771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 1606771fe6b9SJerome Glisse /* TV - tv dac */ 1607eed45b30SAlex Deucher ddc_i2c.valid = false; 1608eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1609771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16105137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1611771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1612771fe6b9SJerome Glisse 2), 1613771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1614771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, 1615771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1616771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1617b75fad06SAlex Deucher &ddc_i2c, 1618eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1619eed45b30SAlex Deucher &hpd); 1620771fe6b9SJerome Glisse } 1621771fe6b9SJerome Glisse break; 1622771fe6b9SJerome Glisse case CT_IBOOK: 1623771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (ibook)\n", 1624771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1625771fe6b9SJerome Glisse /* LVDS */ 1626179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1627eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1628771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16295137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1630771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1631771fe6b9SJerome Glisse 0), 1632771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1633771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1634b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1635eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1636eed45b30SAlex Deucher &hpd); 1637771fe6b9SJerome Glisse /* VGA - TV DAC */ 1638179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1639eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1640771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16415137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1642771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1643771fe6b9SJerome Glisse 2), 1644771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1645771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1646b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1647eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1648eed45b30SAlex Deucher &hpd); 1649771fe6b9SJerome Glisse /* TV - TV DAC */ 1650eed45b30SAlex Deucher ddc_i2c.valid = false; 1651eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1652771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16535137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1654771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1655771fe6b9SJerome Glisse 2), 1656771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1657771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1658771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1659b75fad06SAlex Deucher &ddc_i2c, 1660eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1661eed45b30SAlex Deucher &hpd); 1662771fe6b9SJerome Glisse break; 1663771fe6b9SJerome Glisse case CT_POWERBOOK_EXTERNAL: 1664771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook external tmds)\n", 1665771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1666771fe6b9SJerome Glisse /* LVDS */ 1667179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1668eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1669771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16705137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1671771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1672771fe6b9SJerome Glisse 0), 1673771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1674771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1675b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1676eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1677eed45b30SAlex Deucher &hpd); 1678771fe6b9SJerome Glisse /* DVI-I - primary dac, ext tmds */ 1679179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1680eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1681771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16825137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1683771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1684771fe6b9SJerome Glisse 0), 1685771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1686771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16875137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1688771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1689771fe6b9SJerome Glisse 1), 1690771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1691b75fad06SAlex Deucher /* XXX some are SL */ 1692771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1693771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1694771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1695b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1696eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 1697eed45b30SAlex Deucher &hpd); 1698771fe6b9SJerome Glisse /* TV - TV DAC */ 1699eed45b30SAlex Deucher ddc_i2c.valid = false; 1700eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1701771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17025137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1703771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1704771fe6b9SJerome Glisse 2), 1705771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1706771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1707771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1708b75fad06SAlex Deucher &ddc_i2c, 1709eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1710eed45b30SAlex Deucher &hpd); 1711771fe6b9SJerome Glisse break; 1712771fe6b9SJerome Glisse case CT_POWERBOOK_INTERNAL: 1713771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook internal tmds)\n", 1714771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1715771fe6b9SJerome Glisse /* LVDS */ 1716179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1717eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1718771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17195137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1720771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1721771fe6b9SJerome Glisse 0), 1722771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1723771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1724b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1725eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1726eed45b30SAlex Deucher &hpd); 1727771fe6b9SJerome Glisse /* DVI-I - primary dac, int tmds */ 1728179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1729eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1730771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17315137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1732771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1733771fe6b9SJerome Glisse 0), 1734771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1735771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17365137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1737771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1738771fe6b9SJerome Glisse 1), 1739771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1740771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1741771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1742771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1743b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1744eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1745eed45b30SAlex Deucher &hpd); 1746771fe6b9SJerome Glisse /* TV - TV DAC */ 1747eed45b30SAlex Deucher ddc_i2c.valid = false; 1748eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1749771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17505137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1751771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1752771fe6b9SJerome Glisse 2), 1753771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1754771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1755771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1756b75fad06SAlex Deucher &ddc_i2c, 1757eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1758eed45b30SAlex Deucher &hpd); 1759771fe6b9SJerome Glisse break; 1760771fe6b9SJerome Glisse case CT_POWERBOOK_VGA: 1761771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook vga)\n", 1762771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1763771fe6b9SJerome Glisse /* LVDS */ 1764179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1765eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1766771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17675137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1768771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1769771fe6b9SJerome Glisse 0), 1770771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1771771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1772b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1773eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1774eed45b30SAlex Deucher &hpd); 1775771fe6b9SJerome Glisse /* VGA - primary dac */ 1776179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1777eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1778771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17795137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1780771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1781771fe6b9SJerome Glisse 1), 1782771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1783771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT, 1784b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1785eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1786eed45b30SAlex Deucher &hpd); 1787771fe6b9SJerome Glisse /* TV - TV DAC */ 1788eed45b30SAlex Deucher ddc_i2c.valid = false; 1789eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1790771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17915137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1792771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1793771fe6b9SJerome Glisse 2), 1794771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1795771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1796771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1797b75fad06SAlex Deucher &ddc_i2c, 1798eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1799eed45b30SAlex Deucher &hpd); 1800771fe6b9SJerome Glisse break; 1801771fe6b9SJerome Glisse case CT_MINI_EXTERNAL: 1802771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini external tmds)\n", 1803771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1804771fe6b9SJerome Glisse /* DVI-I - tv dac, ext tmds */ 1805179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1806eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1807771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18085137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1809771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1810771fe6b9SJerome Glisse 0), 1811771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1812771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18135137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1814771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1815771fe6b9SJerome Glisse 2), 1816771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1817b75fad06SAlex Deucher /* XXX are any DL? */ 1818771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1819771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1820771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1821b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1822eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1823eed45b30SAlex Deucher &hpd); 1824771fe6b9SJerome Glisse /* TV - TV DAC */ 1825eed45b30SAlex Deucher ddc_i2c.valid = false; 1826eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1827771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18285137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1829771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1830771fe6b9SJerome Glisse 2), 1831771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1832771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1833771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1834b75fad06SAlex Deucher &ddc_i2c, 1835eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1836eed45b30SAlex Deucher &hpd); 1837771fe6b9SJerome Glisse break; 1838771fe6b9SJerome Glisse case CT_MINI_INTERNAL: 1839771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini internal tmds)\n", 1840771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1841771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1842179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1843eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1844771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18455137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1846771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1847771fe6b9SJerome Glisse 0), 1848771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1849771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18505137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1851771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1852771fe6b9SJerome Glisse 2), 1853771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1854771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1855771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1856771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1857b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1858eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1859eed45b30SAlex Deucher &hpd); 1860771fe6b9SJerome Glisse /* TV - TV DAC */ 1861eed45b30SAlex Deucher ddc_i2c.valid = false; 1862eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1863771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18645137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1865771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1866771fe6b9SJerome Glisse 2), 1867771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1868771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1869771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1870b75fad06SAlex Deucher &ddc_i2c, 1871eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1872eed45b30SAlex Deucher &hpd); 1873771fe6b9SJerome Glisse break; 1874771fe6b9SJerome Glisse case CT_IMAC_G5_ISIGHT: 1875771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (imac g5 isight)\n", 1876771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1877771fe6b9SJerome Glisse /* DVI-D - int tmds */ 1878179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1879eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1880771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18815137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1882771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1883771fe6b9SJerome Glisse 0), 1884771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1885771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT, 1886b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVID, &ddc_i2c, 1887eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 1888eed45b30SAlex Deucher &hpd); 1889771fe6b9SJerome Glisse /* VGA - tv dac */ 1890179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1891eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1892771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18935137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1894771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1895771fe6b9SJerome Glisse 2), 1896771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1897771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1898b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1899eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1900eed45b30SAlex Deucher &hpd); 1901771fe6b9SJerome Glisse /* TV - TV DAC */ 1902eed45b30SAlex Deucher ddc_i2c.valid = false; 1903eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1904771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19055137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1906771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1907771fe6b9SJerome Glisse 2), 1908771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1909771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1910771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1911b75fad06SAlex Deucher &ddc_i2c, 1912eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1913eed45b30SAlex Deucher &hpd); 1914771fe6b9SJerome Glisse break; 1915771fe6b9SJerome Glisse case CT_EMAC: 1916771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (emac)\n", 1917771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1918771fe6b9SJerome Glisse /* VGA - primary dac */ 1919179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1920eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1921771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19225137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1923771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1924771fe6b9SJerome Glisse 1), 1925771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1926771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 1927b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1928eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1929eed45b30SAlex Deucher &hpd); 1930771fe6b9SJerome Glisse /* VGA - tv dac */ 1931179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1932eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1933771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19345137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1935771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1936771fe6b9SJerome Glisse 2), 1937771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1938771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1939b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1940eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1941eed45b30SAlex Deucher &hpd); 1942771fe6b9SJerome Glisse /* TV - TV DAC */ 1943eed45b30SAlex Deucher ddc_i2c.valid = false; 1944eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1945771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19465137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1947771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1948771fe6b9SJerome Glisse 2), 1949771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1950771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1951771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1952b75fad06SAlex Deucher &ddc_i2c, 1953eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1954eed45b30SAlex Deucher &hpd); 1955771fe6b9SJerome Glisse break; 195676a7142aSDave Airlie case CT_RN50_POWER: 195776a7142aSDave Airlie DRM_INFO("Connector Table: %d (rn50-power)\n", 195876a7142aSDave Airlie rdev->mode_info.connector_table); 195976a7142aSDave Airlie /* VGA - primary dac */ 1960179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 196176a7142aSDave Airlie hpd.hpd = RADEON_HPD_NONE; 196276a7142aSDave Airlie radeon_add_legacy_encoder(dev, 19635137ee94SAlex Deucher radeon_get_encoder_enum(dev, 196476a7142aSDave Airlie ATOM_DEVICE_CRT1_SUPPORT, 196576a7142aSDave Airlie 1), 196676a7142aSDave Airlie ATOM_DEVICE_CRT1_SUPPORT); 196776a7142aSDave Airlie radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 196876a7142aSDave Airlie DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 196976a7142aSDave Airlie CONNECTOR_OBJECT_ID_VGA, 197076a7142aSDave Airlie &hpd); 1971179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 197276a7142aSDave Airlie hpd.hpd = RADEON_HPD_NONE; 197376a7142aSDave Airlie radeon_add_legacy_encoder(dev, 19745137ee94SAlex Deucher radeon_get_encoder_enum(dev, 197576a7142aSDave Airlie ATOM_DEVICE_CRT2_SUPPORT, 197676a7142aSDave Airlie 2), 197776a7142aSDave Airlie ATOM_DEVICE_CRT2_SUPPORT); 197876a7142aSDave Airlie radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 197976a7142aSDave Airlie DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 198076a7142aSDave Airlie CONNECTOR_OBJECT_ID_VGA, 198176a7142aSDave Airlie &hpd); 198276a7142aSDave Airlie break; 1983aa74fbb4SAlex Deucher case CT_MAC_X800: 1984aa74fbb4SAlex Deucher DRM_INFO("Connector Table: %d (mac x800)\n", 1985aa74fbb4SAlex Deucher rdev->mode_info.connector_table); 1986aa74fbb4SAlex Deucher /* DVI - primary dac, internal tmds */ 1987aa74fbb4SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1988aa74fbb4SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1989aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 1990aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 1991aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 1992aa74fbb4SAlex Deucher 0), 1993aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 1994aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 1995aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 1996aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 1997aa74fbb4SAlex Deucher 1), 1998aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 1999aa74fbb4SAlex Deucher radeon_add_legacy_connector(dev, 0, 2000aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 2001aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2002aa74fbb4SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 2003aa74fbb4SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2004aa74fbb4SAlex Deucher &hpd); 2005aa74fbb4SAlex Deucher /* DVI - tv dac, dvo */ 2006aa74fbb4SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 2007aa74fbb4SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 2008aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2009aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2010aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT, 2011aa74fbb4SAlex Deucher 0), 2012aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT); 2013aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2014aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2015aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2016aa74fbb4SAlex Deucher 2), 2017aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 2018aa74fbb4SAlex Deucher radeon_add_legacy_connector(dev, 1, 2019aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT | 2020aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2021aa74fbb4SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 2022aa74fbb4SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 2023aa74fbb4SAlex Deucher &hpd); 2024aa74fbb4SAlex Deucher break; 2025771fe6b9SJerome Glisse default: 2026771fe6b9SJerome Glisse DRM_INFO("Connector table: %d (invalid)\n", 2027771fe6b9SJerome Glisse rdev->mode_info.connector_table); 2028771fe6b9SJerome Glisse return false; 2029771fe6b9SJerome Glisse } 2030771fe6b9SJerome Glisse 2031771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2032771fe6b9SJerome Glisse 2033771fe6b9SJerome Glisse return true; 2034771fe6b9SJerome Glisse } 2035771fe6b9SJerome Glisse 2036771fe6b9SJerome Glisse static bool radeon_apply_legacy_quirks(struct drm_device *dev, 2037771fe6b9SJerome Glisse int bios_index, 2038771fe6b9SJerome Glisse enum radeon_combios_connector 2039771fe6b9SJerome Glisse *legacy_connector, 2040eed45b30SAlex Deucher struct radeon_i2c_bus_rec *ddc_i2c, 2041eed45b30SAlex Deucher struct radeon_hpd *hpd) 2042771fe6b9SJerome Glisse { 2043fcec570bSAlex Deucher 2044771fe6b9SJerome Glisse /* Certain IBM chipset RN50s have a BIOS reporting two VGAs, 2045771fe6b9SJerome Glisse one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */ 2046771fe6b9SJerome Glisse if (dev->pdev->device == 0x515e && 2047771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x1014) { 2048771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_CRT_LEGACY && 2049771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 2050771fe6b9SJerome Glisse return false; 2051771fe6b9SJerome Glisse } 2052771fe6b9SJerome Glisse 2053771fe6b9SJerome Glisse /* X300 card with extra non-existent DVI port */ 2054771fe6b9SJerome Glisse if (dev->pdev->device == 0x5B60 && 2055771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x17af && 2056771fe6b9SJerome Glisse dev->pdev->subsystem_device == 0x201e && bios_index == 2) { 2057771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_DVI_I_LEGACY) 2058771fe6b9SJerome Glisse return false; 2059771fe6b9SJerome Glisse } 2060771fe6b9SJerome Glisse 2061771fe6b9SJerome Glisse return true; 2062771fe6b9SJerome Glisse } 2063771fe6b9SJerome Glisse 2064790cfb34SAlex Deucher static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev) 2065790cfb34SAlex Deucher { 2066790cfb34SAlex Deucher /* Acer 5102 has non-existent TV port */ 2067790cfb34SAlex Deucher if (dev->pdev->device == 0x5975 && 2068790cfb34SAlex Deucher dev->pdev->subsystem_vendor == 0x1025 && 2069790cfb34SAlex Deucher dev->pdev->subsystem_device == 0x009f) 2070790cfb34SAlex Deucher return false; 2071790cfb34SAlex Deucher 2072fc7f7119SAlex Deucher /* HP dc5750 has non-existent TV port */ 2073fc7f7119SAlex Deucher if (dev->pdev->device == 0x5974 && 2074fc7f7119SAlex Deucher dev->pdev->subsystem_vendor == 0x103c && 2075fc7f7119SAlex Deucher dev->pdev->subsystem_device == 0x280a) 2076fc7f7119SAlex Deucher return false; 2077fc7f7119SAlex Deucher 2078fd874ad0SAlex Deucher /* MSI S270 has non-existent TV port */ 2079fd874ad0SAlex Deucher if (dev->pdev->device == 0x5955 && 2080fd874ad0SAlex Deucher dev->pdev->subsystem_vendor == 0x1462 && 2081fd874ad0SAlex Deucher dev->pdev->subsystem_device == 0x0131) 2082fd874ad0SAlex Deucher return false; 2083fd874ad0SAlex Deucher 2084790cfb34SAlex Deucher return true; 2085790cfb34SAlex Deucher } 2086790cfb34SAlex Deucher 2087b75fad06SAlex Deucher static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d) 2088b75fad06SAlex Deucher { 2089b75fad06SAlex Deucher struct radeon_device *rdev = dev->dev_private; 2090b75fad06SAlex Deucher uint32_t ext_tmds_info; 2091b75fad06SAlex Deucher 2092b75fad06SAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2093b75fad06SAlex Deucher if (is_dvi_d) 2094b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 2095b75fad06SAlex Deucher else 2096b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2097b75fad06SAlex Deucher } 2098b75fad06SAlex Deucher ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2099b75fad06SAlex Deucher if (ext_tmds_info) { 2100b75fad06SAlex Deucher uint8_t rev = RBIOS8(ext_tmds_info); 2101b75fad06SAlex Deucher uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5); 2102b75fad06SAlex Deucher if (rev >= 3) { 2103b75fad06SAlex Deucher if (is_dvi_d) 2104b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 2105b75fad06SAlex Deucher else 2106b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 2107b75fad06SAlex Deucher } else { 2108b75fad06SAlex Deucher if (flags & 1) { 2109b75fad06SAlex Deucher if (is_dvi_d) 2110b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 2111b75fad06SAlex Deucher else 2112b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 2113b75fad06SAlex Deucher } 2114b75fad06SAlex Deucher } 2115b75fad06SAlex Deucher } 2116b75fad06SAlex Deucher if (is_dvi_d) 2117b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 2118b75fad06SAlex Deucher else 2119b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2120b75fad06SAlex Deucher } 2121b75fad06SAlex Deucher 2122771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) 2123771fe6b9SJerome Glisse { 2124771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2125771fe6b9SJerome Glisse uint32_t conn_info, entry, devices; 2126b75fad06SAlex Deucher uint16_t tmp, connector_object_id; 2127771fe6b9SJerome Glisse enum radeon_combios_ddc ddc_type; 2128771fe6b9SJerome Glisse enum radeon_combios_connector connector; 2129771fe6b9SJerome Glisse int i = 0; 2130771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 2131eed45b30SAlex Deucher struct radeon_hpd hpd; 2132771fe6b9SJerome Glisse 2133771fe6b9SJerome Glisse conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE); 2134771fe6b9SJerome Glisse if (conn_info) { 2135771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 2136771fe6b9SJerome Glisse entry = conn_info + 2 + i * 2; 2137771fe6b9SJerome Glisse 2138771fe6b9SJerome Glisse if (!RBIOS16(entry)) 2139771fe6b9SJerome Glisse break; 2140771fe6b9SJerome Glisse 2141771fe6b9SJerome Glisse tmp = RBIOS16(entry); 2142771fe6b9SJerome Glisse 2143771fe6b9SJerome Glisse connector = (tmp >> 12) & 0xf; 2144771fe6b9SJerome Glisse 2145771fe6b9SJerome Glisse ddc_type = (tmp >> 8) & 0xf; 2146179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, ddc_type, 0, 0); 2147771fe6b9SJerome Glisse 2148eed45b30SAlex Deucher switch (connector) { 2149eed45b30SAlex Deucher case CONNECTOR_PROPRIETARY_LEGACY: 2150eed45b30SAlex Deucher case CONNECTOR_DVI_I_LEGACY: 2151eed45b30SAlex Deucher case CONNECTOR_DVI_D_LEGACY: 2152eed45b30SAlex Deucher if ((tmp >> 4) & 0x1) 2153eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; 2154eed45b30SAlex Deucher else 2155eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 2156eed45b30SAlex Deucher break; 2157eed45b30SAlex Deucher default: 2158eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2159eed45b30SAlex Deucher break; 2160eed45b30SAlex Deucher } 2161eed45b30SAlex Deucher 21622d152c6bSAlex Deucher if (!radeon_apply_legacy_quirks(dev, i, &connector, 2163eed45b30SAlex Deucher &ddc_i2c, &hpd)) 21642d152c6bSAlex Deucher continue; 2165771fe6b9SJerome Glisse 2166771fe6b9SJerome Glisse switch (connector) { 2167771fe6b9SJerome Glisse case CONNECTOR_PROPRIETARY_LEGACY: 2168771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) 2169771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2170771fe6b9SJerome Glisse else 2171771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2172771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 21735137ee94SAlex Deucher radeon_get_encoder_enum 2174771fe6b9SJerome Glisse (dev, devices, 0), 2175771fe6b9SJerome Glisse devices); 2176771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2177771fe6b9SJerome Glisse legacy_connector_convert 2178771fe6b9SJerome Glisse [connector], 2179b75fad06SAlex Deucher &ddc_i2c, 2180eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 2181eed45b30SAlex Deucher &hpd); 2182771fe6b9SJerome Glisse break; 2183771fe6b9SJerome Glisse case CONNECTOR_CRT_LEGACY: 2184771fe6b9SJerome Glisse if (tmp & 0x1) { 2185771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT2_SUPPORT; 2186771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 21875137ee94SAlex Deucher radeon_get_encoder_enum 2188771fe6b9SJerome Glisse (dev, 2189771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2190771fe6b9SJerome Glisse 2), 2191771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2192771fe6b9SJerome Glisse } else { 2193771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT1_SUPPORT; 2194771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 21955137ee94SAlex Deucher radeon_get_encoder_enum 2196771fe6b9SJerome Glisse (dev, 2197771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2198771fe6b9SJerome Glisse 1), 2199771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2200771fe6b9SJerome Glisse } 2201771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2202771fe6b9SJerome Glisse i, 2203771fe6b9SJerome Glisse devices, 2204771fe6b9SJerome Glisse legacy_connector_convert 2205771fe6b9SJerome Glisse [connector], 2206b75fad06SAlex Deucher &ddc_i2c, 2207eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2208eed45b30SAlex Deucher &hpd); 2209771fe6b9SJerome Glisse break; 2210771fe6b9SJerome Glisse case CONNECTOR_DVI_I_LEGACY: 2211771fe6b9SJerome Glisse devices = 0; 2212771fe6b9SJerome Glisse if (tmp & 0x1) { 2213771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT2_SUPPORT; 2214771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22155137ee94SAlex Deucher radeon_get_encoder_enum 2216771fe6b9SJerome Glisse (dev, 2217771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2218771fe6b9SJerome Glisse 2), 2219771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2220771fe6b9SJerome Glisse } else { 2221771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT1_SUPPORT; 2222771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22235137ee94SAlex Deucher radeon_get_encoder_enum 2224771fe6b9SJerome Glisse (dev, 2225771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2226771fe6b9SJerome Glisse 1), 2227771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2228771fe6b9SJerome Glisse } 2229771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) { 2230771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP2_SUPPORT; 2231771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22325137ee94SAlex Deucher radeon_get_encoder_enum 2233771fe6b9SJerome Glisse (dev, 2234771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 2235771fe6b9SJerome Glisse 0), 2236771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 2237b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 0); 2238771fe6b9SJerome Glisse } else { 2239771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP1_SUPPORT; 2240771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22415137ee94SAlex Deucher radeon_get_encoder_enum 2242771fe6b9SJerome Glisse (dev, 2243771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2244771fe6b9SJerome Glisse 0), 2245771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2246b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2247771fe6b9SJerome Glisse } 2248771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2249771fe6b9SJerome Glisse i, 2250771fe6b9SJerome Glisse devices, 2251771fe6b9SJerome Glisse legacy_connector_convert 2252771fe6b9SJerome Glisse [connector], 2253b75fad06SAlex Deucher &ddc_i2c, 2254eed45b30SAlex Deucher connector_object_id, 2255eed45b30SAlex Deucher &hpd); 2256771fe6b9SJerome Glisse break; 2257771fe6b9SJerome Glisse case CONNECTOR_DVI_D_LEGACY: 2258b75fad06SAlex Deucher if ((tmp >> 4) & 0x1) { 2259771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2260b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 1); 2261b75fad06SAlex Deucher } else { 2262771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2263b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2264b75fad06SAlex Deucher } 2265771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22665137ee94SAlex Deucher radeon_get_encoder_enum 2267771fe6b9SJerome Glisse (dev, devices, 0), 2268771fe6b9SJerome Glisse devices); 2269771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2270771fe6b9SJerome Glisse legacy_connector_convert 2271771fe6b9SJerome Glisse [connector], 2272b75fad06SAlex Deucher &ddc_i2c, 2273eed45b30SAlex Deucher connector_object_id, 2274eed45b30SAlex Deucher &hpd); 2275771fe6b9SJerome Glisse break; 2276771fe6b9SJerome Glisse case CONNECTOR_CTV_LEGACY: 2277771fe6b9SJerome Glisse case CONNECTOR_STV_LEGACY: 2278771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22795137ee94SAlex Deucher radeon_get_encoder_enum 2280771fe6b9SJerome Glisse (dev, 2281771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2282771fe6b9SJerome Glisse 2), 2283771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2284771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, 2285771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2286771fe6b9SJerome Glisse legacy_connector_convert 2287771fe6b9SJerome Glisse [connector], 2288b75fad06SAlex Deucher &ddc_i2c, 2289eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2290eed45b30SAlex Deucher &hpd); 2291771fe6b9SJerome Glisse break; 2292771fe6b9SJerome Glisse default: 2293771fe6b9SJerome Glisse DRM_ERROR("Unknown connector type: %d\n", 2294771fe6b9SJerome Glisse connector); 2295771fe6b9SJerome Glisse continue; 2296771fe6b9SJerome Glisse } 2297771fe6b9SJerome Glisse 2298771fe6b9SJerome Glisse } 2299771fe6b9SJerome Glisse } else { 2300771fe6b9SJerome Glisse uint16_t tmds_info = 2301771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 2302771fe6b9SJerome Glisse if (tmds_info) { 2303d9fdaafbSDave Airlie DRM_DEBUG_KMS("Found DFP table, assuming DVI connector\n"); 2304771fe6b9SJerome Glisse 2305771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23065137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2307771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2308771fe6b9SJerome Glisse 1), 2309771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2310771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23115137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2312771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2313771fe6b9SJerome Glisse 0), 2314771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2315771fe6b9SJerome Glisse 2316179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 23178e36ed00SAlex Deucher hpd.hpd = RADEON_HPD_1; 2318771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2319771fe6b9SJerome Glisse 0, 2320771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT | 2321771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2322771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 2323b75fad06SAlex Deucher &ddc_i2c, 2324eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2325eed45b30SAlex Deucher &hpd); 2326771fe6b9SJerome Glisse } else { 2327d0c403e9SAlex Deucher uint16_t crt_info = 2328d0c403e9SAlex Deucher combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 2329d9fdaafbSDave Airlie DRM_DEBUG_KMS("Found CRT table, assuming VGA connector\n"); 2330d0c403e9SAlex Deucher if (crt_info) { 2331d0c403e9SAlex Deucher radeon_add_legacy_encoder(dev, 23325137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2333d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2334d0c403e9SAlex Deucher 1), 2335d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 2336179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 2337eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2338d0c403e9SAlex Deucher radeon_add_legacy_connector(dev, 2339d0c403e9SAlex Deucher 0, 2340d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2341d0c403e9SAlex Deucher DRM_MODE_CONNECTOR_VGA, 2342b75fad06SAlex Deucher &ddc_i2c, 2343eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2344eed45b30SAlex Deucher &hpd); 2345d0c403e9SAlex Deucher } else { 2346d9fdaafbSDave Airlie DRM_DEBUG_KMS("No connector info found\n"); 2347771fe6b9SJerome Glisse return false; 2348771fe6b9SJerome Glisse } 2349771fe6b9SJerome Glisse } 2350d0c403e9SAlex Deucher } 2351771fe6b9SJerome Glisse 2352771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) { 2353771fe6b9SJerome Glisse uint16_t lcd_info = 2354771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 2355771fe6b9SJerome Glisse if (lcd_info) { 2356771fe6b9SJerome Glisse uint16_t lcd_ddc_info = 2357771fe6b9SJerome Glisse combios_get_table_offset(dev, 2358771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE); 2359771fe6b9SJerome Glisse 2360771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23615137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2362771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2363771fe6b9SJerome Glisse 0), 2364771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 2365771fe6b9SJerome Glisse 2366771fe6b9SJerome Glisse if (lcd_ddc_info) { 2367771fe6b9SJerome Glisse ddc_type = RBIOS8(lcd_ddc_info + 2); 2368771fe6b9SJerome Glisse switch (ddc_type) { 2369771fe6b9SJerome Glisse case DDC_LCD: 2370771fe6b9SJerome Glisse ddc_i2c = 2371179e8078SAlex Deucher combios_setup_i2c_bus(rdev, 2372179e8078SAlex Deucher DDC_LCD, 2373179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 3), 2374179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 7)); 2375f376b94fSAlex Deucher radeon_i2c_add(rdev, &ddc_i2c, "LCD"); 2376771fe6b9SJerome Glisse break; 2377771fe6b9SJerome Glisse case DDC_GPIO: 2378771fe6b9SJerome Glisse ddc_i2c = 2379179e8078SAlex Deucher combios_setup_i2c_bus(rdev, 2380179e8078SAlex Deucher DDC_GPIO, 2381179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 3), 2382179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 7)); 2383f376b94fSAlex Deucher radeon_i2c_add(rdev, &ddc_i2c, "LCD"); 2384771fe6b9SJerome Glisse break; 2385771fe6b9SJerome Glisse default: 2386179e8078SAlex Deucher ddc_i2c = 2387179e8078SAlex Deucher combios_setup_i2c_bus(rdev, ddc_type, 0, 0); 2388771fe6b9SJerome Glisse break; 2389771fe6b9SJerome Glisse } 2390d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD DDC Info Table found!\n"); 2391771fe6b9SJerome Glisse } else 2392771fe6b9SJerome Glisse ddc_i2c.valid = false; 2393771fe6b9SJerome Glisse 2394eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2395771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2396771fe6b9SJerome Glisse 5, 2397771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2398771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 2399b75fad06SAlex Deucher &ddc_i2c, 2400eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 2401eed45b30SAlex Deucher &hpd); 2402771fe6b9SJerome Glisse } 2403771fe6b9SJerome Glisse } 2404771fe6b9SJerome Glisse 2405771fe6b9SJerome Glisse /* check TV table */ 2406771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 2407771fe6b9SJerome Glisse uint32_t tv_info = 2408771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 2409771fe6b9SJerome Glisse if (tv_info) { 2410771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 2411790cfb34SAlex Deucher if (radeon_apply_legacy_tv_quirks(dev)) { 2412eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2413d294ed69SDave Airlie ddc_i2c.valid = false; 2414771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24155137ee94SAlex Deucher radeon_get_encoder_enum 2416771fe6b9SJerome Glisse (dev, 2417771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2418771fe6b9SJerome Glisse 2), 2419771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2420771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 6, 2421771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2422771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 2423b75fad06SAlex Deucher &ddc_i2c, 2424eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2425eed45b30SAlex Deucher &hpd); 2426771fe6b9SJerome Glisse } 2427771fe6b9SJerome Glisse } 2428771fe6b9SJerome Glisse } 2429790cfb34SAlex Deucher } 2430771fe6b9SJerome Glisse 2431771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2432771fe6b9SJerome Glisse 2433771fe6b9SJerome Glisse return true; 2434771fe6b9SJerome Glisse } 2435771fe6b9SJerome Glisse 243656278a8eSAlex Deucher void radeon_combios_get_power_modes(struct radeon_device *rdev) 243756278a8eSAlex Deucher { 243856278a8eSAlex Deucher struct drm_device *dev = rdev->ddev; 243956278a8eSAlex Deucher u16 offset, misc, misc2 = 0; 244056278a8eSAlex Deucher u8 rev, blocks, tmp; 244156278a8eSAlex Deucher int state_index = 0; 244256278a8eSAlex Deucher 2443a48b9b4eSAlex Deucher rdev->pm.default_power_state_index = -1; 244456278a8eSAlex Deucher 2445*0975b162SAlex Deucher /* allocate 2 power states */ 2446*0975b162SAlex Deucher rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * 2, GFP_KERNEL); 2447*0975b162SAlex Deucher if (!rdev->pm.power_state) { 2448*0975b162SAlex Deucher rdev->pm.default_power_state_index = state_index; 2449*0975b162SAlex Deucher rdev->pm.num_power_states = 0; 2450*0975b162SAlex Deucher 2451*0975b162SAlex Deucher rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; 2452*0975b162SAlex Deucher rdev->pm.current_clock_mode_index = 0; 2453*0975b162SAlex Deucher return; 2454*0975b162SAlex Deucher } 2455*0975b162SAlex Deucher 245656278a8eSAlex Deucher if (rdev->flags & RADEON_IS_MOBILITY) { 245756278a8eSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE); 245856278a8eSAlex Deucher if (offset) { 245956278a8eSAlex Deucher rev = RBIOS8(offset); 246056278a8eSAlex Deucher blocks = RBIOS8(offset + 0x2); 246156278a8eSAlex Deucher /* power mode 0 tends to be the only valid one */ 246256278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 246356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = RBIOS32(offset + 0x5 + 0x2); 246456278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = RBIOS32(offset + 0x5 + 0x6); 246556278a8eSAlex Deucher if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) || 246656278a8eSAlex Deucher (rdev->pm.power_state[state_index].clock_info[0].sclk == 0)) 246756278a8eSAlex Deucher goto default_mode; 24680ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 24690ec0e74fSAlex Deucher POWER_STATE_TYPE_BATTERY; 247056278a8eSAlex Deucher misc = RBIOS16(offset + 0x5 + 0x0); 247156278a8eSAlex Deucher if (rev > 4) 247256278a8eSAlex Deucher misc2 = RBIOS16(offset + 0x5 + 0xe); 247379daedc9SAlex Deucher rdev->pm.power_state[state_index].misc = misc; 247479daedc9SAlex Deucher rdev->pm.power_state[state_index].misc2 = misc2; 247556278a8eSAlex Deucher if (misc & 0x4) { 247656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_GPIO; 247756278a8eSAlex Deucher if (misc & 0x8) 247856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 247956278a8eSAlex Deucher true; 248056278a8eSAlex Deucher else 248156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 248256278a8eSAlex Deucher false; 248356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = true; 248456278a8eSAlex Deucher if (rev < 6) { 248556278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 248656278a8eSAlex Deucher RBIOS16(offset + 0x5 + 0xb) * 4; 248756278a8eSAlex Deucher tmp = RBIOS8(offset + 0x5 + 0xd); 248856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 248956278a8eSAlex Deucher } else { 249056278a8eSAlex Deucher u8 entries = RBIOS8(offset + 0x5 + 0xb); 249156278a8eSAlex Deucher u16 voltage_table_offset = RBIOS16(offset + 0x5 + 0xc); 249256278a8eSAlex Deucher if (entries && voltage_table_offset) { 249356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 249456278a8eSAlex Deucher RBIOS16(voltage_table_offset) * 4; 249556278a8eSAlex Deucher tmp = RBIOS8(voltage_table_offset + 0x2); 249656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 249756278a8eSAlex Deucher } else 249856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = false; 249956278a8eSAlex Deucher } 250056278a8eSAlex Deucher switch ((misc2 & 0x700) >> 8) { 250156278a8eSAlex Deucher case 0: 250256278a8eSAlex Deucher default: 250356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 0; 250456278a8eSAlex Deucher break; 250556278a8eSAlex Deucher case 1: 250656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 33; 250756278a8eSAlex Deucher break; 250856278a8eSAlex Deucher case 2: 250956278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 66; 251056278a8eSAlex Deucher break; 251156278a8eSAlex Deucher case 3: 251256278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 99; 251356278a8eSAlex Deucher break; 251456278a8eSAlex Deucher case 4: 251556278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 132; 251656278a8eSAlex Deucher break; 251756278a8eSAlex Deucher } 251856278a8eSAlex Deucher } else 251956278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 252056278a8eSAlex Deucher if (rev > 6) 252179daedc9SAlex Deucher rdev->pm.power_state[state_index].pcie_lanes = 252256278a8eSAlex Deucher RBIOS8(offset + 0x5 + 0x10); 2523d7311171SAlex Deucher rdev->pm.power_state[state_index].flags = RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; 252456278a8eSAlex Deucher state_index++; 252556278a8eSAlex Deucher } else { 252656278a8eSAlex Deucher /* XXX figure out some good default low power mode for mobility cards w/out power tables */ 252756278a8eSAlex Deucher } 252856278a8eSAlex Deucher } else { 252956278a8eSAlex Deucher /* XXX figure out some good default low power mode for desktop cards */ 253056278a8eSAlex Deucher } 253156278a8eSAlex Deucher 253256278a8eSAlex Deucher default_mode: 253356278a8eSAlex Deucher /* add the default mode */ 25340ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 25350ec0e74fSAlex Deucher POWER_STATE_TYPE_DEFAULT; 253656278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 253756278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk; 253856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk; 253956278a8eSAlex Deucher rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0]; 254084d88f4cSAlex Deucher if ((state_index > 0) && 25418de016e2SAlex Deucher (rdev->pm.power_state[0].clock_info[0].voltage.type == VOLTAGE_GPIO)) 254284d88f4cSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage = 254384d88f4cSAlex Deucher rdev->pm.power_state[0].clock_info[0].voltage; 254484d88f4cSAlex Deucher else 254556278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 254679daedc9SAlex Deucher rdev->pm.power_state[state_index].pcie_lanes = 16; 2547a48b9b4eSAlex Deucher rdev->pm.power_state[state_index].flags = 0; 2548a48b9b4eSAlex Deucher rdev->pm.default_power_state_index = state_index; 254956278a8eSAlex Deucher rdev->pm.num_power_states = state_index + 1; 25509038dfdfSRafał Miłecki 2551a48b9b4eSAlex Deucher rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; 2552a48b9b4eSAlex Deucher rdev->pm.current_clock_mode_index = 0; 255356278a8eSAlex Deucher } 255456278a8eSAlex Deucher 2555fcec570bSAlex Deucher void radeon_external_tmds_setup(struct drm_encoder *encoder) 2556fcec570bSAlex Deucher { 2557fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2558fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2559fcec570bSAlex Deucher 2560fcec570bSAlex Deucher if (!tmds) 2561fcec570bSAlex Deucher return; 2562fcec570bSAlex Deucher 2563fcec570bSAlex Deucher switch (tmds->dvo_chip) { 2564fcec570bSAlex Deucher case DVO_SIL164: 2565fcec570bSAlex Deucher /* sil 164 */ 25665a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2567fcec570bSAlex Deucher tmds->slave_addr, 2568fcec570bSAlex Deucher 0x08, 0x30); 25695a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2570fcec570bSAlex Deucher tmds->slave_addr, 2571fcec570bSAlex Deucher 0x09, 0x00); 25725a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2573fcec570bSAlex Deucher tmds->slave_addr, 2574fcec570bSAlex Deucher 0x0a, 0x90); 25755a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2576fcec570bSAlex Deucher tmds->slave_addr, 2577fcec570bSAlex Deucher 0x0c, 0x89); 25785a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2579fcec570bSAlex Deucher tmds->slave_addr, 2580fcec570bSAlex Deucher 0x08, 0x3b); 2581fcec570bSAlex Deucher break; 2582fcec570bSAlex Deucher case DVO_SIL1178: 2583fcec570bSAlex Deucher /* sil 1178 - untested */ 2584fcec570bSAlex Deucher /* 2585fcec570bSAlex Deucher * 0x0f, 0x44 2586fcec570bSAlex Deucher * 0x0f, 0x4c 2587fcec570bSAlex Deucher * 0x0e, 0x01 2588fcec570bSAlex Deucher * 0x0a, 0x80 2589fcec570bSAlex Deucher * 0x09, 0x30 2590fcec570bSAlex Deucher * 0x0c, 0xc9 2591fcec570bSAlex Deucher * 0x0d, 0x70 2592fcec570bSAlex Deucher * 0x08, 0x32 2593fcec570bSAlex Deucher * 0x08, 0x33 2594fcec570bSAlex Deucher */ 2595fcec570bSAlex Deucher break; 2596fcec570bSAlex Deucher default: 2597fcec570bSAlex Deucher break; 2598fcec570bSAlex Deucher } 2599fcec570bSAlex Deucher 2600fcec570bSAlex Deucher } 2601fcec570bSAlex Deucher 2602fcec570bSAlex Deucher bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder) 2603fcec570bSAlex Deucher { 2604fcec570bSAlex Deucher struct drm_device *dev = encoder->dev; 2605fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 2606fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2607fcec570bSAlex Deucher uint16_t offset; 2608fcec570bSAlex Deucher uint8_t blocks, slave_addr, rev; 2609fcec570bSAlex Deucher uint32_t index, id; 2610fcec570bSAlex Deucher uint32_t reg, val, and_mask, or_mask; 2611fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2612fcec570bSAlex Deucher 2613fcec570bSAlex Deucher if (!tmds) 2614fcec570bSAlex Deucher return false; 2615fcec570bSAlex Deucher 2616fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2617fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE); 2618fcec570bSAlex Deucher rev = RBIOS8(offset); 2619fcec570bSAlex Deucher if (offset) { 2620fcec570bSAlex Deucher rev = RBIOS8(offset); 2621fcec570bSAlex Deucher if (rev > 1) { 2622fcec570bSAlex Deucher blocks = RBIOS8(offset + 3); 2623fcec570bSAlex Deucher index = offset + 4; 2624fcec570bSAlex Deucher while (blocks > 0) { 2625fcec570bSAlex Deucher id = RBIOS16(index); 2626fcec570bSAlex Deucher index += 2; 2627fcec570bSAlex Deucher switch (id >> 13) { 2628fcec570bSAlex Deucher case 0: 2629fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2630fcec570bSAlex Deucher val = RBIOS32(index); 2631fcec570bSAlex Deucher index += 4; 2632fcec570bSAlex Deucher WREG32(reg, val); 2633fcec570bSAlex Deucher break; 2634fcec570bSAlex Deucher case 2: 2635fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2636fcec570bSAlex Deucher and_mask = RBIOS32(index); 2637fcec570bSAlex Deucher index += 4; 2638fcec570bSAlex Deucher or_mask = RBIOS32(index); 2639fcec570bSAlex Deucher index += 4; 2640fcec570bSAlex Deucher val = RREG32(reg); 2641fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2642fcec570bSAlex Deucher WREG32(reg, val); 2643fcec570bSAlex Deucher break; 2644fcec570bSAlex Deucher case 3: 2645fcec570bSAlex Deucher val = RBIOS16(index); 2646fcec570bSAlex Deucher index += 2; 2647fcec570bSAlex Deucher udelay(val); 2648fcec570bSAlex Deucher break; 2649fcec570bSAlex Deucher case 4: 2650fcec570bSAlex Deucher val = RBIOS16(index); 2651fcec570bSAlex Deucher index += 2; 2652fcec570bSAlex Deucher udelay(val * 1000); 2653fcec570bSAlex Deucher break; 2654fcec570bSAlex Deucher case 6: 2655fcec570bSAlex Deucher slave_addr = id & 0xff; 2656fcec570bSAlex Deucher slave_addr >>= 1; /* 7 bit addressing */ 2657fcec570bSAlex Deucher index++; 2658fcec570bSAlex Deucher reg = RBIOS8(index); 2659fcec570bSAlex Deucher index++; 2660fcec570bSAlex Deucher val = RBIOS8(index); 2661fcec570bSAlex Deucher index++; 26625a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2663fcec570bSAlex Deucher slave_addr, 2664fcec570bSAlex Deucher reg, val); 2665fcec570bSAlex Deucher break; 2666fcec570bSAlex Deucher default: 2667fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2668fcec570bSAlex Deucher break; 2669fcec570bSAlex Deucher } 2670fcec570bSAlex Deucher blocks--; 2671fcec570bSAlex Deucher } 2672fcec570bSAlex Deucher return true; 2673fcec570bSAlex Deucher } 2674fcec570bSAlex Deucher } 2675fcec570bSAlex Deucher } else { 2676fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2677fcec570bSAlex Deucher if (offset) { 2678fcec570bSAlex Deucher index = offset + 10; 2679fcec570bSAlex Deucher id = RBIOS16(index); 2680fcec570bSAlex Deucher while (id != 0xffff) { 2681fcec570bSAlex Deucher index += 2; 2682fcec570bSAlex Deucher switch (id >> 13) { 2683fcec570bSAlex Deucher case 0: 2684fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2685fcec570bSAlex Deucher val = RBIOS32(index); 2686fcec570bSAlex Deucher WREG32(reg, val); 2687fcec570bSAlex Deucher break; 2688fcec570bSAlex Deucher case 2: 2689fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2690fcec570bSAlex Deucher and_mask = RBIOS32(index); 2691fcec570bSAlex Deucher index += 4; 2692fcec570bSAlex Deucher or_mask = RBIOS32(index); 2693fcec570bSAlex Deucher index += 4; 2694fcec570bSAlex Deucher val = RREG32(reg); 2695fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2696fcec570bSAlex Deucher WREG32(reg, val); 2697fcec570bSAlex Deucher break; 2698fcec570bSAlex Deucher case 4: 2699fcec570bSAlex Deucher val = RBIOS16(index); 2700fcec570bSAlex Deucher index += 2; 2701fcec570bSAlex Deucher udelay(val); 2702fcec570bSAlex Deucher break; 2703fcec570bSAlex Deucher case 5: 2704fcec570bSAlex Deucher reg = id & 0x1fff; 2705fcec570bSAlex Deucher and_mask = RBIOS32(index); 2706fcec570bSAlex Deucher index += 4; 2707fcec570bSAlex Deucher or_mask = RBIOS32(index); 2708fcec570bSAlex Deucher index += 4; 2709fcec570bSAlex Deucher val = RREG32_PLL(reg); 2710fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2711fcec570bSAlex Deucher WREG32_PLL(reg, val); 2712fcec570bSAlex Deucher break; 2713fcec570bSAlex Deucher case 6: 2714fcec570bSAlex Deucher reg = id & 0x1fff; 2715fcec570bSAlex Deucher val = RBIOS8(index); 2716fcec570bSAlex Deucher index += 1; 27175a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2718fcec570bSAlex Deucher tmds->slave_addr, 2719fcec570bSAlex Deucher reg, val); 2720fcec570bSAlex Deucher break; 2721fcec570bSAlex Deucher default: 2722fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2723fcec570bSAlex Deucher break; 2724fcec570bSAlex Deucher } 2725fcec570bSAlex Deucher id = RBIOS16(index); 2726fcec570bSAlex Deucher } 2727fcec570bSAlex Deucher return true; 2728fcec570bSAlex Deucher } 2729fcec570bSAlex Deucher } 2730fcec570bSAlex Deucher return false; 2731fcec570bSAlex Deucher } 2732fcec570bSAlex Deucher 2733771fe6b9SJerome Glisse static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset) 2734771fe6b9SJerome Glisse { 2735771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2736771fe6b9SJerome Glisse 2737771fe6b9SJerome Glisse if (offset) { 2738771fe6b9SJerome Glisse while (RBIOS16(offset)) { 2739771fe6b9SJerome Glisse uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13); 2740771fe6b9SJerome Glisse uint32_t addr = (RBIOS16(offset) & 0x1fff); 2741771fe6b9SJerome Glisse uint32_t val, and_mask, or_mask; 2742771fe6b9SJerome Glisse uint32_t tmp; 2743771fe6b9SJerome Glisse 2744771fe6b9SJerome Glisse offset += 2; 2745771fe6b9SJerome Glisse switch (cmd) { 2746771fe6b9SJerome Glisse case 0: 2747771fe6b9SJerome Glisse val = RBIOS32(offset); 2748771fe6b9SJerome Glisse offset += 4; 2749771fe6b9SJerome Glisse WREG32(addr, val); 2750771fe6b9SJerome Glisse break; 2751771fe6b9SJerome Glisse case 1: 2752771fe6b9SJerome Glisse val = RBIOS32(offset); 2753771fe6b9SJerome Glisse offset += 4; 2754771fe6b9SJerome Glisse WREG32(addr, val); 2755771fe6b9SJerome Glisse break; 2756771fe6b9SJerome Glisse case 2: 2757771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2758771fe6b9SJerome Glisse offset += 4; 2759771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2760771fe6b9SJerome Glisse offset += 4; 2761771fe6b9SJerome Glisse tmp = RREG32(addr); 2762771fe6b9SJerome Glisse tmp &= and_mask; 2763771fe6b9SJerome Glisse tmp |= or_mask; 2764771fe6b9SJerome Glisse WREG32(addr, tmp); 2765771fe6b9SJerome Glisse break; 2766771fe6b9SJerome Glisse case 3: 2767771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2768771fe6b9SJerome Glisse offset += 4; 2769771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2770771fe6b9SJerome Glisse offset += 4; 2771771fe6b9SJerome Glisse tmp = RREG32(addr); 2772771fe6b9SJerome Glisse tmp &= and_mask; 2773771fe6b9SJerome Glisse tmp |= or_mask; 2774771fe6b9SJerome Glisse WREG32(addr, tmp); 2775771fe6b9SJerome Glisse break; 2776771fe6b9SJerome Glisse case 4: 2777771fe6b9SJerome Glisse val = RBIOS16(offset); 2778771fe6b9SJerome Glisse offset += 2; 2779771fe6b9SJerome Glisse udelay(val); 2780771fe6b9SJerome Glisse break; 2781771fe6b9SJerome Glisse case 5: 2782771fe6b9SJerome Glisse val = RBIOS16(offset); 2783771fe6b9SJerome Glisse offset += 2; 2784771fe6b9SJerome Glisse switch (addr) { 2785771fe6b9SJerome Glisse case 8: 2786771fe6b9SJerome Glisse while (val--) { 2787771fe6b9SJerome Glisse if (! 2788771fe6b9SJerome Glisse (RREG32_PLL 2789771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2790771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2791771fe6b9SJerome Glisse break; 2792771fe6b9SJerome Glisse } 2793771fe6b9SJerome Glisse break; 2794771fe6b9SJerome Glisse case 9: 2795771fe6b9SJerome Glisse while (val--) { 2796771fe6b9SJerome Glisse if ((RREG32(RADEON_MC_STATUS) & 2797771fe6b9SJerome Glisse RADEON_MC_IDLE)) 2798771fe6b9SJerome Glisse break; 2799771fe6b9SJerome Glisse } 2800771fe6b9SJerome Glisse break; 2801771fe6b9SJerome Glisse default: 2802771fe6b9SJerome Glisse break; 2803771fe6b9SJerome Glisse } 2804771fe6b9SJerome Glisse break; 2805771fe6b9SJerome Glisse default: 2806771fe6b9SJerome Glisse break; 2807771fe6b9SJerome Glisse } 2808771fe6b9SJerome Glisse } 2809771fe6b9SJerome Glisse } 2810771fe6b9SJerome Glisse } 2811771fe6b9SJerome Glisse 2812771fe6b9SJerome Glisse static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset) 2813771fe6b9SJerome Glisse { 2814771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2815771fe6b9SJerome Glisse 2816771fe6b9SJerome Glisse if (offset) { 2817771fe6b9SJerome Glisse while (RBIOS8(offset)) { 2818771fe6b9SJerome Glisse uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6); 2819771fe6b9SJerome Glisse uint8_t addr = (RBIOS8(offset) & 0x3f); 2820771fe6b9SJerome Glisse uint32_t val, shift, tmp; 2821771fe6b9SJerome Glisse uint32_t and_mask, or_mask; 2822771fe6b9SJerome Glisse 2823771fe6b9SJerome Glisse offset++; 2824771fe6b9SJerome Glisse switch (cmd) { 2825771fe6b9SJerome Glisse case 0: 2826771fe6b9SJerome Glisse val = RBIOS32(offset); 2827771fe6b9SJerome Glisse offset += 4; 2828771fe6b9SJerome Glisse WREG32_PLL(addr, val); 2829771fe6b9SJerome Glisse break; 2830771fe6b9SJerome Glisse case 1: 2831771fe6b9SJerome Glisse shift = RBIOS8(offset) * 8; 2832771fe6b9SJerome Glisse offset++; 2833771fe6b9SJerome Glisse and_mask = RBIOS8(offset) << shift; 2834771fe6b9SJerome Glisse and_mask |= ~(0xff << shift); 2835771fe6b9SJerome Glisse offset++; 2836771fe6b9SJerome Glisse or_mask = RBIOS8(offset) << shift; 2837771fe6b9SJerome Glisse offset++; 2838771fe6b9SJerome Glisse tmp = RREG32_PLL(addr); 2839771fe6b9SJerome Glisse tmp &= and_mask; 2840771fe6b9SJerome Glisse tmp |= or_mask; 2841771fe6b9SJerome Glisse WREG32_PLL(addr, tmp); 2842771fe6b9SJerome Glisse break; 2843771fe6b9SJerome Glisse case 2: 2844771fe6b9SJerome Glisse case 3: 2845771fe6b9SJerome Glisse tmp = 1000; 2846771fe6b9SJerome Glisse switch (addr) { 2847771fe6b9SJerome Glisse case 1: 2848771fe6b9SJerome Glisse udelay(150); 2849771fe6b9SJerome Glisse break; 2850771fe6b9SJerome Glisse case 2: 2851771fe6b9SJerome Glisse udelay(1000); 2852771fe6b9SJerome Glisse break; 2853771fe6b9SJerome Glisse case 3: 2854771fe6b9SJerome Glisse while (tmp--) { 2855771fe6b9SJerome Glisse if (! 2856771fe6b9SJerome Glisse (RREG32_PLL 2857771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2858771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2859771fe6b9SJerome Glisse break; 2860771fe6b9SJerome Glisse } 2861771fe6b9SJerome Glisse break; 2862771fe6b9SJerome Glisse case 4: 2863771fe6b9SJerome Glisse while (tmp--) { 2864771fe6b9SJerome Glisse if (RREG32_PLL 2865771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2866771fe6b9SJerome Glisse RADEON_DLL_READY) 2867771fe6b9SJerome Glisse break; 2868771fe6b9SJerome Glisse } 2869771fe6b9SJerome Glisse break; 2870771fe6b9SJerome Glisse case 5: 2871771fe6b9SJerome Glisse tmp = 2872771fe6b9SJerome Glisse RREG32_PLL(RADEON_CLK_PWRMGT_CNTL); 2873771fe6b9SJerome Glisse if (tmp & RADEON_CG_NO1_DEBUG_0) { 2874771fe6b9SJerome Glisse #if 0 2875771fe6b9SJerome Glisse uint32_t mclk_cntl = 2876771fe6b9SJerome Glisse RREG32_PLL 2877771fe6b9SJerome Glisse (RADEON_MCLK_CNTL); 2878771fe6b9SJerome Glisse mclk_cntl &= 0xffff0000; 2879771fe6b9SJerome Glisse /*mclk_cntl |= 0x00001111;*//* ??? */ 2880771fe6b9SJerome Glisse WREG32_PLL(RADEON_MCLK_CNTL, 2881771fe6b9SJerome Glisse mclk_cntl); 2882771fe6b9SJerome Glisse udelay(10000); 2883771fe6b9SJerome Glisse #endif 2884771fe6b9SJerome Glisse WREG32_PLL 2885771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL, 2886771fe6b9SJerome Glisse tmp & 2887771fe6b9SJerome Glisse ~RADEON_CG_NO1_DEBUG_0); 2888771fe6b9SJerome Glisse udelay(10000); 2889771fe6b9SJerome Glisse } 2890771fe6b9SJerome Glisse break; 2891771fe6b9SJerome Glisse default: 2892771fe6b9SJerome Glisse break; 2893771fe6b9SJerome Glisse } 2894771fe6b9SJerome Glisse break; 2895771fe6b9SJerome Glisse default: 2896771fe6b9SJerome Glisse break; 2897771fe6b9SJerome Glisse } 2898771fe6b9SJerome Glisse } 2899771fe6b9SJerome Glisse } 2900771fe6b9SJerome Glisse } 2901771fe6b9SJerome Glisse 2902771fe6b9SJerome Glisse static void combios_parse_ram_reset_table(struct drm_device *dev, 2903771fe6b9SJerome Glisse uint16_t offset) 2904771fe6b9SJerome Glisse { 2905771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2906771fe6b9SJerome Glisse uint32_t tmp; 2907771fe6b9SJerome Glisse 2908771fe6b9SJerome Glisse if (offset) { 2909771fe6b9SJerome Glisse uint8_t val = RBIOS8(offset); 2910771fe6b9SJerome Glisse while (val != 0xff) { 2911771fe6b9SJerome Glisse offset++; 2912771fe6b9SJerome Glisse 2913771fe6b9SJerome Glisse if (val == 0x0f) { 2914771fe6b9SJerome Glisse uint32_t channel_complete_mask; 2915771fe6b9SJerome Glisse 2916771fe6b9SJerome Glisse if (ASIC_IS_R300(rdev)) 2917771fe6b9SJerome Glisse channel_complete_mask = 2918771fe6b9SJerome Glisse R300_MEM_PWRUP_COMPLETE; 2919771fe6b9SJerome Glisse else 2920771fe6b9SJerome Glisse channel_complete_mask = 2921771fe6b9SJerome Glisse RADEON_MEM_PWRUP_COMPLETE; 2922771fe6b9SJerome Glisse tmp = 20000; 2923771fe6b9SJerome Glisse while (tmp--) { 2924771fe6b9SJerome Glisse if ((RREG32(RADEON_MEM_STR_CNTL) & 2925771fe6b9SJerome Glisse channel_complete_mask) == 2926771fe6b9SJerome Glisse channel_complete_mask) 2927771fe6b9SJerome Glisse break; 2928771fe6b9SJerome Glisse } 2929771fe6b9SJerome Glisse } else { 2930771fe6b9SJerome Glisse uint32_t or_mask = RBIOS16(offset); 2931771fe6b9SJerome Glisse offset += 2; 2932771fe6b9SJerome Glisse 2933771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 2934771fe6b9SJerome Glisse tmp &= RADEON_SDRAM_MODE_MASK; 2935771fe6b9SJerome Glisse tmp |= or_mask; 2936771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 2937771fe6b9SJerome Glisse 2938771fe6b9SJerome Glisse or_mask = val << 24; 2939771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 2940771fe6b9SJerome Glisse tmp &= RADEON_B3MEM_RESET_MASK; 2941771fe6b9SJerome Glisse tmp |= or_mask; 2942771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 2943771fe6b9SJerome Glisse } 2944771fe6b9SJerome Glisse val = RBIOS8(offset); 2945771fe6b9SJerome Glisse } 2946771fe6b9SJerome Glisse } 2947771fe6b9SJerome Glisse } 2948771fe6b9SJerome Glisse 2949771fe6b9SJerome Glisse static uint32_t combios_detect_ram(struct drm_device *dev, int ram, 2950771fe6b9SJerome Glisse int mem_addr_mapping) 2951771fe6b9SJerome Glisse { 2952771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2953771fe6b9SJerome Glisse uint32_t mem_cntl; 2954771fe6b9SJerome Glisse uint32_t mem_size; 2955771fe6b9SJerome Glisse uint32_t addr = 0; 2956771fe6b9SJerome Glisse 2957771fe6b9SJerome Glisse mem_cntl = RREG32(RADEON_MEM_CNTL); 2958771fe6b9SJerome Glisse if (mem_cntl & RV100_HALF_MODE) 2959771fe6b9SJerome Glisse ram /= 2; 2960771fe6b9SJerome Glisse mem_size = ram; 2961771fe6b9SJerome Glisse mem_cntl &= ~(0xff << 8); 2962771fe6b9SJerome Glisse mem_cntl |= (mem_addr_mapping & 0xff) << 8; 2963771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 2964771fe6b9SJerome Glisse RREG32(RADEON_MEM_CNTL); 2965771fe6b9SJerome Glisse 2966771fe6b9SJerome Glisse /* sdram reset ? */ 2967771fe6b9SJerome Glisse 2968771fe6b9SJerome Glisse /* something like this???? */ 2969771fe6b9SJerome Glisse while (ram--) { 2970771fe6b9SJerome Glisse addr = ram * 1024 * 1024; 2971771fe6b9SJerome Glisse /* write to each page */ 2972771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 2973771fe6b9SJerome Glisse WREG32(RADEON_MM_DATA, 0xdeadbeef); 2974771fe6b9SJerome Glisse /* read back and verify */ 2975771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 2976771fe6b9SJerome Glisse if (RREG32(RADEON_MM_DATA) != 0xdeadbeef) 2977771fe6b9SJerome Glisse return 0; 2978771fe6b9SJerome Glisse } 2979771fe6b9SJerome Glisse 2980771fe6b9SJerome Glisse return mem_size; 2981771fe6b9SJerome Glisse } 2982771fe6b9SJerome Glisse 2983771fe6b9SJerome Glisse static void combios_write_ram_size(struct drm_device *dev) 2984771fe6b9SJerome Glisse { 2985771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2986771fe6b9SJerome Glisse uint8_t rev; 2987771fe6b9SJerome Glisse uint16_t offset; 2988771fe6b9SJerome Glisse uint32_t mem_size = 0; 2989771fe6b9SJerome Glisse uint32_t mem_cntl = 0; 2990771fe6b9SJerome Glisse 2991771fe6b9SJerome Glisse /* should do something smarter here I guess... */ 2992771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_IGP) 2993771fe6b9SJerome Glisse return; 2994771fe6b9SJerome Glisse 2995771fe6b9SJerome Glisse /* first check detected mem table */ 2996771fe6b9SJerome Glisse offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE); 2997771fe6b9SJerome Glisse if (offset) { 2998771fe6b9SJerome Glisse rev = RBIOS8(offset); 2999771fe6b9SJerome Glisse if (rev < 3) { 3000771fe6b9SJerome Glisse mem_cntl = RBIOS32(offset + 1); 3001771fe6b9SJerome Glisse mem_size = RBIOS16(offset + 5); 30024ce9198eSAlex Deucher if ((rdev->family < CHIP_R200) && 30034ce9198eSAlex Deucher !ASIC_IS_RN50(rdev)) 3004771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 3005771fe6b9SJerome Glisse } 3006771fe6b9SJerome Glisse } 3007771fe6b9SJerome Glisse 3008771fe6b9SJerome Glisse if (!mem_size) { 3009771fe6b9SJerome Glisse offset = 3010771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 3011771fe6b9SJerome Glisse if (offset) { 3012771fe6b9SJerome Glisse rev = RBIOS8(offset - 1); 3013771fe6b9SJerome Glisse if (rev < 1) { 30144ce9198eSAlex Deucher if ((rdev->family < CHIP_R200) 30154ce9198eSAlex Deucher && !ASIC_IS_RN50(rdev)) { 3016771fe6b9SJerome Glisse int ram = 0; 3017771fe6b9SJerome Glisse int mem_addr_mapping = 0; 3018771fe6b9SJerome Glisse 3019771fe6b9SJerome Glisse while (RBIOS8(offset)) { 3020771fe6b9SJerome Glisse ram = RBIOS8(offset); 3021771fe6b9SJerome Glisse mem_addr_mapping = 3022771fe6b9SJerome Glisse RBIOS8(offset + 1); 3023771fe6b9SJerome Glisse if (mem_addr_mapping != 0x25) 3024771fe6b9SJerome Glisse ram *= 2; 3025771fe6b9SJerome Glisse mem_size = 3026771fe6b9SJerome Glisse combios_detect_ram(dev, ram, 3027771fe6b9SJerome Glisse mem_addr_mapping); 3028771fe6b9SJerome Glisse if (mem_size) 3029771fe6b9SJerome Glisse break; 3030771fe6b9SJerome Glisse offset += 2; 3031771fe6b9SJerome Glisse } 3032771fe6b9SJerome Glisse } else 3033771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 3034771fe6b9SJerome Glisse } else { 3035771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 3036771fe6b9SJerome Glisse mem_size *= 2; /* convert to MB */ 3037771fe6b9SJerome Glisse } 3038771fe6b9SJerome Glisse } 3039771fe6b9SJerome Glisse } 3040771fe6b9SJerome Glisse 3041771fe6b9SJerome Glisse mem_size *= (1024 * 1024); /* convert to bytes */ 3042771fe6b9SJerome Glisse WREG32(RADEON_CONFIG_MEMSIZE, mem_size); 3043771fe6b9SJerome Glisse } 3044771fe6b9SJerome Glisse 3045771fe6b9SJerome Glisse void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable) 3046771fe6b9SJerome Glisse { 3047771fe6b9SJerome Glisse uint16_t dyn_clk_info = 3048771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 3049771fe6b9SJerome Glisse 3050771fe6b9SJerome Glisse if (dyn_clk_info) 3051771fe6b9SJerome Glisse combios_parse_pll_table(dev, dyn_clk_info); 3052771fe6b9SJerome Glisse } 3053771fe6b9SJerome Glisse 3054771fe6b9SJerome Glisse void radeon_combios_asic_init(struct drm_device *dev) 3055771fe6b9SJerome Glisse { 3056771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3057771fe6b9SJerome Glisse uint16_t table; 3058771fe6b9SJerome Glisse 3059771fe6b9SJerome Glisse /* port hardcoded mac stuff from radeonfb */ 3060771fe6b9SJerome Glisse if (rdev->bios == NULL) 3061771fe6b9SJerome Glisse return; 3062771fe6b9SJerome Glisse 3063771fe6b9SJerome Glisse /* ASIC INIT 1 */ 3064771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE); 3065771fe6b9SJerome Glisse if (table) 3066771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3067771fe6b9SJerome Glisse 3068771fe6b9SJerome Glisse /* PLL INIT */ 3069771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE); 3070771fe6b9SJerome Glisse if (table) 3071771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 3072771fe6b9SJerome Glisse 3073771fe6b9SJerome Glisse /* ASIC INIT 2 */ 3074771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE); 3075771fe6b9SJerome Glisse if (table) 3076771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3077771fe6b9SJerome Glisse 3078771fe6b9SJerome Glisse if (!(rdev->flags & RADEON_IS_IGP)) { 3079771fe6b9SJerome Glisse /* ASIC INIT 4 */ 3080771fe6b9SJerome Glisse table = 3081771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE); 3082771fe6b9SJerome Glisse if (table) 3083771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3084771fe6b9SJerome Glisse 3085771fe6b9SJerome Glisse /* RAM RESET */ 3086771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE); 3087771fe6b9SJerome Glisse if (table) 3088771fe6b9SJerome Glisse combios_parse_ram_reset_table(dev, table); 3089771fe6b9SJerome Glisse 3090771fe6b9SJerome Glisse /* ASIC INIT 3 */ 3091771fe6b9SJerome Glisse table = 3092771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE); 3093771fe6b9SJerome Glisse if (table) 3094771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3095771fe6b9SJerome Glisse 3096771fe6b9SJerome Glisse /* write CONFIG_MEMSIZE */ 3097771fe6b9SJerome Glisse combios_write_ram_size(dev); 3098771fe6b9SJerome Glisse } 3099771fe6b9SJerome Glisse 3100580b4fffSDave Airlie /* quirk for rs4xx HP nx6125 laptop to make it resume 3101580b4fffSDave Airlie * - it hangs on resume inside the dynclk 1 table. 3102580b4fffSDave Airlie */ 3103580b4fffSDave Airlie if (rdev->family == CHIP_RS480 && 3104580b4fffSDave Airlie rdev->pdev->subsystem_vendor == 0x103c && 3105580b4fffSDave Airlie rdev->pdev->subsystem_device == 0x308b) 3106580b4fffSDave Airlie return; 3107580b4fffSDave Airlie 310852fa2bbcSAlex Deucher /* quirk for rs4xx HP dv5000 laptop to make it resume 310952fa2bbcSAlex Deucher * - it hangs on resume inside the dynclk 1 table. 311052fa2bbcSAlex Deucher */ 311152fa2bbcSAlex Deucher if (rdev->family == CHIP_RS480 && 311252fa2bbcSAlex Deucher rdev->pdev->subsystem_vendor == 0x103c && 311352fa2bbcSAlex Deucher rdev->pdev->subsystem_device == 0x30a4) 311452fa2bbcSAlex Deucher return; 311552fa2bbcSAlex Deucher 3116771fe6b9SJerome Glisse /* DYN CLK 1 */ 3117771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 3118771fe6b9SJerome Glisse if (table) 3119771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 3120771fe6b9SJerome Glisse 3121771fe6b9SJerome Glisse } 3122771fe6b9SJerome Glisse 3123771fe6b9SJerome Glisse void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev) 3124771fe6b9SJerome Glisse { 3125771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3126771fe6b9SJerome Glisse uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch; 3127771fe6b9SJerome Glisse 3128771fe6b9SJerome Glisse bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); 3129771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3130771fe6b9SJerome Glisse bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH); 3131771fe6b9SJerome Glisse 3132771fe6b9SJerome Glisse /* let the bios control the backlight */ 3133771fe6b9SJerome Glisse bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN; 3134771fe6b9SJerome Glisse 3135771fe6b9SJerome Glisse /* tell the bios not to handle mode switching */ 3136771fe6b9SJerome Glisse bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS | 3137771fe6b9SJerome Glisse RADEON_ACC_MODE_CHANGE); 3138771fe6b9SJerome Glisse 3139771fe6b9SJerome Glisse /* tell the bios a driver is loaded */ 3140771fe6b9SJerome Glisse bios_7_scratch |= RADEON_DRV_LOADED; 3141771fe6b9SJerome Glisse 3142771fe6b9SJerome Glisse WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch); 3143771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3144771fe6b9SJerome Glisse WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch); 3145771fe6b9SJerome Glisse } 3146771fe6b9SJerome Glisse 3147771fe6b9SJerome Glisse void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock) 3148771fe6b9SJerome Glisse { 3149771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3150771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3151771fe6b9SJerome Glisse uint32_t bios_6_scratch; 3152771fe6b9SJerome Glisse 3153771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3154771fe6b9SJerome Glisse 3155771fe6b9SJerome Glisse if (lock) 3156771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DRIVER_CRITICAL; 3157771fe6b9SJerome Glisse else 3158771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DRIVER_CRITICAL; 3159771fe6b9SJerome Glisse 3160771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3161771fe6b9SJerome Glisse } 3162771fe6b9SJerome Glisse 3163771fe6b9SJerome Glisse void 3164771fe6b9SJerome Glisse radeon_combios_connected_scratch_regs(struct drm_connector *connector, 3165771fe6b9SJerome Glisse struct drm_encoder *encoder, 3166771fe6b9SJerome Glisse bool connected) 3167771fe6b9SJerome Glisse { 3168771fe6b9SJerome Glisse struct drm_device *dev = connector->dev; 3169771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3170771fe6b9SJerome Glisse struct radeon_connector *radeon_connector = 3171771fe6b9SJerome Glisse to_radeon_connector(connector); 3172771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3173771fe6b9SJerome Glisse uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH); 3174771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3175771fe6b9SJerome Glisse 3176771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) && 3177771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) { 3178771fe6b9SJerome Glisse if (connected) { 3179d9fdaafbSDave Airlie DRM_DEBUG_KMS("TV1 connected\n"); 3180771fe6b9SJerome Glisse /* fix me */ 3181771fe6b9SJerome Glisse bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO; 3182771fe6b9SJerome Glisse /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */ 3183771fe6b9SJerome Glisse bios_5_scratch |= RADEON_TV1_ON; 3184771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_TV1; 3185771fe6b9SJerome Glisse } else { 3186d9fdaafbSDave Airlie DRM_DEBUG_KMS("TV1 disconnected\n"); 3187771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK; 3188771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_ON; 3189771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_TV1; 3190771fe6b9SJerome Glisse } 3191771fe6b9SJerome Glisse } 3192771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) && 3193771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) { 3194771fe6b9SJerome Glisse if (connected) { 3195d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD1 connected\n"); 3196771fe6b9SJerome Glisse bios_4_scratch |= RADEON_LCD1_ATTACHED; 3197771fe6b9SJerome Glisse bios_5_scratch |= RADEON_LCD1_ON; 3198771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_LCD1; 3199771fe6b9SJerome Glisse } else { 3200d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD1 disconnected\n"); 3201771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_LCD1_ATTACHED; 3202771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_ON; 3203771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_LCD1; 3204771fe6b9SJerome Glisse } 3205771fe6b9SJerome Glisse } 3206771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) && 3207771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) { 3208771fe6b9SJerome Glisse if (connected) { 3209d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT1 connected\n"); 3210771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR; 3211771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT1_ON; 3212771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT1; 3213771fe6b9SJerome Glisse } else { 3214d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT1 disconnected\n"); 3215771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK; 3216771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_ON; 3217771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT1; 3218771fe6b9SJerome Glisse } 3219771fe6b9SJerome Glisse } 3220771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) && 3221771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) { 3222771fe6b9SJerome Glisse if (connected) { 3223d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT2 connected\n"); 3224771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR; 3225771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT2_ON; 3226771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT2; 3227771fe6b9SJerome Glisse } else { 3228d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT2 disconnected\n"); 3229771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK; 3230771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_ON; 3231771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT2; 3232771fe6b9SJerome Glisse } 3233771fe6b9SJerome Glisse } 3234771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) && 3235771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) { 3236771fe6b9SJerome Glisse if (connected) { 3237d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP1 connected\n"); 3238771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP1_ATTACHED; 3239771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP1_ON; 3240771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP1; 3241771fe6b9SJerome Glisse } else { 3242d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP1 disconnected\n"); 3243771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP1_ATTACHED; 3244771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_ON; 3245771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP1; 3246771fe6b9SJerome Glisse } 3247771fe6b9SJerome Glisse } 3248771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) && 3249771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) { 3250771fe6b9SJerome Glisse if (connected) { 3251d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP2 connected\n"); 3252771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP2_ATTACHED; 3253771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP2_ON; 3254771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP2; 3255771fe6b9SJerome Glisse } else { 3256d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP2 disconnected\n"); 3257771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP2_ATTACHED; 3258771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_ON; 3259771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP2; 3260771fe6b9SJerome Glisse } 3261771fe6b9SJerome Glisse } 3262771fe6b9SJerome Glisse WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch); 3263771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3264771fe6b9SJerome Glisse } 3265771fe6b9SJerome Glisse 3266771fe6b9SJerome Glisse void 3267771fe6b9SJerome Glisse radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc) 3268771fe6b9SJerome Glisse { 3269771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3270771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3271771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3272771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3273771fe6b9SJerome Glisse 3274771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { 3275771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_CRTC_MASK; 3276771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT); 3277771fe6b9SJerome Glisse } 3278771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { 3279771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK; 3280771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT); 3281771fe6b9SJerome Glisse } 3282771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { 3283771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK; 3284771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT); 3285771fe6b9SJerome Glisse } 3286771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { 3287771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK; 3288771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT); 3289771fe6b9SJerome Glisse } 3290771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { 3291771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK; 3292771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT); 3293771fe6b9SJerome Glisse } 3294771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { 3295771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK; 3296771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT); 3297771fe6b9SJerome Glisse } 3298771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3299771fe6b9SJerome Glisse } 3300771fe6b9SJerome Glisse 3301771fe6b9SJerome Glisse void 3302771fe6b9SJerome Glisse radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on) 3303771fe6b9SJerome Glisse { 3304771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3305771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3306771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3307771fe6b9SJerome Glisse uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3308771fe6b9SJerome Glisse 3309771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { 3310771fe6b9SJerome Glisse if (on) 3311771fe6b9SJerome Glisse bios_6_scratch |= RADEON_TV_DPMS_ON; 3312771fe6b9SJerome Glisse else 3313771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_TV_DPMS_ON; 3314771fe6b9SJerome Glisse } 3315771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) { 3316771fe6b9SJerome Glisse if (on) 3317771fe6b9SJerome Glisse bios_6_scratch |= RADEON_CRT_DPMS_ON; 3318771fe6b9SJerome Glisse else 3319771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_CRT_DPMS_ON; 3320771fe6b9SJerome Glisse } 3321771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 3322771fe6b9SJerome Glisse if (on) 3323771fe6b9SJerome Glisse bios_6_scratch |= RADEON_LCD_DPMS_ON; 3324771fe6b9SJerome Glisse else 3325771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_LCD_DPMS_ON; 3326771fe6b9SJerome Glisse } 3327771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 3328771fe6b9SJerome Glisse if (on) 3329771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DFP_DPMS_ON; 3330771fe6b9SJerome Glisse else 3331771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DFP_DPMS_ON; 3332771fe6b9SJerome Glisse } 3333771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3334771fe6b9SJerome Glisse } 3335