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 42771fe6b9SJerome Glisse radeon_get_encoder_id(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 58771fe6b9SJerome Glisse radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_id, 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 153771fe6b9SJerome Glisse switch (table) { 154771fe6b9SJerome Glisse /* absolute offset tables */ 155771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_1_TABLE: 156771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0xc); 157771fe6b9SJerome Glisse if (check_offset) 158771fe6b9SJerome Glisse offset = check_offset; 159771fe6b9SJerome Glisse break; 160771fe6b9SJerome Glisse case COMBIOS_BIOS_SUPPORT_TABLE: 161771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x14); 162771fe6b9SJerome Glisse if (check_offset) 163771fe6b9SJerome Glisse offset = check_offset; 164771fe6b9SJerome Glisse break; 165771fe6b9SJerome Glisse case COMBIOS_DAC_PROGRAMMING_TABLE: 166771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x2a); 167771fe6b9SJerome Glisse if (check_offset) 168771fe6b9SJerome Glisse offset = check_offset; 169771fe6b9SJerome Glisse break; 170771fe6b9SJerome Glisse case COMBIOS_MAX_COLOR_DEPTH_TABLE: 171771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x2c); 172771fe6b9SJerome Glisse if (check_offset) 173771fe6b9SJerome Glisse offset = check_offset; 174771fe6b9SJerome Glisse break; 175771fe6b9SJerome Glisse case COMBIOS_CRTC_INFO_TABLE: 176771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x2e); 177771fe6b9SJerome Glisse if (check_offset) 178771fe6b9SJerome Glisse offset = check_offset; 179771fe6b9SJerome Glisse break; 180771fe6b9SJerome Glisse case COMBIOS_PLL_INFO_TABLE: 181771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x30); 182771fe6b9SJerome Glisse if (check_offset) 183771fe6b9SJerome Glisse offset = check_offset; 184771fe6b9SJerome Glisse break; 185771fe6b9SJerome Glisse case COMBIOS_TV_INFO_TABLE: 186771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x32); 187771fe6b9SJerome Glisse if (check_offset) 188771fe6b9SJerome Glisse offset = check_offset; 189771fe6b9SJerome Glisse break; 190771fe6b9SJerome Glisse case COMBIOS_DFP_INFO_TABLE: 191771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x34); 192771fe6b9SJerome Glisse if (check_offset) 193771fe6b9SJerome Glisse offset = check_offset; 194771fe6b9SJerome Glisse break; 195771fe6b9SJerome Glisse case COMBIOS_HW_CONFIG_INFO_TABLE: 196771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x36); 197771fe6b9SJerome Glisse if (check_offset) 198771fe6b9SJerome Glisse offset = check_offset; 199771fe6b9SJerome Glisse break; 200771fe6b9SJerome Glisse case COMBIOS_MULTIMEDIA_INFO_TABLE: 201771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x38); 202771fe6b9SJerome Glisse if (check_offset) 203771fe6b9SJerome Glisse offset = check_offset; 204771fe6b9SJerome Glisse break; 205771fe6b9SJerome Glisse case COMBIOS_TV_STD_PATCH_TABLE: 206771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x3e); 207771fe6b9SJerome Glisse if (check_offset) 208771fe6b9SJerome Glisse offset = check_offset; 209771fe6b9SJerome Glisse break; 210771fe6b9SJerome Glisse case COMBIOS_LCD_INFO_TABLE: 211771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x40); 212771fe6b9SJerome Glisse if (check_offset) 213771fe6b9SJerome Glisse offset = check_offset; 214771fe6b9SJerome Glisse break; 215771fe6b9SJerome Glisse case COMBIOS_MOBILE_INFO_TABLE: 216771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x42); 217771fe6b9SJerome Glisse if (check_offset) 218771fe6b9SJerome Glisse offset = check_offset; 219771fe6b9SJerome Glisse break; 220771fe6b9SJerome Glisse case COMBIOS_PLL_INIT_TABLE: 221771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x46); 222771fe6b9SJerome Glisse if (check_offset) 223771fe6b9SJerome Glisse offset = check_offset; 224771fe6b9SJerome Glisse break; 225771fe6b9SJerome Glisse case COMBIOS_MEM_CONFIG_TABLE: 226771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x48); 227771fe6b9SJerome Glisse if (check_offset) 228771fe6b9SJerome Glisse offset = check_offset; 229771fe6b9SJerome Glisse break; 230771fe6b9SJerome Glisse case COMBIOS_SAVE_MASK_TABLE: 231771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x4a); 232771fe6b9SJerome Glisse if (check_offset) 233771fe6b9SJerome Glisse offset = check_offset; 234771fe6b9SJerome Glisse break; 235771fe6b9SJerome Glisse case COMBIOS_HARDCODED_EDID_TABLE: 236771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x4c); 237771fe6b9SJerome Glisse if (check_offset) 238771fe6b9SJerome Glisse offset = check_offset; 239771fe6b9SJerome Glisse break; 240771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_2_TABLE: 241771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x4e); 242771fe6b9SJerome Glisse if (check_offset) 243771fe6b9SJerome Glisse offset = check_offset; 244771fe6b9SJerome Glisse break; 245771fe6b9SJerome Glisse case COMBIOS_CONNECTOR_INFO_TABLE: 246771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x50); 247771fe6b9SJerome Glisse if (check_offset) 248771fe6b9SJerome Glisse offset = check_offset; 249771fe6b9SJerome Glisse break; 250771fe6b9SJerome Glisse case COMBIOS_DYN_CLK_1_TABLE: 251771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x52); 252771fe6b9SJerome Glisse if (check_offset) 253771fe6b9SJerome Glisse offset = check_offset; 254771fe6b9SJerome Glisse break; 255771fe6b9SJerome Glisse case COMBIOS_RESERVED_MEM_TABLE: 256771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x54); 257771fe6b9SJerome Glisse if (check_offset) 258771fe6b9SJerome Glisse offset = check_offset; 259771fe6b9SJerome Glisse break; 260771fe6b9SJerome Glisse case COMBIOS_EXT_TMDS_INFO_TABLE: 261771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x58); 262771fe6b9SJerome Glisse if (check_offset) 263771fe6b9SJerome Glisse offset = check_offset; 264771fe6b9SJerome Glisse break; 265771fe6b9SJerome Glisse case COMBIOS_MEM_CLK_INFO_TABLE: 266771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x5a); 267771fe6b9SJerome Glisse if (check_offset) 268771fe6b9SJerome Glisse offset = check_offset; 269771fe6b9SJerome Glisse break; 270771fe6b9SJerome Glisse case COMBIOS_EXT_DAC_INFO_TABLE: 271771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x5c); 272771fe6b9SJerome Glisse if (check_offset) 273771fe6b9SJerome Glisse offset = check_offset; 274771fe6b9SJerome Glisse break; 275771fe6b9SJerome Glisse case COMBIOS_MISC_INFO_TABLE: 276771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x5e); 277771fe6b9SJerome Glisse if (check_offset) 278771fe6b9SJerome Glisse offset = check_offset; 279771fe6b9SJerome Glisse break; 280771fe6b9SJerome Glisse case COMBIOS_CRT_INFO_TABLE: 281771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x60); 282771fe6b9SJerome Glisse if (check_offset) 283771fe6b9SJerome Glisse offset = check_offset; 284771fe6b9SJerome Glisse break; 285771fe6b9SJerome Glisse case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE: 286771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x62); 287771fe6b9SJerome Glisse if (check_offset) 288771fe6b9SJerome Glisse offset = check_offset; 289771fe6b9SJerome Glisse break; 290771fe6b9SJerome Glisse case COMBIOS_COMPONENT_VIDEO_INFO_TABLE: 291771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x64); 292771fe6b9SJerome Glisse if (check_offset) 293771fe6b9SJerome Glisse offset = check_offset; 294771fe6b9SJerome Glisse break; 295771fe6b9SJerome Glisse case COMBIOS_FAN_SPEED_INFO_TABLE: 296771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x66); 297771fe6b9SJerome Glisse if (check_offset) 298771fe6b9SJerome Glisse offset = check_offset; 299771fe6b9SJerome Glisse break; 300771fe6b9SJerome Glisse case COMBIOS_OVERDRIVE_INFO_TABLE: 301771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x68); 302771fe6b9SJerome Glisse if (check_offset) 303771fe6b9SJerome Glisse offset = check_offset; 304771fe6b9SJerome Glisse break; 305771fe6b9SJerome Glisse case COMBIOS_OEM_INFO_TABLE: 306771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x6a); 307771fe6b9SJerome Glisse if (check_offset) 308771fe6b9SJerome Glisse offset = check_offset; 309771fe6b9SJerome Glisse break; 310771fe6b9SJerome Glisse case COMBIOS_DYN_CLK_2_TABLE: 311771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x6c); 312771fe6b9SJerome Glisse if (check_offset) 313771fe6b9SJerome Glisse offset = check_offset; 314771fe6b9SJerome Glisse break; 315771fe6b9SJerome Glisse case COMBIOS_POWER_CONNECTOR_INFO_TABLE: 316771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x6e); 317771fe6b9SJerome Glisse if (check_offset) 318771fe6b9SJerome Glisse offset = check_offset; 319771fe6b9SJerome Glisse break; 320771fe6b9SJerome Glisse case COMBIOS_I2C_INFO_TABLE: 321771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x70); 322771fe6b9SJerome Glisse if (check_offset) 323771fe6b9SJerome Glisse offset = check_offset; 324771fe6b9SJerome Glisse break; 325771fe6b9SJerome Glisse /* relative offset tables */ 326771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_3_TABLE: /* offset from misc info */ 327771fe6b9SJerome Glisse check_offset = 328771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 329771fe6b9SJerome Glisse if (check_offset) { 330771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 331771fe6b9SJerome Glisse if (rev > 0) { 332771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x3); 333771fe6b9SJerome Glisse if (check_offset) 334771fe6b9SJerome Glisse offset = check_offset; 335771fe6b9SJerome Glisse } 336771fe6b9SJerome Glisse } 337771fe6b9SJerome Glisse break; 338771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_4_TABLE: /* offset from misc info */ 339771fe6b9SJerome Glisse check_offset = 340771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 341771fe6b9SJerome Glisse if (check_offset) { 342771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 343771fe6b9SJerome Glisse if (rev > 0) { 344771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x5); 345771fe6b9SJerome Glisse if (check_offset) 346771fe6b9SJerome Glisse offset = check_offset; 347771fe6b9SJerome Glisse } 348771fe6b9SJerome Glisse } 349771fe6b9SJerome Glisse break; 350771fe6b9SJerome Glisse case COMBIOS_DETECTED_MEM_TABLE: /* offset from misc info */ 351771fe6b9SJerome Glisse check_offset = 352771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 353771fe6b9SJerome Glisse if (check_offset) { 354771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 355771fe6b9SJerome Glisse if (rev > 0) { 356771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x7); 357771fe6b9SJerome Glisse if (check_offset) 358771fe6b9SJerome Glisse offset = check_offset; 359771fe6b9SJerome Glisse } 360771fe6b9SJerome Glisse } 361771fe6b9SJerome Glisse break; 362771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_5_TABLE: /* offset from misc info */ 363771fe6b9SJerome Glisse check_offset = 364771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 365771fe6b9SJerome Glisse if (check_offset) { 366771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 367771fe6b9SJerome Glisse if (rev == 2) { 368771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x9); 369771fe6b9SJerome Glisse if (check_offset) 370771fe6b9SJerome Glisse offset = check_offset; 371771fe6b9SJerome Glisse } 372771fe6b9SJerome Glisse } 373771fe6b9SJerome Glisse break; 374771fe6b9SJerome Glisse case COMBIOS_RAM_RESET_TABLE: /* offset from mem config */ 375771fe6b9SJerome Glisse check_offset = 376771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 377771fe6b9SJerome Glisse if (check_offset) { 378771fe6b9SJerome Glisse while (RBIOS8(check_offset++)); 379771fe6b9SJerome Glisse check_offset += 2; 380771fe6b9SJerome Glisse if (check_offset) 381771fe6b9SJerome Glisse offset = check_offset; 382771fe6b9SJerome Glisse } 383771fe6b9SJerome Glisse break; 384771fe6b9SJerome Glisse case COMBIOS_POWERPLAY_INFO_TABLE: /* offset from mobile info */ 385771fe6b9SJerome Glisse check_offset = 386771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 387771fe6b9SJerome Glisse if (check_offset) { 388771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x11); 389771fe6b9SJerome Glisse if (check_offset) 390771fe6b9SJerome Glisse offset = check_offset; 391771fe6b9SJerome Glisse } 392771fe6b9SJerome Glisse break; 393771fe6b9SJerome Glisse case COMBIOS_GPIO_INFO_TABLE: /* offset from mobile info */ 394771fe6b9SJerome Glisse check_offset = 395771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 396771fe6b9SJerome Glisse if (check_offset) { 397771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x13); 398771fe6b9SJerome Glisse if (check_offset) 399771fe6b9SJerome Glisse offset = check_offset; 400771fe6b9SJerome Glisse } 401771fe6b9SJerome Glisse break; 402771fe6b9SJerome Glisse case COMBIOS_LCD_DDC_INFO_TABLE: /* offset from mobile info */ 403771fe6b9SJerome Glisse check_offset = 404771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 405771fe6b9SJerome Glisse if (check_offset) { 406771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x15); 407771fe6b9SJerome Glisse if (check_offset) 408771fe6b9SJerome Glisse offset = check_offset; 409771fe6b9SJerome Glisse } 410771fe6b9SJerome Glisse break; 411771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_TABLE: /* offset from mobile info */ 412771fe6b9SJerome Glisse check_offset = 413771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 414771fe6b9SJerome Glisse if (check_offset) { 415771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x17); 416771fe6b9SJerome Glisse if (check_offset) 417771fe6b9SJerome Glisse offset = check_offset; 418771fe6b9SJerome Glisse } 419771fe6b9SJerome Glisse break; 420771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_ON_TABLE: /* offset from tmds power */ 421771fe6b9SJerome Glisse check_offset = 422771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); 423771fe6b9SJerome Glisse if (check_offset) { 424771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x2); 425771fe6b9SJerome Glisse if (check_offset) 426771fe6b9SJerome Glisse offset = check_offset; 427771fe6b9SJerome Glisse } 428771fe6b9SJerome Glisse break; 429771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_OFF_TABLE: /* offset from tmds power */ 430771fe6b9SJerome Glisse check_offset = 431771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); 432771fe6b9SJerome Glisse if (check_offset) { 433771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x4); 434771fe6b9SJerome Glisse if (check_offset) 435771fe6b9SJerome Glisse offset = check_offset; 436771fe6b9SJerome Glisse } 437771fe6b9SJerome Glisse break; 438771fe6b9SJerome Glisse default: 439771fe6b9SJerome Glisse break; 440771fe6b9SJerome Glisse } 441771fe6b9SJerome Glisse 442771fe6b9SJerome Glisse return offset; 443771fe6b9SJerome Glisse 444771fe6b9SJerome Glisse } 445771fe6b9SJerome Glisse 4466a93cb25SAlex Deucher static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev, 4476a93cb25SAlex Deucher int ddc_line) 448771fe6b9SJerome Glisse { 449771fe6b9SJerome Glisse struct radeon_i2c_bus_rec i2c; 450771fe6b9SJerome Glisse 4516a93cb25SAlex Deucher if (ddc_line == RADEON_GPIOPAD_MASK) { 4526a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_GPIOPAD_MASK; 4536a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_GPIOPAD_MASK; 4546a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_GPIOPAD_A; 4556a93cb25SAlex Deucher i2c.a_data_reg = RADEON_GPIOPAD_A; 4566a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_GPIOPAD_EN; 4576a93cb25SAlex Deucher i2c.en_data_reg = RADEON_GPIOPAD_EN; 4586a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_GPIOPAD_Y; 4596a93cb25SAlex Deucher i2c.y_data_reg = RADEON_GPIOPAD_Y; 4606a93cb25SAlex Deucher } else if (ddc_line == RADEON_MDGPIO_MASK) { 4616a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_MDGPIO_MASK; 4626a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_MDGPIO_MASK; 4636a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_MDGPIO_A; 4646a93cb25SAlex Deucher i2c.a_data_reg = RADEON_MDGPIO_A; 4656a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_MDGPIO_EN; 4666a93cb25SAlex Deucher i2c.en_data_reg = RADEON_MDGPIO_EN; 4676a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_MDGPIO_Y; 4686a93cb25SAlex Deucher i2c.y_data_reg = RADEON_MDGPIO_Y; 4696a93cb25SAlex Deucher } else { 470771fe6b9SJerome Glisse i2c.mask_clk_mask = RADEON_GPIO_EN_1; 471771fe6b9SJerome Glisse i2c.mask_data_mask = RADEON_GPIO_EN_0; 472771fe6b9SJerome Glisse i2c.a_clk_mask = RADEON_GPIO_A_1; 473771fe6b9SJerome Glisse i2c.a_data_mask = RADEON_GPIO_A_0; 4749b9fe724SAlex Deucher i2c.en_clk_mask = RADEON_GPIO_EN_1; 4759b9fe724SAlex Deucher i2c.en_data_mask = RADEON_GPIO_EN_0; 4769b9fe724SAlex Deucher i2c.y_clk_mask = RADEON_GPIO_Y_1; 4779b9fe724SAlex Deucher i2c.y_data_mask = RADEON_GPIO_Y_0; 4786a93cb25SAlex Deucher 479771fe6b9SJerome Glisse i2c.mask_clk_reg = ddc_line; 480771fe6b9SJerome Glisse i2c.mask_data_reg = ddc_line; 481771fe6b9SJerome Glisse i2c.a_clk_reg = ddc_line; 482771fe6b9SJerome Glisse i2c.a_data_reg = ddc_line; 4839b9fe724SAlex Deucher i2c.en_clk_reg = ddc_line; 4849b9fe724SAlex Deucher i2c.en_data_reg = ddc_line; 4859b9fe724SAlex Deucher i2c.y_clk_reg = ddc_line; 4869b9fe724SAlex Deucher i2c.y_data_reg = ddc_line; 487771fe6b9SJerome Glisse } 488771fe6b9SJerome Glisse 4896a93cb25SAlex Deucher if (rdev->family < CHIP_R200) 4906a93cb25SAlex Deucher i2c.hw_capable = false; 4916a93cb25SAlex Deucher else { 4926a93cb25SAlex Deucher switch (ddc_line) { 4936a93cb25SAlex Deucher case RADEON_GPIO_VGA_DDC: 4946a93cb25SAlex Deucher case RADEON_GPIO_DVI_DDC: 4956a93cb25SAlex Deucher i2c.hw_capable = true; 4966a93cb25SAlex Deucher break; 4976a93cb25SAlex Deucher case RADEON_GPIO_MONID: 4986a93cb25SAlex Deucher /* hw i2c on RADEON_GPIO_MONID doesn't seem to work 4996a93cb25SAlex Deucher * reliably on some pre-r4xx hardware; not sure why. 5006a93cb25SAlex Deucher */ 5016a93cb25SAlex Deucher i2c.hw_capable = false; 5026a93cb25SAlex Deucher break; 5036a93cb25SAlex Deucher default: 5046a93cb25SAlex Deucher i2c.hw_capable = false; 5056a93cb25SAlex Deucher break; 5066a93cb25SAlex Deucher } 5076a93cb25SAlex Deucher } 5086a93cb25SAlex Deucher i2c.mm_i2c = false; 5096a93cb25SAlex Deucher i2c.i2c_id = 0; 5106a93cb25SAlex Deucher 511771fe6b9SJerome Glisse if (ddc_line) 512771fe6b9SJerome Glisse i2c.valid = true; 513771fe6b9SJerome Glisse else 514771fe6b9SJerome Glisse i2c.valid = false; 515771fe6b9SJerome Glisse 516771fe6b9SJerome Glisse return i2c; 517771fe6b9SJerome Glisse } 518771fe6b9SJerome Glisse 519771fe6b9SJerome Glisse bool radeon_combios_get_clock_info(struct drm_device *dev) 520771fe6b9SJerome Glisse { 521771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 522771fe6b9SJerome Glisse uint16_t pll_info; 523771fe6b9SJerome Glisse struct radeon_pll *p1pll = &rdev->clock.p1pll; 524771fe6b9SJerome Glisse struct radeon_pll *p2pll = &rdev->clock.p2pll; 525771fe6b9SJerome Glisse struct radeon_pll *spll = &rdev->clock.spll; 526771fe6b9SJerome Glisse struct radeon_pll *mpll = &rdev->clock.mpll; 527771fe6b9SJerome Glisse int8_t rev; 528771fe6b9SJerome Glisse uint16_t sclk, mclk; 529771fe6b9SJerome Glisse 530771fe6b9SJerome Glisse if (rdev->bios == NULL) 5314b30b870SDave Airlie return false; 532771fe6b9SJerome Glisse 533771fe6b9SJerome Glisse pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE); 534771fe6b9SJerome Glisse if (pll_info) { 535771fe6b9SJerome Glisse rev = RBIOS8(pll_info); 536771fe6b9SJerome Glisse 537771fe6b9SJerome Glisse /* pixel clocks */ 538771fe6b9SJerome Glisse p1pll->reference_freq = RBIOS16(pll_info + 0xe); 539771fe6b9SJerome Glisse p1pll->reference_div = RBIOS16(pll_info + 0x10); 540771fe6b9SJerome Glisse p1pll->pll_out_min = RBIOS32(pll_info + 0x12); 541771fe6b9SJerome Glisse p1pll->pll_out_max = RBIOS32(pll_info + 0x16); 542771fe6b9SJerome Glisse 543771fe6b9SJerome Glisse if (rev > 9) { 544771fe6b9SJerome Glisse p1pll->pll_in_min = RBIOS32(pll_info + 0x36); 545771fe6b9SJerome Glisse p1pll->pll_in_max = RBIOS32(pll_info + 0x3a); 546771fe6b9SJerome Glisse } else { 547771fe6b9SJerome Glisse p1pll->pll_in_min = 40; 548771fe6b9SJerome Glisse p1pll->pll_in_max = 500; 549771fe6b9SJerome Glisse } 550771fe6b9SJerome Glisse *p2pll = *p1pll; 551771fe6b9SJerome Glisse 552771fe6b9SJerome Glisse /* system clock */ 553771fe6b9SJerome Glisse spll->reference_freq = RBIOS16(pll_info + 0x1a); 554771fe6b9SJerome Glisse spll->reference_div = RBIOS16(pll_info + 0x1c); 555771fe6b9SJerome Glisse spll->pll_out_min = RBIOS32(pll_info + 0x1e); 556771fe6b9SJerome Glisse spll->pll_out_max = RBIOS32(pll_info + 0x22); 557771fe6b9SJerome Glisse 558771fe6b9SJerome Glisse if (rev > 10) { 559771fe6b9SJerome Glisse spll->pll_in_min = RBIOS32(pll_info + 0x48); 560771fe6b9SJerome Glisse spll->pll_in_max = RBIOS32(pll_info + 0x4c); 561771fe6b9SJerome Glisse } else { 562771fe6b9SJerome Glisse /* ??? */ 563771fe6b9SJerome Glisse spll->pll_in_min = 40; 564771fe6b9SJerome Glisse spll->pll_in_max = 500; 565771fe6b9SJerome Glisse } 566771fe6b9SJerome Glisse 567771fe6b9SJerome Glisse /* memory clock */ 568771fe6b9SJerome Glisse mpll->reference_freq = RBIOS16(pll_info + 0x26); 569771fe6b9SJerome Glisse mpll->reference_div = RBIOS16(pll_info + 0x28); 570771fe6b9SJerome Glisse mpll->pll_out_min = RBIOS32(pll_info + 0x2a); 571771fe6b9SJerome Glisse mpll->pll_out_max = RBIOS32(pll_info + 0x2e); 572771fe6b9SJerome Glisse 573771fe6b9SJerome Glisse if (rev > 10) { 574771fe6b9SJerome Glisse mpll->pll_in_min = RBIOS32(pll_info + 0x5a); 575771fe6b9SJerome Glisse mpll->pll_in_max = RBIOS32(pll_info + 0x5e); 576771fe6b9SJerome Glisse } else { 577771fe6b9SJerome Glisse /* ??? */ 578771fe6b9SJerome Glisse mpll->pll_in_min = 40; 579771fe6b9SJerome Glisse mpll->pll_in_max = 500; 580771fe6b9SJerome Glisse } 581771fe6b9SJerome Glisse 582771fe6b9SJerome Glisse /* default sclk/mclk */ 583771fe6b9SJerome Glisse sclk = RBIOS16(pll_info + 0xa); 584771fe6b9SJerome Glisse mclk = RBIOS16(pll_info + 0x8); 585771fe6b9SJerome Glisse if (sclk == 0) 586771fe6b9SJerome Glisse sclk = 200 * 100; 587771fe6b9SJerome Glisse if (mclk == 0) 588771fe6b9SJerome Glisse mclk = 200 * 100; 589771fe6b9SJerome Glisse 590771fe6b9SJerome Glisse rdev->clock.default_sclk = sclk; 591771fe6b9SJerome Glisse rdev->clock.default_mclk = mclk; 592771fe6b9SJerome Glisse 593771fe6b9SJerome Glisse return true; 594771fe6b9SJerome Glisse } 595771fe6b9SJerome Glisse return false; 596771fe6b9SJerome Glisse } 597771fe6b9SJerome Glisse 598*06b6476dSAlex Deucher bool radeon_combios_sideport_present(struct radeon_device *rdev) 599*06b6476dSAlex Deucher { 600*06b6476dSAlex Deucher struct drm_device *dev = rdev->ddev; 601*06b6476dSAlex Deucher u16 igp_info; 602*06b6476dSAlex Deucher 603*06b6476dSAlex Deucher igp_info = combios_get_table_offset(dev, COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE); 604*06b6476dSAlex Deucher 605*06b6476dSAlex Deucher if (igp_info) { 606*06b6476dSAlex Deucher if (RBIOS16(igp_info + 0x4)) 607*06b6476dSAlex Deucher return true; 608*06b6476dSAlex Deucher } 609*06b6476dSAlex Deucher return false; 610*06b6476dSAlex Deucher } 611*06b6476dSAlex Deucher 612246263ccSAlex Deucher static const uint32_t default_primarydac_adj[CHIP_LAST] = { 613246263ccSAlex Deucher 0x00000808, /* r100 */ 614246263ccSAlex Deucher 0x00000808, /* rv100 */ 615246263ccSAlex Deucher 0x00000808, /* rs100 */ 616246263ccSAlex Deucher 0x00000808, /* rv200 */ 617246263ccSAlex Deucher 0x00000808, /* rs200 */ 618246263ccSAlex Deucher 0x00000808, /* r200 */ 619246263ccSAlex Deucher 0x00000808, /* rv250 */ 620246263ccSAlex Deucher 0x00000000, /* rs300 */ 621246263ccSAlex Deucher 0x00000808, /* rv280 */ 622246263ccSAlex Deucher 0x00000808, /* r300 */ 623246263ccSAlex Deucher 0x00000808, /* r350 */ 624246263ccSAlex Deucher 0x00000808, /* rv350 */ 625246263ccSAlex Deucher 0x00000808, /* rv380 */ 626246263ccSAlex Deucher 0x00000808, /* r420 */ 627246263ccSAlex Deucher 0x00000808, /* r423 */ 628246263ccSAlex Deucher 0x00000808, /* rv410 */ 629246263ccSAlex Deucher 0x00000000, /* rs400 */ 630246263ccSAlex Deucher 0x00000000, /* rs480 */ 631246263ccSAlex Deucher }; 632246263ccSAlex Deucher 633246263ccSAlex Deucher static void radeon_legacy_get_primary_dac_info_from_table(struct radeon_device *rdev, 634246263ccSAlex Deucher struct radeon_encoder_primary_dac *p_dac) 635246263ccSAlex Deucher { 636246263ccSAlex Deucher p_dac->ps2_pdac_adj = default_primarydac_adj[rdev->family]; 637246263ccSAlex Deucher return; 638246263ccSAlex Deucher } 639246263ccSAlex Deucher 640771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct 641771fe6b9SJerome Glisse radeon_encoder 642771fe6b9SJerome Glisse *encoder) 643771fe6b9SJerome Glisse { 644771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 645771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 646771fe6b9SJerome Glisse uint16_t dac_info; 647771fe6b9SJerome Glisse uint8_t rev, bg, dac; 648771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *p_dac = NULL; 649246263ccSAlex Deucher int found = 0; 650771fe6b9SJerome Glisse 651246263ccSAlex Deucher p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), 652771fe6b9SJerome Glisse GFP_KERNEL); 653771fe6b9SJerome Glisse 654771fe6b9SJerome Glisse if (!p_dac) 655771fe6b9SJerome Glisse return NULL; 656771fe6b9SJerome Glisse 657246263ccSAlex Deucher if (rdev->bios == NULL) 658246263ccSAlex Deucher goto out; 659246263ccSAlex Deucher 660246263ccSAlex Deucher /* check CRT table */ 661246263ccSAlex Deucher dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 662246263ccSAlex Deucher if (dac_info) { 663771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 664771fe6b9SJerome Glisse if (rev < 2) { 665771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 666771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf; 667771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 668771fe6b9SJerome Glisse } else { 669771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 670771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x3) & 0xf; 671771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 672771fe6b9SJerome Glisse } 673246263ccSAlex Deucher found = 1; 674771fe6b9SJerome Glisse } 675771fe6b9SJerome Glisse 676246263ccSAlex Deucher out: 677246263ccSAlex Deucher if (!found) /* fallback to defaults */ 678246263ccSAlex Deucher radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac); 679246263ccSAlex Deucher 680771fe6b9SJerome Glisse return p_dac; 681771fe6b9SJerome Glisse } 682771fe6b9SJerome Glisse 683d79766faSAlex Deucher enum radeon_tv_std 684d79766faSAlex Deucher radeon_combios_get_tv_info(struct radeon_device *rdev) 685771fe6b9SJerome Glisse { 686d79766faSAlex Deucher struct drm_device *dev = rdev->ddev; 687771fe6b9SJerome Glisse uint16_t tv_info; 688771fe6b9SJerome Glisse enum radeon_tv_std tv_std = TV_STD_NTSC; 689771fe6b9SJerome Glisse 690771fe6b9SJerome Glisse tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 691771fe6b9SJerome Glisse if (tv_info) { 692771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 693771fe6b9SJerome Glisse switch (RBIOS8(tv_info + 7) & 0xf) { 694771fe6b9SJerome Glisse case 1: 695771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 696771fe6b9SJerome Glisse DRM_INFO("Default TV standard: NTSC\n"); 697771fe6b9SJerome Glisse break; 698771fe6b9SJerome Glisse case 2: 699771fe6b9SJerome Glisse tv_std = TV_STD_PAL; 700771fe6b9SJerome Glisse DRM_INFO("Default TV standard: PAL\n"); 701771fe6b9SJerome Glisse break; 702771fe6b9SJerome Glisse case 3: 703771fe6b9SJerome Glisse tv_std = TV_STD_PAL_M; 704771fe6b9SJerome Glisse DRM_INFO("Default TV standard: PAL-M\n"); 705771fe6b9SJerome Glisse break; 706771fe6b9SJerome Glisse case 4: 707771fe6b9SJerome Glisse tv_std = TV_STD_PAL_60; 708771fe6b9SJerome Glisse DRM_INFO("Default TV standard: PAL-60\n"); 709771fe6b9SJerome Glisse break; 710771fe6b9SJerome Glisse case 5: 711771fe6b9SJerome Glisse tv_std = TV_STD_NTSC_J; 712771fe6b9SJerome Glisse DRM_INFO("Default TV standard: NTSC-J\n"); 713771fe6b9SJerome Glisse break; 714771fe6b9SJerome Glisse case 6: 715771fe6b9SJerome Glisse tv_std = TV_STD_SCART_PAL; 716771fe6b9SJerome Glisse DRM_INFO("Default TV standard: SCART-PAL\n"); 717771fe6b9SJerome Glisse break; 718771fe6b9SJerome Glisse default: 719771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 720771fe6b9SJerome Glisse DRM_INFO 721771fe6b9SJerome Glisse ("Unknown TV standard; defaulting to NTSC\n"); 722771fe6b9SJerome Glisse break; 723771fe6b9SJerome Glisse } 724771fe6b9SJerome Glisse 725771fe6b9SJerome Glisse switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) { 726771fe6b9SJerome Glisse case 0: 727771fe6b9SJerome Glisse DRM_INFO("29.498928713 MHz TV ref clk\n"); 728771fe6b9SJerome Glisse break; 729771fe6b9SJerome Glisse case 1: 730771fe6b9SJerome Glisse DRM_INFO("28.636360000 MHz TV ref clk\n"); 731771fe6b9SJerome Glisse break; 732771fe6b9SJerome Glisse case 2: 733771fe6b9SJerome Glisse DRM_INFO("14.318180000 MHz TV ref clk\n"); 734771fe6b9SJerome Glisse break; 735771fe6b9SJerome Glisse case 3: 736771fe6b9SJerome Glisse DRM_INFO("27.000000000 MHz TV ref clk\n"); 737771fe6b9SJerome Glisse break; 738771fe6b9SJerome Glisse default: 739771fe6b9SJerome Glisse break; 740771fe6b9SJerome Glisse } 741771fe6b9SJerome Glisse } 742771fe6b9SJerome Glisse } 743771fe6b9SJerome Glisse return tv_std; 744771fe6b9SJerome Glisse } 745771fe6b9SJerome Glisse 746771fe6b9SJerome Glisse static const uint32_t default_tvdac_adj[CHIP_LAST] = { 747771fe6b9SJerome Glisse 0x00000000, /* r100 */ 748771fe6b9SJerome Glisse 0x00280000, /* rv100 */ 749771fe6b9SJerome Glisse 0x00000000, /* rs100 */ 750771fe6b9SJerome Glisse 0x00880000, /* rv200 */ 751771fe6b9SJerome Glisse 0x00000000, /* rs200 */ 752771fe6b9SJerome Glisse 0x00000000, /* r200 */ 753771fe6b9SJerome Glisse 0x00770000, /* rv250 */ 754771fe6b9SJerome Glisse 0x00290000, /* rs300 */ 755771fe6b9SJerome Glisse 0x00560000, /* rv280 */ 756771fe6b9SJerome Glisse 0x00780000, /* r300 */ 757771fe6b9SJerome Glisse 0x00770000, /* r350 */ 758771fe6b9SJerome Glisse 0x00780000, /* rv350 */ 759771fe6b9SJerome Glisse 0x00780000, /* rv380 */ 760771fe6b9SJerome Glisse 0x01080000, /* r420 */ 761771fe6b9SJerome Glisse 0x01080000, /* r423 */ 762771fe6b9SJerome Glisse 0x01080000, /* rv410 */ 763771fe6b9SJerome Glisse 0x00780000, /* rs400 */ 764771fe6b9SJerome Glisse 0x00780000, /* rs480 */ 765771fe6b9SJerome Glisse }; 766771fe6b9SJerome Glisse 7676a719e05SDave Airlie static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev, 7686a719e05SDave Airlie struct radeon_encoder_tv_dac *tv_dac) 769771fe6b9SJerome Glisse { 770771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; 771771fe6b9SJerome Glisse if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) 772771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 0x00880000; 773771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 774771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 7756a719e05SDave Airlie return; 776771fe6b9SJerome Glisse } 777771fe6b9SJerome Glisse 778771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct 779771fe6b9SJerome Glisse radeon_encoder 780771fe6b9SJerome Glisse *encoder) 781771fe6b9SJerome Glisse { 782771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 783771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 784771fe6b9SJerome Glisse uint16_t dac_info; 785771fe6b9SJerome Glisse uint8_t rev, bg, dac; 786771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *tv_dac = NULL; 7876a719e05SDave Airlie int found = 0; 7886a719e05SDave Airlie 7896a719e05SDave Airlie tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); 7906a719e05SDave Airlie if (!tv_dac) 7916a719e05SDave Airlie return NULL; 792771fe6b9SJerome Glisse 793771fe6b9SJerome Glisse if (rdev->bios == NULL) 7946a719e05SDave Airlie goto out; 795771fe6b9SJerome Glisse 796771fe6b9SJerome Glisse /* first check TV table */ 797771fe6b9SJerome Glisse dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 798771fe6b9SJerome Glisse if (dac_info) { 799771fe6b9SJerome Glisse rev = RBIOS8(dac_info + 0x3); 800771fe6b9SJerome Glisse if (rev > 4) { 801771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 802771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xd) & 0xf; 803771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 804771fe6b9SJerome Glisse 805771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 806771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xf) & 0xf; 807771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 808771fe6b9SJerome Glisse 809771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x10) & 0xf; 810771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x11) & 0xf; 811771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 8126a719e05SDave Airlie found = 1; 813771fe6b9SJerome Glisse } else if (rev > 1) { 814771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 815771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; 816771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 817771fe6b9SJerome Glisse 818771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xd) & 0xf; 819771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf; 820771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 821771fe6b9SJerome Glisse 822771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 823771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; 824771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 8256a719e05SDave Airlie found = 1; 826771fe6b9SJerome Glisse } 827d79766faSAlex Deucher tv_dac->tv_std = radeon_combios_get_tv_info(rdev); 8286a719e05SDave Airlie } 8296a719e05SDave Airlie if (!found) { 830771fe6b9SJerome Glisse /* then check CRT table */ 831771fe6b9SJerome Glisse dac_info = 832771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 833771fe6b9SJerome Glisse if (dac_info) { 834771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 835771fe6b9SJerome Glisse if (rev < 2) { 836771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x3) & 0xf; 837771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf; 838771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 839771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 840771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 841771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 8426a719e05SDave Airlie found = 1; 843771fe6b9SJerome Glisse } else { 844771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x4) & 0xf; 845771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x5) & 0xf; 846771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 847771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 848771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 849771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 8506a719e05SDave Airlie found = 1; 851771fe6b9SJerome Glisse } 8526fe7ac3fSAlex Deucher } else { 8536fe7ac3fSAlex Deucher DRM_INFO("No TV DAC info found in BIOS\n"); 854771fe6b9SJerome Glisse } 855771fe6b9SJerome Glisse } 856771fe6b9SJerome Glisse 8576a719e05SDave Airlie out: 8586a719e05SDave Airlie if (!found) /* fallback to defaults */ 8596a719e05SDave Airlie radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac); 8606a719e05SDave Airlie 861771fe6b9SJerome Glisse return tv_dac; 862771fe6b9SJerome Glisse } 863771fe6b9SJerome Glisse 864771fe6b9SJerome Glisse static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct 865771fe6b9SJerome Glisse radeon_device 866771fe6b9SJerome Glisse *rdev) 867771fe6b9SJerome Glisse { 868771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 869771fe6b9SJerome Glisse uint32_t fp_vert_stretch, fp_horz_stretch; 870771fe6b9SJerome Glisse uint32_t ppll_div_sel, ppll_val; 8718b5c7444SMichel Dänzer uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL); 872771fe6b9SJerome Glisse 873771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 874771fe6b9SJerome Glisse 875771fe6b9SJerome Glisse if (!lvds) 876771fe6b9SJerome Glisse return NULL; 877771fe6b9SJerome Glisse 878771fe6b9SJerome Glisse fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH); 879771fe6b9SJerome Glisse fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH); 880771fe6b9SJerome Glisse 8818b5c7444SMichel Dänzer /* These should be fail-safe defaults, fingers crossed */ 8828b5c7444SMichel Dänzer lvds->panel_pwr_delay = 200; 8838b5c7444SMichel Dänzer lvds->panel_vcc_delay = 2000; 8848b5c7444SMichel Dänzer 8858b5c7444SMichel Dänzer lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL); 8868b5c7444SMichel Dänzer lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf; 8878b5c7444SMichel Dänzer lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf; 8888b5c7444SMichel Dänzer 889771fe6b9SJerome Glisse if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE) 890de2103e4SAlex Deucher lvds->native_mode.vdisplay = 891771fe6b9SJerome Glisse ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >> 892771fe6b9SJerome Glisse RADEON_VERT_PANEL_SHIFT) + 1; 893771fe6b9SJerome Glisse else 894de2103e4SAlex Deucher lvds->native_mode.vdisplay = 895771fe6b9SJerome Glisse (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1; 896771fe6b9SJerome Glisse 897771fe6b9SJerome Glisse if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE) 898de2103e4SAlex Deucher lvds->native_mode.hdisplay = 899771fe6b9SJerome Glisse (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >> 900771fe6b9SJerome Glisse RADEON_HORZ_PANEL_SHIFT) + 1) * 8; 901771fe6b9SJerome Glisse else 902de2103e4SAlex Deucher lvds->native_mode.hdisplay = 903771fe6b9SJerome Glisse ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8; 904771fe6b9SJerome Glisse 905de2103e4SAlex Deucher if ((lvds->native_mode.hdisplay < 640) || 906de2103e4SAlex Deucher (lvds->native_mode.vdisplay < 480)) { 907de2103e4SAlex Deucher lvds->native_mode.hdisplay = 640; 908de2103e4SAlex Deucher lvds->native_mode.vdisplay = 480; 909771fe6b9SJerome Glisse } 910771fe6b9SJerome Glisse 911771fe6b9SJerome Glisse ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3; 912771fe6b9SJerome Glisse ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel); 913771fe6b9SJerome Glisse if ((ppll_val & 0x000707ff) == 0x1bb) 914771fe6b9SJerome Glisse lvds->use_bios_dividers = false; 915771fe6b9SJerome Glisse else { 916771fe6b9SJerome Glisse lvds->panel_ref_divider = 917771fe6b9SJerome Glisse RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff; 918771fe6b9SJerome Glisse lvds->panel_post_divider = (ppll_val >> 16) & 0x7; 919771fe6b9SJerome Glisse lvds->panel_fb_divider = ppll_val & 0x7ff; 920771fe6b9SJerome Glisse 921771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 922771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 923771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 924771fe6b9SJerome Glisse } 925771fe6b9SJerome Glisse lvds->panel_vcc_delay = 200; 926771fe6b9SJerome Glisse 927771fe6b9SJerome Glisse DRM_INFO("Panel info derived from registers\n"); 928de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 929de2103e4SAlex Deucher lvds->native_mode.vdisplay); 930771fe6b9SJerome Glisse 931771fe6b9SJerome Glisse return lvds; 932771fe6b9SJerome Glisse } 933771fe6b9SJerome Glisse 934771fe6b9SJerome Glisse struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder 935771fe6b9SJerome Glisse *encoder) 936771fe6b9SJerome Glisse { 937771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 938771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 939771fe6b9SJerome Glisse uint16_t lcd_info; 940771fe6b9SJerome Glisse uint32_t panel_setup; 941771fe6b9SJerome Glisse char stmp[30]; 942771fe6b9SJerome Glisse int tmp, i; 943771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 944771fe6b9SJerome Glisse 9458dfaa8a7SMichel Dänzer if (rdev->bios == NULL) { 9468dfaa8a7SMichel Dänzer lvds = radeon_legacy_get_lvds_info_from_regs(rdev); 9478dfaa8a7SMichel Dänzer goto out; 9488dfaa8a7SMichel Dänzer } 949771fe6b9SJerome Glisse 950771fe6b9SJerome Glisse lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 951771fe6b9SJerome Glisse 952771fe6b9SJerome Glisse if (lcd_info) { 953771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 954771fe6b9SJerome Glisse 955771fe6b9SJerome Glisse if (!lvds) 956771fe6b9SJerome Glisse return NULL; 957771fe6b9SJerome Glisse 958771fe6b9SJerome Glisse for (i = 0; i < 24; i++) 959771fe6b9SJerome Glisse stmp[i] = RBIOS8(lcd_info + i + 1); 960771fe6b9SJerome Glisse stmp[24] = 0; 961771fe6b9SJerome Glisse 962771fe6b9SJerome Glisse DRM_INFO("Panel ID String: %s\n", stmp); 963771fe6b9SJerome Glisse 964de2103e4SAlex Deucher lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19); 965de2103e4SAlex Deucher lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b); 966771fe6b9SJerome Glisse 967de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 968de2103e4SAlex Deucher lvds->native_mode.vdisplay); 969771fe6b9SJerome Glisse 970771fe6b9SJerome Glisse lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c); 971771fe6b9SJerome Glisse if (lvds->panel_vcc_delay > 2000 || lvds->panel_vcc_delay < 0) 972771fe6b9SJerome Glisse lvds->panel_vcc_delay = 2000; 973771fe6b9SJerome Glisse 974771fe6b9SJerome Glisse lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24); 975771fe6b9SJerome Glisse lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf; 976771fe6b9SJerome Glisse lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf; 977771fe6b9SJerome Glisse 978771fe6b9SJerome Glisse lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e); 979771fe6b9SJerome Glisse lvds->panel_post_divider = RBIOS8(lcd_info + 0x30); 980771fe6b9SJerome Glisse lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31); 981771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 982771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 983771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 984771fe6b9SJerome Glisse 985771fe6b9SJerome Glisse panel_setup = RBIOS32(lcd_info + 0x39); 986771fe6b9SJerome Glisse lvds->lvds_gen_cntl = 0xff00; 987771fe6b9SJerome Glisse if (panel_setup & 0x1) 988771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT; 989771fe6b9SJerome Glisse 990771fe6b9SJerome Glisse if ((panel_setup >> 4) & 0x1) 991771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE; 992771fe6b9SJerome Glisse 993771fe6b9SJerome Glisse switch ((panel_setup >> 8) & 0x7) { 994771fe6b9SJerome Glisse case 0: 995771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM; 996771fe6b9SJerome Glisse break; 997771fe6b9SJerome Glisse case 1: 998771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY; 999771fe6b9SJerome Glisse break; 1000771fe6b9SJerome Glisse case 2: 1001771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY; 1002771fe6b9SJerome Glisse break; 1003771fe6b9SJerome Glisse default: 1004771fe6b9SJerome Glisse break; 1005771fe6b9SJerome Glisse } 1006771fe6b9SJerome Glisse 1007771fe6b9SJerome Glisse if ((panel_setup >> 16) & 0x1) 1008771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW; 1009771fe6b9SJerome Glisse 1010771fe6b9SJerome Glisse if ((panel_setup >> 17) & 0x1) 1011771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW; 1012771fe6b9SJerome Glisse 1013771fe6b9SJerome Glisse if ((panel_setup >> 18) & 0x1) 1014771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW; 1015771fe6b9SJerome Glisse 1016771fe6b9SJerome Glisse if ((panel_setup >> 23) & 0x1) 1017771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL; 1018771fe6b9SJerome Glisse 1019771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000); 1020771fe6b9SJerome Glisse 1021771fe6b9SJerome Glisse for (i = 0; i < 32; i++) { 1022771fe6b9SJerome Glisse tmp = RBIOS16(lcd_info + 64 + i * 2); 1023771fe6b9SJerome Glisse if (tmp == 0) 1024771fe6b9SJerome Glisse break; 1025771fe6b9SJerome Glisse 1026de2103e4SAlex Deucher if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) && 1027771fe6b9SJerome Glisse (RBIOS16(tmp + 2) == 1028de2103e4SAlex Deucher lvds->native_mode.vdisplay)) { 1029de2103e4SAlex Deucher lvds->native_mode.htotal = RBIOS16(tmp + 17) * 8; 1030de2103e4SAlex Deucher lvds->native_mode.hsync_start = RBIOS16(tmp + 21) * 8; 1031de2103e4SAlex Deucher lvds->native_mode.hsync_end = (RBIOS8(tmp + 23) + 1032de2103e4SAlex Deucher RBIOS16(tmp + 21)) * 8; 1033771fe6b9SJerome Glisse 1034de2103e4SAlex Deucher lvds->native_mode.vtotal = RBIOS16(tmp + 24); 1035de2103e4SAlex Deucher lvds->native_mode.vsync_start = RBIOS16(tmp + 28) & 0x7ff; 1036de2103e4SAlex Deucher lvds->native_mode.vsync_end = 1037de2103e4SAlex Deucher ((RBIOS16(tmp + 28) & 0xf800) >> 11) + 1038de2103e4SAlex Deucher (RBIOS16(tmp + 28) & 0x7ff); 1039de2103e4SAlex Deucher 1040de2103e4SAlex Deucher lvds->native_mode.clock = RBIOS16(tmp + 9) * 10; 1041771fe6b9SJerome Glisse lvds->native_mode.flags = 0; 1042de2103e4SAlex Deucher /* set crtc values */ 1043de2103e4SAlex Deucher drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V); 1044de2103e4SAlex Deucher 1045771fe6b9SJerome Glisse } 1046771fe6b9SJerome Glisse } 10476fe7ac3fSAlex Deucher } else { 1048771fe6b9SJerome Glisse DRM_INFO("No panel info found in BIOS\n"); 10498dfaa8a7SMichel Dänzer lvds = radeon_legacy_get_lvds_info_from_regs(rdev); 10506fe7ac3fSAlex Deucher } 10518dfaa8a7SMichel Dänzer out: 10528dfaa8a7SMichel Dänzer if (lvds) 10538dfaa8a7SMichel Dänzer encoder->native_mode = lvds->native_mode; 1054771fe6b9SJerome Glisse return lvds; 1055771fe6b9SJerome Glisse } 1056771fe6b9SJerome Glisse 1057771fe6b9SJerome Glisse static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = { 1058771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */ 1059771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */ 1060771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */ 1061771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */ 1062771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */ 1063771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */ 1064771fe6b9SJerome Glisse {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */ 1065771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */ 1066771fe6b9SJerome Glisse {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */ 1067771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */ 1068771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */ 1069771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */ 1070771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */ 1071771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */ 1072771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */ 1073771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */ 1074fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */ 1075fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */ 1076771fe6b9SJerome Glisse }; 1077771fe6b9SJerome Glisse 1078445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder, 1079445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1080771fe6b9SJerome Glisse { 1081445282dbSDave Airlie struct drm_device *dev = encoder->base.dev; 1082445282dbSDave Airlie struct radeon_device *rdev = dev->dev_private; 1083771fe6b9SJerome Glisse int i; 1084771fe6b9SJerome Glisse 1085771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 1086771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1087771fe6b9SJerome Glisse default_tmds_pll[rdev->family][i].value; 1088771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq; 1089771fe6b9SJerome Glisse } 1090771fe6b9SJerome Glisse 1091445282dbSDave Airlie return true; 1092771fe6b9SJerome Glisse } 1093771fe6b9SJerome Glisse 1094445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder, 1095445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1096771fe6b9SJerome Glisse { 1097771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1098771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1099771fe6b9SJerome Glisse uint16_t tmds_info; 1100771fe6b9SJerome Glisse int i, n; 1101771fe6b9SJerome Glisse uint8_t ver; 1102771fe6b9SJerome Glisse 1103771fe6b9SJerome Glisse if (rdev->bios == NULL) 1104445282dbSDave Airlie return false; 1105771fe6b9SJerome Glisse 1106771fe6b9SJerome Glisse tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 1107771fe6b9SJerome Glisse 1108771fe6b9SJerome Glisse if (tmds_info) { 1109771fe6b9SJerome Glisse ver = RBIOS8(tmds_info); 1110771fe6b9SJerome Glisse DRM_INFO("DFP table revision: %d\n", ver); 1111771fe6b9SJerome Glisse if (ver == 3) { 1112771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1113771fe6b9SJerome Glisse if (n > 4) 1114771fe6b9SJerome Glisse n = 4; 1115771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1116771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1117771fe6b9SJerome Glisse RBIOS32(tmds_info + i * 10 + 0x08); 1118771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1119771fe6b9SJerome Glisse RBIOS16(tmds_info + i * 10 + 0x10); 1120771fe6b9SJerome Glisse DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n", 1121771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1122771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1123771fe6b9SJerome Glisse } 1124771fe6b9SJerome Glisse } else if (ver == 4) { 1125771fe6b9SJerome Glisse int stride = 0; 1126771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1127771fe6b9SJerome Glisse if (n > 4) 1128771fe6b9SJerome Glisse n = 4; 1129771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1130771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1131771fe6b9SJerome Glisse RBIOS32(tmds_info + stride + 0x08); 1132771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1133771fe6b9SJerome Glisse RBIOS16(tmds_info + stride + 0x10); 1134771fe6b9SJerome Glisse if (i == 0) 1135771fe6b9SJerome Glisse stride += 10; 1136771fe6b9SJerome Glisse else 1137771fe6b9SJerome Glisse stride += 6; 1138771fe6b9SJerome Glisse DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n", 1139771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1140771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1141771fe6b9SJerome Glisse } 1142771fe6b9SJerome Glisse } 1143fcec570bSAlex Deucher } else { 1144771fe6b9SJerome Glisse DRM_INFO("No TMDS info found in BIOS\n"); 1145fcec570bSAlex Deucher return false; 1146fcec570bSAlex Deucher } 1147445282dbSDave Airlie return true; 1148445282dbSDave Airlie } 1149445282dbSDave Airlie 1150fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder, 1151fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1152771fe6b9SJerome Glisse { 1153771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1154771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1155fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1156fcec570bSAlex Deucher 1157fcec570bSAlex Deucher /* default for macs */ 11586a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1159fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1160fcec570bSAlex Deucher 1161fcec570bSAlex Deucher /* XXX some macs have duallink chips */ 1162fcec570bSAlex Deucher switch (rdev->mode_info.connector_table) { 1163fcec570bSAlex Deucher case CT_POWERBOOK_EXTERNAL: 1164fcec570bSAlex Deucher case CT_MINI_EXTERNAL: 1165fcec570bSAlex Deucher default: 1166fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1167fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1168fcec570bSAlex Deucher break; 1169fcec570bSAlex Deucher } 1170fcec570bSAlex Deucher 1171fcec570bSAlex Deucher return true; 1172fcec570bSAlex Deucher } 1173fcec570bSAlex Deucher 1174fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder, 1175fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1176fcec570bSAlex Deucher { 1177fcec570bSAlex Deucher struct drm_device *dev = encoder->base.dev; 1178fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 1179fcec570bSAlex Deucher uint16_t offset; 1180fcec570bSAlex Deucher uint8_t ver, id, blocks, clk, data; 1181fcec570bSAlex Deucher int i; 1182fcec570bSAlex Deucher enum radeon_combios_ddc gpio; 1183fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1184771fe6b9SJerome Glisse 1185771fe6b9SJerome Glisse if (rdev->bios == NULL) 1186fcec570bSAlex Deucher return false; 1187771fe6b9SJerome Glisse 1188fcec570bSAlex Deucher tmds->i2c_bus = NULL; 1189fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 1190fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE); 1191fcec570bSAlex Deucher if (offset) { 1192fcec570bSAlex Deucher ver = RBIOS8(offset); 1193fcec570bSAlex Deucher DRM_INFO("GPIO Table revision: %d\n", ver); 1194fcec570bSAlex Deucher blocks = RBIOS8(offset + 2); 1195fcec570bSAlex Deucher for (i = 0; i < blocks; i++) { 1196fcec570bSAlex Deucher id = RBIOS8(offset + 3 + (i * 5) + 0); 1197fcec570bSAlex Deucher if (id == 136) { 1198fcec570bSAlex Deucher clk = RBIOS8(offset + 3 + (i * 5) + 3); 1199fcec570bSAlex Deucher data = RBIOS8(offset + 3 + (i * 5) + 4); 1200fcec570bSAlex Deucher i2c_bus.valid = true; 1201fcec570bSAlex Deucher i2c_bus.mask_clk_mask = (1 << clk); 1202fcec570bSAlex Deucher i2c_bus.mask_data_mask = (1 << data); 1203fcec570bSAlex Deucher i2c_bus.a_clk_mask = (1 << clk); 1204fcec570bSAlex Deucher i2c_bus.a_data_mask = (1 << data); 1205fcec570bSAlex Deucher i2c_bus.en_clk_mask = (1 << clk); 1206fcec570bSAlex Deucher i2c_bus.en_data_mask = (1 << data); 1207fcec570bSAlex Deucher i2c_bus.y_clk_mask = (1 << clk); 1208fcec570bSAlex Deucher i2c_bus.y_data_mask = (1 << data); 1209fcec570bSAlex Deucher i2c_bus.mask_clk_reg = RADEON_GPIOPAD_MASK; 1210fcec570bSAlex Deucher i2c_bus.mask_data_reg = RADEON_GPIOPAD_MASK; 1211fcec570bSAlex Deucher i2c_bus.a_clk_reg = RADEON_GPIOPAD_A; 1212fcec570bSAlex Deucher i2c_bus.a_data_reg = RADEON_GPIOPAD_A; 1213fcec570bSAlex Deucher i2c_bus.en_clk_reg = RADEON_GPIOPAD_EN; 1214fcec570bSAlex Deucher i2c_bus.en_data_reg = RADEON_GPIOPAD_EN; 1215fcec570bSAlex Deucher i2c_bus.y_clk_reg = RADEON_GPIOPAD_Y; 1216fcec570bSAlex Deucher i2c_bus.y_data_reg = RADEON_GPIOPAD_Y; 1217fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1218fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1219fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1220fcec570bSAlex Deucher break; 1221771fe6b9SJerome Glisse } 1222771fe6b9SJerome Glisse } 1223fcec570bSAlex Deucher } 1224fcec570bSAlex Deucher } else { 1225fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 1226fcec570bSAlex Deucher if (offset) { 1227fcec570bSAlex Deucher ver = RBIOS8(offset); 1228fcec570bSAlex Deucher DRM_INFO("External TMDS Table revision: %d\n", ver); 1229fcec570bSAlex Deucher tmds->slave_addr = RBIOS8(offset + 4 + 2); 1230fcec570bSAlex Deucher tmds->slave_addr >>= 1; /* 7 bit addressing */ 1231fcec570bSAlex Deucher gpio = RBIOS8(offset + 4 + 3); 1232fcec570bSAlex Deucher switch (gpio) { 1233fcec570bSAlex Deucher case DDC_MONID: 12346a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1235fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1236fcec570bSAlex Deucher break; 1237fcec570bSAlex Deucher case DDC_DVI: 12386a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1239fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1240fcec570bSAlex Deucher break; 1241fcec570bSAlex Deucher case DDC_VGA: 12426a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1243fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1244fcec570bSAlex Deucher break; 1245fcec570bSAlex Deucher case DDC_CRT2: 1246fcec570bSAlex Deucher /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */ 1247fcec570bSAlex Deucher if (rdev->family >= CHIP_R300) 12486a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1249fcec570bSAlex Deucher else 12506a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); 1251fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1252fcec570bSAlex Deucher break; 1253fcec570bSAlex Deucher case DDC_LCD: /* MM i2c */ 1254fcec570bSAlex Deucher DRM_ERROR("MM i2c requires hw i2c engine\n"); 1255fcec570bSAlex Deucher break; 1256fcec570bSAlex Deucher default: 1257fcec570bSAlex Deucher DRM_ERROR("Unsupported gpio %d\n", gpio); 1258fcec570bSAlex Deucher break; 1259fcec570bSAlex Deucher } 1260fcec570bSAlex Deucher } 1261fcec570bSAlex Deucher } 1262fcec570bSAlex Deucher 1263fcec570bSAlex Deucher if (!tmds->i2c_bus) { 1264fcec570bSAlex Deucher DRM_INFO("No valid Ext TMDS info found in BIOS\n"); 1265fcec570bSAlex Deucher return false; 1266fcec570bSAlex Deucher } 1267fcec570bSAlex Deucher 1268fcec570bSAlex Deucher return true; 1269fcec570bSAlex Deucher } 1270771fe6b9SJerome Glisse 1271771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) 1272771fe6b9SJerome Glisse { 1273771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1274771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 1275eed45b30SAlex Deucher struct radeon_hpd hpd; 1276771fe6b9SJerome Glisse 1277771fe6b9SJerome Glisse rdev->mode_info.connector_table = radeon_connector_table; 1278771fe6b9SJerome Glisse if (rdev->mode_info.connector_table == CT_NONE) { 1279771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 1280771fe6b9SJerome Glisse if (machine_is_compatible("PowerBook3,3")) { 1281771fe6b9SJerome Glisse /* powerbook with VGA */ 1282771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_VGA; 1283771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook3,4") || 1284771fe6b9SJerome Glisse machine_is_compatible("PowerBook3,5")) { 1285771fe6b9SJerome Glisse /* powerbook with internal tmds */ 1286771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; 1287771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook5,1") || 1288771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,2") || 1289771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,3") || 1290771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,4") || 1291771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,5")) { 1292771fe6b9SJerome Glisse /* powerbook with external single link tmds (sil164) */ 1293771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 1294771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook5,6")) { 1295771fe6b9SJerome Glisse /* powerbook with external dual or single link tmds */ 1296771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 1297771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook5,7") || 1298771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,8") || 1299771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,9")) { 1300771fe6b9SJerome Glisse /* PowerBook6,2 ? */ 1301771fe6b9SJerome Glisse /* powerbook with external dual link tmds (sil1178?) */ 1302771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 1303771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook4,1") || 1304771fe6b9SJerome Glisse machine_is_compatible("PowerBook4,2") || 1305771fe6b9SJerome Glisse machine_is_compatible("PowerBook4,3") || 1306771fe6b9SJerome Glisse machine_is_compatible("PowerBook6,3") || 1307771fe6b9SJerome Glisse machine_is_compatible("PowerBook6,5") || 1308771fe6b9SJerome Glisse machine_is_compatible("PowerBook6,7")) { 1309771fe6b9SJerome Glisse /* ibook */ 1310771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IBOOK; 1311771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac4,4")) { 1312771fe6b9SJerome Glisse /* emac */ 1313771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_EMAC; 1314771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac10,1")) { 1315771fe6b9SJerome Glisse /* mini with internal tmds */ 1316771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_INTERNAL; 1317771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac10,2")) { 1318771fe6b9SJerome Glisse /* mini with external tmds */ 1319771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_EXTERNAL; 1320771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac12,1")) { 1321771fe6b9SJerome Glisse /* PowerMac8,1 ? */ 1322771fe6b9SJerome Glisse /* imac g5 isight */ 1323771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; 1324771fe6b9SJerome Glisse } else 1325771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 1326771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_GENERIC; 1327771fe6b9SJerome Glisse } 1328771fe6b9SJerome Glisse 1329771fe6b9SJerome Glisse switch (rdev->mode_info.connector_table) { 1330771fe6b9SJerome Glisse case CT_GENERIC: 1331771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (generic)\n", 1332771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1333771fe6b9SJerome Glisse /* these are the most common settings */ 1334771fe6b9SJerome Glisse if (rdev->flags & RADEON_SINGLE_CRTC) { 1335771fe6b9SJerome Glisse /* VGA - primary dac */ 13366a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1337eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1338771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1339771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1340771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1341771fe6b9SJerome Glisse 1), 1342771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1343771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1344771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1345771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1346b75fad06SAlex Deucher &ddc_i2c, 1347eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1348eed45b30SAlex Deucher &hpd); 1349771fe6b9SJerome Glisse } else if (rdev->flags & RADEON_IS_MOBILITY) { 1350771fe6b9SJerome Glisse /* LVDS */ 13516a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, 0); 1352eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1353771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1354771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1355771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1356771fe6b9SJerome Glisse 0), 1357771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1358771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1359771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1360771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 1361b75fad06SAlex Deucher &ddc_i2c, 1362eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1363eed45b30SAlex Deucher &hpd); 1364771fe6b9SJerome Glisse 1365771fe6b9SJerome Glisse /* VGA - primary dac */ 13666a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1367eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1368771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1369771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1370771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1371771fe6b9SJerome Glisse 1), 1372771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1373771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1374771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1375771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1376b75fad06SAlex Deucher &ddc_i2c, 1377eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1378eed45b30SAlex Deucher &hpd); 1379771fe6b9SJerome Glisse } else { 1380771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 13816a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1382eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 1383771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1384771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1385771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1386771fe6b9SJerome Glisse 0), 1387771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1388771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1389771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1390771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1391771fe6b9SJerome Glisse 2), 1392771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1393771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1394771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1395771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1396771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 1397b75fad06SAlex Deucher &ddc_i2c, 1398eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1399eed45b30SAlex Deucher &hpd); 1400771fe6b9SJerome Glisse 1401771fe6b9SJerome Glisse /* VGA - primary dac */ 14026a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1403eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1404771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1405771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1406771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1407771fe6b9SJerome Glisse 1), 1408771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1409771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1410771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1411771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1412b75fad06SAlex Deucher &ddc_i2c, 1413eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1414eed45b30SAlex Deucher &hpd); 1415771fe6b9SJerome Glisse } 1416771fe6b9SJerome Glisse 1417771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 1418771fe6b9SJerome Glisse /* TV - tv dac */ 1419eed45b30SAlex Deucher ddc_i2c.valid = false; 1420eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1421771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1422771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1423771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1424771fe6b9SJerome Glisse 2), 1425771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1426771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, 1427771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1428771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1429b75fad06SAlex Deucher &ddc_i2c, 1430eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1431eed45b30SAlex Deucher &hpd); 1432771fe6b9SJerome Glisse } 1433771fe6b9SJerome Glisse break; 1434771fe6b9SJerome Glisse case CT_IBOOK: 1435771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (ibook)\n", 1436771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1437771fe6b9SJerome Glisse /* LVDS */ 14386a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1439eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1440771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1441771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1442771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1443771fe6b9SJerome Glisse 0), 1444771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1445771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1446b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1447eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1448eed45b30SAlex Deucher &hpd); 1449771fe6b9SJerome Glisse /* VGA - TV DAC */ 14506a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1451eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1452771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1453771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1454771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1455771fe6b9SJerome Glisse 2), 1456771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1457771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1458b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1459eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1460eed45b30SAlex Deucher &hpd); 1461771fe6b9SJerome Glisse /* TV - TV DAC */ 1462eed45b30SAlex Deucher ddc_i2c.valid = false; 1463eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1464771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1465771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1466771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1467771fe6b9SJerome Glisse 2), 1468771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1469771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1470771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1471b75fad06SAlex Deucher &ddc_i2c, 1472eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1473eed45b30SAlex Deucher &hpd); 1474771fe6b9SJerome Glisse break; 1475771fe6b9SJerome Glisse case CT_POWERBOOK_EXTERNAL: 1476771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook external tmds)\n", 1477771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1478771fe6b9SJerome Glisse /* LVDS */ 14796a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1480eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1481771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1482771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1483771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1484771fe6b9SJerome Glisse 0), 1485771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1486771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1487b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1488eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1489eed45b30SAlex Deucher &hpd); 1490771fe6b9SJerome Glisse /* DVI-I - primary dac, ext tmds */ 14916a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1492eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1493771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1494771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1495771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1496771fe6b9SJerome Glisse 0), 1497771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1498771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1499771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1500771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1501771fe6b9SJerome Glisse 1), 1502771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1503b75fad06SAlex Deucher /* XXX some are SL */ 1504771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1505771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1506771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1507b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1508eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 1509eed45b30SAlex Deucher &hpd); 1510771fe6b9SJerome Glisse /* TV - TV DAC */ 1511eed45b30SAlex Deucher ddc_i2c.valid = false; 1512eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1513771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1514771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1515771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1516771fe6b9SJerome Glisse 2), 1517771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1518771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1519771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1520b75fad06SAlex Deucher &ddc_i2c, 1521eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1522eed45b30SAlex Deucher &hpd); 1523771fe6b9SJerome Glisse break; 1524771fe6b9SJerome Glisse case CT_POWERBOOK_INTERNAL: 1525771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook internal tmds)\n", 1526771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1527771fe6b9SJerome Glisse /* LVDS */ 15286a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1529eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1530771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1531771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1532771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1533771fe6b9SJerome Glisse 0), 1534771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1535771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1536b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1537eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1538eed45b30SAlex Deucher &hpd); 1539771fe6b9SJerome Glisse /* DVI-I - primary dac, int tmds */ 15406a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1541eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1542771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1543771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1544771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1545771fe6b9SJerome Glisse 0), 1546771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1547771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1548771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1549771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1550771fe6b9SJerome Glisse 1), 1551771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1552771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1553771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1554771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1555b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1556eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1557eed45b30SAlex Deucher &hpd); 1558771fe6b9SJerome Glisse /* TV - TV DAC */ 1559eed45b30SAlex Deucher ddc_i2c.valid = false; 1560eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1561771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1562771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1563771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1564771fe6b9SJerome Glisse 2), 1565771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1566771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1567771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1568b75fad06SAlex Deucher &ddc_i2c, 1569eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1570eed45b30SAlex Deucher &hpd); 1571771fe6b9SJerome Glisse break; 1572771fe6b9SJerome Glisse case CT_POWERBOOK_VGA: 1573771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook vga)\n", 1574771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1575771fe6b9SJerome Glisse /* LVDS */ 15766a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1577eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1578771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1579771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1580771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1581771fe6b9SJerome Glisse 0), 1582771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1583771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1584b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1585eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1586eed45b30SAlex Deucher &hpd); 1587771fe6b9SJerome Glisse /* VGA - primary dac */ 15886a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1589eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1590771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1591771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1592771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1593771fe6b9SJerome Glisse 1), 1594771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1595771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT, 1596b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1597eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1598eed45b30SAlex Deucher &hpd); 1599771fe6b9SJerome Glisse /* TV - TV DAC */ 1600eed45b30SAlex Deucher ddc_i2c.valid = false; 1601eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1602771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1603771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1604771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1605771fe6b9SJerome Glisse 2), 1606771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1607771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1608771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1609b75fad06SAlex Deucher &ddc_i2c, 1610eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1611eed45b30SAlex Deucher &hpd); 1612771fe6b9SJerome Glisse break; 1613771fe6b9SJerome Glisse case CT_MINI_EXTERNAL: 1614771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini external tmds)\n", 1615771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1616771fe6b9SJerome Glisse /* DVI-I - tv dac, ext tmds */ 16176a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); 1618eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1619771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1620771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1621771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1622771fe6b9SJerome Glisse 0), 1623771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1624771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1625771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1626771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1627771fe6b9SJerome Glisse 2), 1628771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1629b75fad06SAlex Deucher /* XXX are any DL? */ 1630771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1631771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1632771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1633b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1634eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1635eed45b30SAlex Deucher &hpd); 1636771fe6b9SJerome Glisse /* TV - TV DAC */ 1637eed45b30SAlex Deucher ddc_i2c.valid = false; 1638eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1639771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1640771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1641771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1642771fe6b9SJerome Glisse 2), 1643771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1644771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1645771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1646b75fad06SAlex Deucher &ddc_i2c, 1647eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1648eed45b30SAlex Deucher &hpd); 1649771fe6b9SJerome Glisse break; 1650771fe6b9SJerome Glisse case CT_MINI_INTERNAL: 1651771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini internal tmds)\n", 1652771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1653771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 16546a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); 1655eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1656771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1657771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1658771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1659771fe6b9SJerome Glisse 0), 1660771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1661771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1662771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1663771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1664771fe6b9SJerome Glisse 2), 1665771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1666771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1667771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1668771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1669b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1670eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1671eed45b30SAlex Deucher &hpd); 1672771fe6b9SJerome Glisse /* TV - TV DAC */ 1673eed45b30SAlex Deucher ddc_i2c.valid = false; 1674eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1675771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1676771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1677771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1678771fe6b9SJerome Glisse 2), 1679771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1680771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1681771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1682b75fad06SAlex Deucher &ddc_i2c, 1683eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1684eed45b30SAlex Deucher &hpd); 1685771fe6b9SJerome Glisse break; 1686771fe6b9SJerome Glisse case CT_IMAC_G5_ISIGHT: 1687771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (imac g5 isight)\n", 1688771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1689771fe6b9SJerome Glisse /* DVI-D - int tmds */ 16906a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1691eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1692771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1693771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1694771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1695771fe6b9SJerome Glisse 0), 1696771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1697771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT, 1698b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVID, &ddc_i2c, 1699eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 1700eed45b30SAlex Deucher &hpd); 1701771fe6b9SJerome Glisse /* VGA - tv dac */ 17026a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1703eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1704771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1705771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1706771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1707771fe6b9SJerome Glisse 2), 1708771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1709771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1710b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1711eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1712eed45b30SAlex Deucher &hpd); 1713771fe6b9SJerome Glisse /* TV - TV DAC */ 1714eed45b30SAlex Deucher ddc_i2c.valid = false; 1715eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1716771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1717771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1718771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1719771fe6b9SJerome Glisse 2), 1720771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1721771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1722771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1723b75fad06SAlex Deucher &ddc_i2c, 1724eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1725eed45b30SAlex Deucher &hpd); 1726771fe6b9SJerome Glisse break; 1727771fe6b9SJerome Glisse case CT_EMAC: 1728771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (emac)\n", 1729771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1730771fe6b9SJerome Glisse /* VGA - primary dac */ 17316a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1732eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1733771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1734771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1735771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1736771fe6b9SJerome Glisse 1), 1737771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1738771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 1739b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1740eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1741eed45b30SAlex Deucher &hpd); 1742771fe6b9SJerome Glisse /* VGA - tv dac */ 17436a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); 1744eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1745771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1746771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1747771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1748771fe6b9SJerome Glisse 2), 1749771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1750771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1751b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1752eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1753eed45b30SAlex Deucher &hpd); 1754771fe6b9SJerome Glisse /* TV - TV DAC */ 1755eed45b30SAlex Deucher ddc_i2c.valid = false; 1756eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1757771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1758771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1759771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1760771fe6b9SJerome Glisse 2), 1761771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1762771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1763771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1764b75fad06SAlex Deucher &ddc_i2c, 1765eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1766eed45b30SAlex Deucher &hpd); 1767771fe6b9SJerome Glisse break; 1768771fe6b9SJerome Glisse default: 1769771fe6b9SJerome Glisse DRM_INFO("Connector table: %d (invalid)\n", 1770771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1771771fe6b9SJerome Glisse return false; 1772771fe6b9SJerome Glisse } 1773771fe6b9SJerome Glisse 1774771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 1775771fe6b9SJerome Glisse 1776771fe6b9SJerome Glisse return true; 1777771fe6b9SJerome Glisse } 1778771fe6b9SJerome Glisse 1779771fe6b9SJerome Glisse static bool radeon_apply_legacy_quirks(struct drm_device *dev, 1780771fe6b9SJerome Glisse int bios_index, 1781771fe6b9SJerome Glisse enum radeon_combios_connector 1782771fe6b9SJerome Glisse *legacy_connector, 1783eed45b30SAlex Deucher struct radeon_i2c_bus_rec *ddc_i2c, 1784eed45b30SAlex Deucher struct radeon_hpd *hpd) 1785771fe6b9SJerome Glisse { 1786771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1787771fe6b9SJerome Glisse 1788771fe6b9SJerome Glisse /* XPRESS DDC quirks */ 1789771fe6b9SJerome Glisse if ((rdev->family == CHIP_RS400 || 1790771fe6b9SJerome Glisse rdev->family == CHIP_RS480) && 1791771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 17926a93cb25SAlex Deucher *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1793771fe6b9SJerome Glisse else if ((rdev->family == CHIP_RS400 || 1794771fe6b9SJerome Glisse rdev->family == CHIP_RS480) && 1795771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_MONID) { 17966a93cb25SAlex Deucher *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIOPAD_MASK); 1797771fe6b9SJerome Glisse ddc_i2c->mask_clk_mask = (0x20 << 8); 1798771fe6b9SJerome Glisse ddc_i2c->mask_data_mask = 0x80; 1799771fe6b9SJerome Glisse ddc_i2c->a_clk_mask = (0x20 << 8); 1800771fe6b9SJerome Glisse ddc_i2c->a_data_mask = 0x80; 18019b9fe724SAlex Deucher ddc_i2c->en_clk_mask = (0x20 << 8); 18029b9fe724SAlex Deucher ddc_i2c->en_data_mask = 0x80; 18039b9fe724SAlex Deucher ddc_i2c->y_clk_mask = (0x20 << 8); 18049b9fe724SAlex Deucher ddc_i2c->y_data_mask = 0x80; 1805771fe6b9SJerome Glisse } 1806771fe6b9SJerome Glisse 1807fcec570bSAlex Deucher /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */ 1808fcec570bSAlex Deucher if ((rdev->family >= CHIP_R300) && 1809fcec570bSAlex Deucher ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 18106a93cb25SAlex Deucher *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1811fcec570bSAlex Deucher 1812771fe6b9SJerome Glisse /* Certain IBM chipset RN50s have a BIOS reporting two VGAs, 1813771fe6b9SJerome Glisse one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */ 1814771fe6b9SJerome Glisse if (dev->pdev->device == 0x515e && 1815771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x1014) { 1816771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_CRT_LEGACY && 1817771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 1818771fe6b9SJerome Glisse return false; 1819771fe6b9SJerome Glisse } 1820771fe6b9SJerome Glisse 1821771fe6b9SJerome Glisse /* Some RV100 cards with 2 VGA ports show up with DVI+VGA */ 1822771fe6b9SJerome Glisse if (dev->pdev->device == 0x5159 && 1823771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x1002 && 1824771fe6b9SJerome Glisse dev->pdev->subsystem_device == 0x013a) { 1825771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_DVI_I_LEGACY) 1826771fe6b9SJerome Glisse *legacy_connector = CONNECTOR_CRT_LEGACY; 1827771fe6b9SJerome Glisse 1828771fe6b9SJerome Glisse } 1829771fe6b9SJerome Glisse 1830771fe6b9SJerome Glisse /* X300 card with extra non-existent DVI port */ 1831771fe6b9SJerome Glisse if (dev->pdev->device == 0x5B60 && 1832771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x17af && 1833771fe6b9SJerome Glisse dev->pdev->subsystem_device == 0x201e && bios_index == 2) { 1834771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_DVI_I_LEGACY) 1835771fe6b9SJerome Glisse return false; 1836771fe6b9SJerome Glisse } 1837771fe6b9SJerome Glisse 1838771fe6b9SJerome Glisse return true; 1839771fe6b9SJerome Glisse } 1840771fe6b9SJerome Glisse 1841790cfb34SAlex Deucher static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev) 1842790cfb34SAlex Deucher { 1843790cfb34SAlex Deucher /* Acer 5102 has non-existent TV port */ 1844790cfb34SAlex Deucher if (dev->pdev->device == 0x5975 && 1845790cfb34SAlex Deucher dev->pdev->subsystem_vendor == 0x1025 && 1846790cfb34SAlex Deucher dev->pdev->subsystem_device == 0x009f) 1847790cfb34SAlex Deucher return false; 1848790cfb34SAlex Deucher 1849fc7f7119SAlex Deucher /* HP dc5750 has non-existent TV port */ 1850fc7f7119SAlex Deucher if (dev->pdev->device == 0x5974 && 1851fc7f7119SAlex Deucher dev->pdev->subsystem_vendor == 0x103c && 1852fc7f7119SAlex Deucher dev->pdev->subsystem_device == 0x280a) 1853fc7f7119SAlex Deucher return false; 1854fc7f7119SAlex Deucher 1855fd874ad0SAlex Deucher /* MSI S270 has non-existent TV port */ 1856fd874ad0SAlex Deucher if (dev->pdev->device == 0x5955 && 1857fd874ad0SAlex Deucher dev->pdev->subsystem_vendor == 0x1462 && 1858fd874ad0SAlex Deucher dev->pdev->subsystem_device == 0x0131) 1859fd874ad0SAlex Deucher return false; 1860fd874ad0SAlex Deucher 1861790cfb34SAlex Deucher return true; 1862790cfb34SAlex Deucher } 1863790cfb34SAlex Deucher 1864b75fad06SAlex Deucher static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d) 1865b75fad06SAlex Deucher { 1866b75fad06SAlex Deucher struct radeon_device *rdev = dev->dev_private; 1867b75fad06SAlex Deucher uint32_t ext_tmds_info; 1868b75fad06SAlex Deucher 1869b75fad06SAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 1870b75fad06SAlex Deucher if (is_dvi_d) 1871b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 1872b75fad06SAlex Deucher else 1873b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 1874b75fad06SAlex Deucher } 1875b75fad06SAlex Deucher ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 1876b75fad06SAlex Deucher if (ext_tmds_info) { 1877b75fad06SAlex Deucher uint8_t rev = RBIOS8(ext_tmds_info); 1878b75fad06SAlex Deucher uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5); 1879b75fad06SAlex Deucher if (rev >= 3) { 1880b75fad06SAlex Deucher if (is_dvi_d) 1881b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 1882b75fad06SAlex Deucher else 1883b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 1884b75fad06SAlex Deucher } else { 1885b75fad06SAlex Deucher if (flags & 1) { 1886b75fad06SAlex Deucher if (is_dvi_d) 1887b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 1888b75fad06SAlex Deucher else 1889b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 1890b75fad06SAlex Deucher } 1891b75fad06SAlex Deucher } 1892b75fad06SAlex Deucher } 1893b75fad06SAlex Deucher if (is_dvi_d) 1894b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 1895b75fad06SAlex Deucher else 1896b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 1897b75fad06SAlex Deucher } 1898b75fad06SAlex Deucher 1899771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) 1900771fe6b9SJerome Glisse { 1901771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1902771fe6b9SJerome Glisse uint32_t conn_info, entry, devices; 1903b75fad06SAlex Deucher uint16_t tmp, connector_object_id; 1904771fe6b9SJerome Glisse enum radeon_combios_ddc ddc_type; 1905771fe6b9SJerome Glisse enum radeon_combios_connector connector; 1906771fe6b9SJerome Glisse int i = 0; 1907771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 1908eed45b30SAlex Deucher struct radeon_hpd hpd; 1909771fe6b9SJerome Glisse 1910771fe6b9SJerome Glisse if (rdev->bios == NULL) 1911771fe6b9SJerome Glisse return false; 1912771fe6b9SJerome Glisse 1913771fe6b9SJerome Glisse conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE); 1914771fe6b9SJerome Glisse if (conn_info) { 1915771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 1916771fe6b9SJerome Glisse entry = conn_info + 2 + i * 2; 1917771fe6b9SJerome Glisse 1918771fe6b9SJerome Glisse if (!RBIOS16(entry)) 1919771fe6b9SJerome Glisse break; 1920771fe6b9SJerome Glisse 1921771fe6b9SJerome Glisse tmp = RBIOS16(entry); 1922771fe6b9SJerome Glisse 1923771fe6b9SJerome Glisse connector = (tmp >> 12) & 0xf; 1924771fe6b9SJerome Glisse 1925771fe6b9SJerome Glisse ddc_type = (tmp >> 8) & 0xf; 1926771fe6b9SJerome Glisse switch (ddc_type) { 1927771fe6b9SJerome Glisse case DDC_MONID: 1928771fe6b9SJerome Glisse ddc_i2c = 19296a93cb25SAlex Deucher combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1930771fe6b9SJerome Glisse break; 1931771fe6b9SJerome Glisse case DDC_DVI: 1932771fe6b9SJerome Glisse ddc_i2c = 19336a93cb25SAlex Deucher combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1934771fe6b9SJerome Glisse break; 1935771fe6b9SJerome Glisse case DDC_VGA: 1936771fe6b9SJerome Glisse ddc_i2c = 19376a93cb25SAlex Deucher combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1938771fe6b9SJerome Glisse break; 1939771fe6b9SJerome Glisse case DDC_CRT2: 1940771fe6b9SJerome Glisse ddc_i2c = 19416a93cb25SAlex Deucher combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); 1942771fe6b9SJerome Glisse break; 1943771fe6b9SJerome Glisse default: 1944771fe6b9SJerome Glisse break; 1945771fe6b9SJerome Glisse } 1946771fe6b9SJerome Glisse 1947eed45b30SAlex Deucher switch (connector) { 1948eed45b30SAlex Deucher case CONNECTOR_PROPRIETARY_LEGACY: 1949eed45b30SAlex Deucher case CONNECTOR_DVI_I_LEGACY: 1950eed45b30SAlex Deucher case CONNECTOR_DVI_D_LEGACY: 1951eed45b30SAlex Deucher if ((tmp >> 4) & 0x1) 1952eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; 1953eed45b30SAlex Deucher else 1954eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 1955eed45b30SAlex Deucher break; 1956eed45b30SAlex Deucher default: 1957eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1958eed45b30SAlex Deucher break; 1959eed45b30SAlex Deucher } 1960eed45b30SAlex Deucher 19612d152c6bSAlex Deucher if (!radeon_apply_legacy_quirks(dev, i, &connector, 1962eed45b30SAlex Deucher &ddc_i2c, &hpd)) 19632d152c6bSAlex Deucher continue; 1964771fe6b9SJerome Glisse 1965771fe6b9SJerome Glisse switch (connector) { 1966771fe6b9SJerome Glisse case CONNECTOR_PROPRIETARY_LEGACY: 1967771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) 1968771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 1969771fe6b9SJerome Glisse else 1970771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 1971771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1972771fe6b9SJerome Glisse radeon_get_encoder_id 1973771fe6b9SJerome Glisse (dev, devices, 0), 1974771fe6b9SJerome Glisse devices); 1975771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 1976771fe6b9SJerome Glisse legacy_connector_convert 1977771fe6b9SJerome Glisse [connector], 1978b75fad06SAlex Deucher &ddc_i2c, 1979eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 1980eed45b30SAlex Deucher &hpd); 1981771fe6b9SJerome Glisse break; 1982771fe6b9SJerome Glisse case CONNECTOR_CRT_LEGACY: 1983771fe6b9SJerome Glisse if (tmp & 0x1) { 1984771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT2_SUPPORT; 1985771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1986771fe6b9SJerome Glisse radeon_get_encoder_id 1987771fe6b9SJerome Glisse (dev, 1988771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1989771fe6b9SJerome Glisse 2), 1990771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1991771fe6b9SJerome Glisse } else { 1992771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT1_SUPPORT; 1993771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1994771fe6b9SJerome Glisse radeon_get_encoder_id 1995771fe6b9SJerome Glisse (dev, 1996771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1997771fe6b9SJerome Glisse 1), 1998771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1999771fe6b9SJerome Glisse } 2000771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2001771fe6b9SJerome Glisse i, 2002771fe6b9SJerome Glisse devices, 2003771fe6b9SJerome Glisse legacy_connector_convert 2004771fe6b9SJerome Glisse [connector], 2005b75fad06SAlex Deucher &ddc_i2c, 2006eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2007eed45b30SAlex Deucher &hpd); 2008771fe6b9SJerome Glisse break; 2009771fe6b9SJerome Glisse case CONNECTOR_DVI_I_LEGACY: 2010771fe6b9SJerome Glisse devices = 0; 2011771fe6b9SJerome Glisse if (tmp & 0x1) { 2012771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT2_SUPPORT; 2013771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2014771fe6b9SJerome Glisse radeon_get_encoder_id 2015771fe6b9SJerome Glisse (dev, 2016771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2017771fe6b9SJerome Glisse 2), 2018771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2019771fe6b9SJerome Glisse } else { 2020771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT1_SUPPORT; 2021771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2022771fe6b9SJerome Glisse radeon_get_encoder_id 2023771fe6b9SJerome Glisse (dev, 2024771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2025771fe6b9SJerome Glisse 1), 2026771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2027771fe6b9SJerome Glisse } 2028771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) { 2029771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP2_SUPPORT; 2030771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2031771fe6b9SJerome Glisse radeon_get_encoder_id 2032771fe6b9SJerome Glisse (dev, 2033771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 2034771fe6b9SJerome Glisse 0), 2035771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 2036b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 0); 2037771fe6b9SJerome Glisse } else { 2038771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP1_SUPPORT; 2039771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2040771fe6b9SJerome Glisse radeon_get_encoder_id 2041771fe6b9SJerome Glisse (dev, 2042771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2043771fe6b9SJerome Glisse 0), 2044771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2045b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2046771fe6b9SJerome Glisse } 2047771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2048771fe6b9SJerome Glisse i, 2049771fe6b9SJerome Glisse devices, 2050771fe6b9SJerome Glisse legacy_connector_convert 2051771fe6b9SJerome Glisse [connector], 2052b75fad06SAlex Deucher &ddc_i2c, 2053eed45b30SAlex Deucher connector_object_id, 2054eed45b30SAlex Deucher &hpd); 2055771fe6b9SJerome Glisse break; 2056771fe6b9SJerome Glisse case CONNECTOR_DVI_D_LEGACY: 2057b75fad06SAlex Deucher if ((tmp >> 4) & 0x1) { 2058771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2059b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 1); 2060b75fad06SAlex Deucher } else { 2061771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2062b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2063b75fad06SAlex Deucher } 2064771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2065771fe6b9SJerome Glisse radeon_get_encoder_id 2066771fe6b9SJerome Glisse (dev, devices, 0), 2067771fe6b9SJerome Glisse devices); 2068771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2069771fe6b9SJerome Glisse legacy_connector_convert 2070771fe6b9SJerome Glisse [connector], 2071b75fad06SAlex Deucher &ddc_i2c, 2072eed45b30SAlex Deucher connector_object_id, 2073eed45b30SAlex Deucher &hpd); 2074771fe6b9SJerome Glisse break; 2075771fe6b9SJerome Glisse case CONNECTOR_CTV_LEGACY: 2076771fe6b9SJerome Glisse case CONNECTOR_STV_LEGACY: 2077771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2078771fe6b9SJerome Glisse radeon_get_encoder_id 2079771fe6b9SJerome Glisse (dev, 2080771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2081771fe6b9SJerome Glisse 2), 2082771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2083771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, 2084771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2085771fe6b9SJerome Glisse legacy_connector_convert 2086771fe6b9SJerome Glisse [connector], 2087b75fad06SAlex Deucher &ddc_i2c, 2088eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2089eed45b30SAlex Deucher &hpd); 2090771fe6b9SJerome Glisse break; 2091771fe6b9SJerome Glisse default: 2092771fe6b9SJerome Glisse DRM_ERROR("Unknown connector type: %d\n", 2093771fe6b9SJerome Glisse connector); 2094771fe6b9SJerome Glisse continue; 2095771fe6b9SJerome Glisse } 2096771fe6b9SJerome Glisse 2097771fe6b9SJerome Glisse } 2098771fe6b9SJerome Glisse } else { 2099771fe6b9SJerome Glisse uint16_t tmds_info = 2100771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 2101771fe6b9SJerome Glisse if (tmds_info) { 2102771fe6b9SJerome Glisse DRM_DEBUG("Found DFP table, assuming DVI connector\n"); 2103771fe6b9SJerome Glisse 2104771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2105771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 2106771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2107771fe6b9SJerome Glisse 1), 2108771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2109771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2110771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 2111771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2112771fe6b9SJerome Glisse 0), 2113771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2114771fe6b9SJerome Glisse 21156a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 2116eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2117771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2118771fe6b9SJerome Glisse 0, 2119771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT | 2120771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2121771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 2122b75fad06SAlex Deucher &ddc_i2c, 2123eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2124eed45b30SAlex Deucher &hpd); 2125771fe6b9SJerome Glisse } else { 2126d0c403e9SAlex Deucher uint16_t crt_info = 2127d0c403e9SAlex Deucher combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 2128d0c403e9SAlex Deucher DRM_DEBUG("Found CRT table, assuming VGA connector\n"); 2129d0c403e9SAlex Deucher if (crt_info) { 2130d0c403e9SAlex Deucher radeon_add_legacy_encoder(dev, 2131d0c403e9SAlex Deucher radeon_get_encoder_id(dev, 2132d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2133d0c403e9SAlex Deucher 1), 2134d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 21356a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 2136eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2137d0c403e9SAlex Deucher radeon_add_legacy_connector(dev, 2138d0c403e9SAlex Deucher 0, 2139d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2140d0c403e9SAlex Deucher DRM_MODE_CONNECTOR_VGA, 2141b75fad06SAlex Deucher &ddc_i2c, 2142eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2143eed45b30SAlex Deucher &hpd); 2144d0c403e9SAlex Deucher } else { 2145771fe6b9SJerome Glisse DRM_DEBUG("No connector info found\n"); 2146771fe6b9SJerome Glisse return false; 2147771fe6b9SJerome Glisse } 2148771fe6b9SJerome Glisse } 2149d0c403e9SAlex Deucher } 2150771fe6b9SJerome Glisse 2151771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) { 2152771fe6b9SJerome Glisse uint16_t lcd_info = 2153771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 2154771fe6b9SJerome Glisse if (lcd_info) { 2155771fe6b9SJerome Glisse uint16_t lcd_ddc_info = 2156771fe6b9SJerome Glisse combios_get_table_offset(dev, 2157771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE); 2158771fe6b9SJerome Glisse 2159771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2160771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 2161771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2162771fe6b9SJerome Glisse 0), 2163771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 2164771fe6b9SJerome Glisse 2165771fe6b9SJerome Glisse if (lcd_ddc_info) { 2166771fe6b9SJerome Glisse ddc_type = RBIOS8(lcd_ddc_info + 2); 2167771fe6b9SJerome Glisse switch (ddc_type) { 2168771fe6b9SJerome Glisse case DDC_MONID: 2169771fe6b9SJerome Glisse ddc_i2c = 2170771fe6b9SJerome Glisse combios_setup_i2c_bus 21716a93cb25SAlex Deucher (rdev, RADEON_GPIO_MONID); 2172771fe6b9SJerome Glisse break; 2173771fe6b9SJerome Glisse case DDC_DVI: 2174771fe6b9SJerome Glisse ddc_i2c = 2175771fe6b9SJerome Glisse combios_setup_i2c_bus 21766a93cb25SAlex Deucher (rdev, RADEON_GPIO_DVI_DDC); 2177771fe6b9SJerome Glisse break; 2178771fe6b9SJerome Glisse case DDC_VGA: 2179771fe6b9SJerome Glisse ddc_i2c = 2180771fe6b9SJerome Glisse combios_setup_i2c_bus 21816a93cb25SAlex Deucher (rdev, RADEON_GPIO_VGA_DDC); 2182771fe6b9SJerome Glisse break; 2183771fe6b9SJerome Glisse case DDC_CRT2: 2184771fe6b9SJerome Glisse ddc_i2c = 2185771fe6b9SJerome Glisse combios_setup_i2c_bus 21866a93cb25SAlex Deucher (rdev, RADEON_GPIO_CRT2_DDC); 2187771fe6b9SJerome Glisse break; 2188771fe6b9SJerome Glisse case DDC_LCD: 2189771fe6b9SJerome Glisse ddc_i2c = 2190771fe6b9SJerome Glisse combios_setup_i2c_bus 21916a93cb25SAlex Deucher (rdev, RADEON_GPIOPAD_MASK); 2192771fe6b9SJerome Glisse ddc_i2c.mask_clk_mask = 2193771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2194771fe6b9SJerome Glisse ddc_i2c.mask_data_mask = 2195771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2196771fe6b9SJerome Glisse ddc_i2c.a_clk_mask = 2197771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2198771fe6b9SJerome Glisse ddc_i2c.a_data_mask = 2199771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 22009b9fe724SAlex Deucher ddc_i2c.en_clk_mask = 2201771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 22029b9fe724SAlex Deucher ddc_i2c.en_data_mask = 2203771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 22049b9fe724SAlex Deucher ddc_i2c.y_clk_mask = 2205771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 22069b9fe724SAlex Deucher ddc_i2c.y_data_mask = 2207771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2208771fe6b9SJerome Glisse break; 2209771fe6b9SJerome Glisse case DDC_GPIO: 2210771fe6b9SJerome Glisse ddc_i2c = 2211771fe6b9SJerome Glisse combios_setup_i2c_bus 22126a93cb25SAlex Deucher (rdev, RADEON_MDGPIO_MASK); 2213771fe6b9SJerome Glisse ddc_i2c.mask_clk_mask = 2214771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2215771fe6b9SJerome Glisse ddc_i2c.mask_data_mask = 2216771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2217771fe6b9SJerome Glisse ddc_i2c.a_clk_mask = 2218771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2219771fe6b9SJerome Glisse ddc_i2c.a_data_mask = 2220771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 22219b9fe724SAlex Deucher ddc_i2c.en_clk_mask = 2222771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 22239b9fe724SAlex Deucher ddc_i2c.en_data_mask = 2224771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 22259b9fe724SAlex Deucher ddc_i2c.y_clk_mask = 2226771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 22279b9fe724SAlex Deucher ddc_i2c.y_data_mask = 2228771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2229771fe6b9SJerome Glisse break; 2230771fe6b9SJerome Glisse default: 2231771fe6b9SJerome Glisse ddc_i2c.valid = false; 2232771fe6b9SJerome Glisse break; 2233771fe6b9SJerome Glisse } 2234771fe6b9SJerome Glisse DRM_DEBUG("LCD DDC Info Table found!\n"); 2235771fe6b9SJerome Glisse } else 2236771fe6b9SJerome Glisse ddc_i2c.valid = false; 2237771fe6b9SJerome Glisse 2238eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2239771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2240771fe6b9SJerome Glisse 5, 2241771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2242771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 2243b75fad06SAlex Deucher &ddc_i2c, 2244eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 2245eed45b30SAlex Deucher &hpd); 2246771fe6b9SJerome Glisse } 2247771fe6b9SJerome Glisse } 2248771fe6b9SJerome Glisse 2249771fe6b9SJerome Glisse /* check TV table */ 2250771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 2251771fe6b9SJerome Glisse uint32_t tv_info = 2252771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 2253771fe6b9SJerome Glisse if (tv_info) { 2254771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 2255790cfb34SAlex Deucher if (radeon_apply_legacy_tv_quirks(dev)) { 2256eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2257771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2258771fe6b9SJerome Glisse radeon_get_encoder_id 2259771fe6b9SJerome Glisse (dev, 2260771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2261771fe6b9SJerome Glisse 2), 2262771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2263771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 6, 2264771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2265771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 2266b75fad06SAlex Deucher &ddc_i2c, 2267eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2268eed45b30SAlex Deucher &hpd); 2269771fe6b9SJerome Glisse } 2270771fe6b9SJerome Glisse } 2271771fe6b9SJerome Glisse } 2272790cfb34SAlex Deucher } 2273771fe6b9SJerome Glisse 2274771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2275771fe6b9SJerome Glisse 2276771fe6b9SJerome Glisse return true; 2277771fe6b9SJerome Glisse } 2278771fe6b9SJerome Glisse 2279fcec570bSAlex Deucher void radeon_external_tmds_setup(struct drm_encoder *encoder) 2280fcec570bSAlex Deucher { 2281fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2282fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2283fcec570bSAlex Deucher 2284fcec570bSAlex Deucher if (!tmds) 2285fcec570bSAlex Deucher return; 2286fcec570bSAlex Deucher 2287fcec570bSAlex Deucher switch (tmds->dvo_chip) { 2288fcec570bSAlex Deucher case DVO_SIL164: 2289fcec570bSAlex Deucher /* sil 164 */ 2290fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 1); 2291fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2292fcec570bSAlex Deucher tmds->slave_addr, 2293fcec570bSAlex Deucher 0x08, 0x30); 2294fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2295fcec570bSAlex Deucher tmds->slave_addr, 2296fcec570bSAlex Deucher 0x09, 0x00); 2297fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2298fcec570bSAlex Deucher tmds->slave_addr, 2299fcec570bSAlex Deucher 0x0a, 0x90); 2300fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2301fcec570bSAlex Deucher tmds->slave_addr, 2302fcec570bSAlex Deucher 0x0c, 0x89); 2303fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2304fcec570bSAlex Deucher tmds->slave_addr, 2305fcec570bSAlex Deucher 0x08, 0x3b); 2306fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 0); 2307fcec570bSAlex Deucher break; 2308fcec570bSAlex Deucher case DVO_SIL1178: 2309fcec570bSAlex Deucher /* sil 1178 - untested */ 2310fcec570bSAlex Deucher /* 2311fcec570bSAlex Deucher * 0x0f, 0x44 2312fcec570bSAlex Deucher * 0x0f, 0x4c 2313fcec570bSAlex Deucher * 0x0e, 0x01 2314fcec570bSAlex Deucher * 0x0a, 0x80 2315fcec570bSAlex Deucher * 0x09, 0x30 2316fcec570bSAlex Deucher * 0x0c, 0xc9 2317fcec570bSAlex Deucher * 0x0d, 0x70 2318fcec570bSAlex Deucher * 0x08, 0x32 2319fcec570bSAlex Deucher * 0x08, 0x33 2320fcec570bSAlex Deucher */ 2321fcec570bSAlex Deucher break; 2322fcec570bSAlex Deucher default: 2323fcec570bSAlex Deucher break; 2324fcec570bSAlex Deucher } 2325fcec570bSAlex Deucher 2326fcec570bSAlex Deucher } 2327fcec570bSAlex Deucher 2328fcec570bSAlex Deucher bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder) 2329fcec570bSAlex Deucher { 2330fcec570bSAlex Deucher struct drm_device *dev = encoder->dev; 2331fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 2332fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2333fcec570bSAlex Deucher uint16_t offset; 2334fcec570bSAlex Deucher uint8_t blocks, slave_addr, rev; 2335fcec570bSAlex Deucher uint32_t index, id; 2336fcec570bSAlex Deucher uint32_t reg, val, and_mask, or_mask; 2337fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2338fcec570bSAlex Deucher 2339fcec570bSAlex Deucher if (rdev->bios == NULL) 2340fcec570bSAlex Deucher return false; 2341fcec570bSAlex Deucher 2342fcec570bSAlex Deucher if (!tmds) 2343fcec570bSAlex Deucher return false; 2344fcec570bSAlex Deucher 2345fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2346fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE); 2347fcec570bSAlex Deucher rev = RBIOS8(offset); 2348fcec570bSAlex Deucher if (offset) { 2349fcec570bSAlex Deucher rev = RBIOS8(offset); 2350fcec570bSAlex Deucher if (rev > 1) { 2351fcec570bSAlex Deucher blocks = RBIOS8(offset + 3); 2352fcec570bSAlex Deucher index = offset + 4; 2353fcec570bSAlex Deucher while (blocks > 0) { 2354fcec570bSAlex Deucher id = RBIOS16(index); 2355fcec570bSAlex Deucher index += 2; 2356fcec570bSAlex Deucher switch (id >> 13) { 2357fcec570bSAlex Deucher case 0: 2358fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2359fcec570bSAlex Deucher val = RBIOS32(index); 2360fcec570bSAlex Deucher index += 4; 2361fcec570bSAlex Deucher WREG32(reg, val); 2362fcec570bSAlex Deucher break; 2363fcec570bSAlex Deucher case 2: 2364fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2365fcec570bSAlex Deucher and_mask = RBIOS32(index); 2366fcec570bSAlex Deucher index += 4; 2367fcec570bSAlex Deucher or_mask = RBIOS32(index); 2368fcec570bSAlex Deucher index += 4; 2369fcec570bSAlex Deucher val = RREG32(reg); 2370fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2371fcec570bSAlex Deucher WREG32(reg, val); 2372fcec570bSAlex Deucher break; 2373fcec570bSAlex Deucher case 3: 2374fcec570bSAlex Deucher val = RBIOS16(index); 2375fcec570bSAlex Deucher index += 2; 2376fcec570bSAlex Deucher udelay(val); 2377fcec570bSAlex Deucher break; 2378fcec570bSAlex Deucher case 4: 2379fcec570bSAlex Deucher val = RBIOS16(index); 2380fcec570bSAlex Deucher index += 2; 2381fcec570bSAlex Deucher udelay(val * 1000); 2382fcec570bSAlex Deucher break; 2383fcec570bSAlex Deucher case 6: 2384fcec570bSAlex Deucher slave_addr = id & 0xff; 2385fcec570bSAlex Deucher slave_addr >>= 1; /* 7 bit addressing */ 2386fcec570bSAlex Deucher index++; 2387fcec570bSAlex Deucher reg = RBIOS8(index); 2388fcec570bSAlex Deucher index++; 2389fcec570bSAlex Deucher val = RBIOS8(index); 2390fcec570bSAlex Deucher index++; 2391fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 1); 2392fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2393fcec570bSAlex Deucher slave_addr, 2394fcec570bSAlex Deucher reg, val); 2395fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 0); 2396fcec570bSAlex Deucher break; 2397fcec570bSAlex Deucher default: 2398fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2399fcec570bSAlex Deucher break; 2400fcec570bSAlex Deucher } 2401fcec570bSAlex Deucher blocks--; 2402fcec570bSAlex Deucher } 2403fcec570bSAlex Deucher return true; 2404fcec570bSAlex Deucher } 2405fcec570bSAlex Deucher } 2406fcec570bSAlex Deucher } else { 2407fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2408fcec570bSAlex Deucher if (offset) { 2409fcec570bSAlex Deucher index = offset + 10; 2410fcec570bSAlex Deucher id = RBIOS16(index); 2411fcec570bSAlex Deucher while (id != 0xffff) { 2412fcec570bSAlex Deucher index += 2; 2413fcec570bSAlex Deucher switch (id >> 13) { 2414fcec570bSAlex Deucher case 0: 2415fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2416fcec570bSAlex Deucher val = RBIOS32(index); 2417fcec570bSAlex Deucher WREG32(reg, val); 2418fcec570bSAlex Deucher break; 2419fcec570bSAlex Deucher case 2: 2420fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2421fcec570bSAlex Deucher and_mask = RBIOS32(index); 2422fcec570bSAlex Deucher index += 4; 2423fcec570bSAlex Deucher or_mask = RBIOS32(index); 2424fcec570bSAlex Deucher index += 4; 2425fcec570bSAlex Deucher val = RREG32(reg); 2426fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2427fcec570bSAlex Deucher WREG32(reg, val); 2428fcec570bSAlex Deucher break; 2429fcec570bSAlex Deucher case 4: 2430fcec570bSAlex Deucher val = RBIOS16(index); 2431fcec570bSAlex Deucher index += 2; 2432fcec570bSAlex Deucher udelay(val); 2433fcec570bSAlex Deucher break; 2434fcec570bSAlex Deucher case 5: 2435fcec570bSAlex Deucher reg = id & 0x1fff; 2436fcec570bSAlex Deucher and_mask = RBIOS32(index); 2437fcec570bSAlex Deucher index += 4; 2438fcec570bSAlex Deucher or_mask = RBIOS32(index); 2439fcec570bSAlex Deucher index += 4; 2440fcec570bSAlex Deucher val = RREG32_PLL(reg); 2441fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2442fcec570bSAlex Deucher WREG32_PLL(reg, val); 2443fcec570bSAlex Deucher break; 2444fcec570bSAlex Deucher case 6: 2445fcec570bSAlex Deucher reg = id & 0x1fff; 2446fcec570bSAlex Deucher val = RBIOS8(index); 2447fcec570bSAlex Deucher index += 1; 2448fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 1); 2449fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2450fcec570bSAlex Deucher tmds->slave_addr, 2451fcec570bSAlex Deucher reg, val); 2452fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 0); 2453fcec570bSAlex Deucher break; 2454fcec570bSAlex Deucher default: 2455fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2456fcec570bSAlex Deucher break; 2457fcec570bSAlex Deucher } 2458fcec570bSAlex Deucher id = RBIOS16(index); 2459fcec570bSAlex Deucher } 2460fcec570bSAlex Deucher return true; 2461fcec570bSAlex Deucher } 2462fcec570bSAlex Deucher } 2463fcec570bSAlex Deucher return false; 2464fcec570bSAlex Deucher } 2465fcec570bSAlex Deucher 2466771fe6b9SJerome Glisse static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset) 2467771fe6b9SJerome Glisse { 2468771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2469771fe6b9SJerome Glisse 2470771fe6b9SJerome Glisse if (offset) { 2471771fe6b9SJerome Glisse while (RBIOS16(offset)) { 2472771fe6b9SJerome Glisse uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13); 2473771fe6b9SJerome Glisse uint32_t addr = (RBIOS16(offset) & 0x1fff); 2474771fe6b9SJerome Glisse uint32_t val, and_mask, or_mask; 2475771fe6b9SJerome Glisse uint32_t tmp; 2476771fe6b9SJerome Glisse 2477771fe6b9SJerome Glisse offset += 2; 2478771fe6b9SJerome Glisse switch (cmd) { 2479771fe6b9SJerome Glisse case 0: 2480771fe6b9SJerome Glisse val = RBIOS32(offset); 2481771fe6b9SJerome Glisse offset += 4; 2482771fe6b9SJerome Glisse WREG32(addr, val); 2483771fe6b9SJerome Glisse break; 2484771fe6b9SJerome Glisse case 1: 2485771fe6b9SJerome Glisse val = RBIOS32(offset); 2486771fe6b9SJerome Glisse offset += 4; 2487771fe6b9SJerome Glisse WREG32(addr, val); 2488771fe6b9SJerome Glisse break; 2489771fe6b9SJerome Glisse case 2: 2490771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2491771fe6b9SJerome Glisse offset += 4; 2492771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2493771fe6b9SJerome Glisse offset += 4; 2494771fe6b9SJerome Glisse tmp = RREG32(addr); 2495771fe6b9SJerome Glisse tmp &= and_mask; 2496771fe6b9SJerome Glisse tmp |= or_mask; 2497771fe6b9SJerome Glisse WREG32(addr, tmp); 2498771fe6b9SJerome Glisse break; 2499771fe6b9SJerome Glisse case 3: 2500771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2501771fe6b9SJerome Glisse offset += 4; 2502771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2503771fe6b9SJerome Glisse offset += 4; 2504771fe6b9SJerome Glisse tmp = RREG32(addr); 2505771fe6b9SJerome Glisse tmp &= and_mask; 2506771fe6b9SJerome Glisse tmp |= or_mask; 2507771fe6b9SJerome Glisse WREG32(addr, tmp); 2508771fe6b9SJerome Glisse break; 2509771fe6b9SJerome Glisse case 4: 2510771fe6b9SJerome Glisse val = RBIOS16(offset); 2511771fe6b9SJerome Glisse offset += 2; 2512771fe6b9SJerome Glisse udelay(val); 2513771fe6b9SJerome Glisse break; 2514771fe6b9SJerome Glisse case 5: 2515771fe6b9SJerome Glisse val = RBIOS16(offset); 2516771fe6b9SJerome Glisse offset += 2; 2517771fe6b9SJerome Glisse switch (addr) { 2518771fe6b9SJerome Glisse case 8: 2519771fe6b9SJerome Glisse while (val--) { 2520771fe6b9SJerome Glisse if (! 2521771fe6b9SJerome Glisse (RREG32_PLL 2522771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2523771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2524771fe6b9SJerome Glisse break; 2525771fe6b9SJerome Glisse } 2526771fe6b9SJerome Glisse break; 2527771fe6b9SJerome Glisse case 9: 2528771fe6b9SJerome Glisse while (val--) { 2529771fe6b9SJerome Glisse if ((RREG32(RADEON_MC_STATUS) & 2530771fe6b9SJerome Glisse RADEON_MC_IDLE)) 2531771fe6b9SJerome Glisse break; 2532771fe6b9SJerome Glisse } 2533771fe6b9SJerome Glisse break; 2534771fe6b9SJerome Glisse default: 2535771fe6b9SJerome Glisse break; 2536771fe6b9SJerome Glisse } 2537771fe6b9SJerome Glisse break; 2538771fe6b9SJerome Glisse default: 2539771fe6b9SJerome Glisse break; 2540771fe6b9SJerome Glisse } 2541771fe6b9SJerome Glisse } 2542771fe6b9SJerome Glisse } 2543771fe6b9SJerome Glisse } 2544771fe6b9SJerome Glisse 2545771fe6b9SJerome Glisse static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset) 2546771fe6b9SJerome Glisse { 2547771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2548771fe6b9SJerome Glisse 2549771fe6b9SJerome Glisse if (offset) { 2550771fe6b9SJerome Glisse while (RBIOS8(offset)) { 2551771fe6b9SJerome Glisse uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6); 2552771fe6b9SJerome Glisse uint8_t addr = (RBIOS8(offset) & 0x3f); 2553771fe6b9SJerome Glisse uint32_t val, shift, tmp; 2554771fe6b9SJerome Glisse uint32_t and_mask, or_mask; 2555771fe6b9SJerome Glisse 2556771fe6b9SJerome Glisse offset++; 2557771fe6b9SJerome Glisse switch (cmd) { 2558771fe6b9SJerome Glisse case 0: 2559771fe6b9SJerome Glisse val = RBIOS32(offset); 2560771fe6b9SJerome Glisse offset += 4; 2561771fe6b9SJerome Glisse WREG32_PLL(addr, val); 2562771fe6b9SJerome Glisse break; 2563771fe6b9SJerome Glisse case 1: 2564771fe6b9SJerome Glisse shift = RBIOS8(offset) * 8; 2565771fe6b9SJerome Glisse offset++; 2566771fe6b9SJerome Glisse and_mask = RBIOS8(offset) << shift; 2567771fe6b9SJerome Glisse and_mask |= ~(0xff << shift); 2568771fe6b9SJerome Glisse offset++; 2569771fe6b9SJerome Glisse or_mask = RBIOS8(offset) << shift; 2570771fe6b9SJerome Glisse offset++; 2571771fe6b9SJerome Glisse tmp = RREG32_PLL(addr); 2572771fe6b9SJerome Glisse tmp &= and_mask; 2573771fe6b9SJerome Glisse tmp |= or_mask; 2574771fe6b9SJerome Glisse WREG32_PLL(addr, tmp); 2575771fe6b9SJerome Glisse break; 2576771fe6b9SJerome Glisse case 2: 2577771fe6b9SJerome Glisse case 3: 2578771fe6b9SJerome Glisse tmp = 1000; 2579771fe6b9SJerome Glisse switch (addr) { 2580771fe6b9SJerome Glisse case 1: 2581771fe6b9SJerome Glisse udelay(150); 2582771fe6b9SJerome Glisse break; 2583771fe6b9SJerome Glisse case 2: 2584771fe6b9SJerome Glisse udelay(1000); 2585771fe6b9SJerome Glisse break; 2586771fe6b9SJerome Glisse case 3: 2587771fe6b9SJerome Glisse while (tmp--) { 2588771fe6b9SJerome Glisse if (! 2589771fe6b9SJerome Glisse (RREG32_PLL 2590771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2591771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2592771fe6b9SJerome Glisse break; 2593771fe6b9SJerome Glisse } 2594771fe6b9SJerome Glisse break; 2595771fe6b9SJerome Glisse case 4: 2596771fe6b9SJerome Glisse while (tmp--) { 2597771fe6b9SJerome Glisse if (RREG32_PLL 2598771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2599771fe6b9SJerome Glisse RADEON_DLL_READY) 2600771fe6b9SJerome Glisse break; 2601771fe6b9SJerome Glisse } 2602771fe6b9SJerome Glisse break; 2603771fe6b9SJerome Glisse case 5: 2604771fe6b9SJerome Glisse tmp = 2605771fe6b9SJerome Glisse RREG32_PLL(RADEON_CLK_PWRMGT_CNTL); 2606771fe6b9SJerome Glisse if (tmp & RADEON_CG_NO1_DEBUG_0) { 2607771fe6b9SJerome Glisse #if 0 2608771fe6b9SJerome Glisse uint32_t mclk_cntl = 2609771fe6b9SJerome Glisse RREG32_PLL 2610771fe6b9SJerome Glisse (RADEON_MCLK_CNTL); 2611771fe6b9SJerome Glisse mclk_cntl &= 0xffff0000; 2612771fe6b9SJerome Glisse /*mclk_cntl |= 0x00001111;*//* ??? */ 2613771fe6b9SJerome Glisse WREG32_PLL(RADEON_MCLK_CNTL, 2614771fe6b9SJerome Glisse mclk_cntl); 2615771fe6b9SJerome Glisse udelay(10000); 2616771fe6b9SJerome Glisse #endif 2617771fe6b9SJerome Glisse WREG32_PLL 2618771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL, 2619771fe6b9SJerome Glisse tmp & 2620771fe6b9SJerome Glisse ~RADEON_CG_NO1_DEBUG_0); 2621771fe6b9SJerome Glisse udelay(10000); 2622771fe6b9SJerome Glisse } 2623771fe6b9SJerome Glisse break; 2624771fe6b9SJerome Glisse default: 2625771fe6b9SJerome Glisse break; 2626771fe6b9SJerome Glisse } 2627771fe6b9SJerome Glisse break; 2628771fe6b9SJerome Glisse default: 2629771fe6b9SJerome Glisse break; 2630771fe6b9SJerome Glisse } 2631771fe6b9SJerome Glisse } 2632771fe6b9SJerome Glisse } 2633771fe6b9SJerome Glisse } 2634771fe6b9SJerome Glisse 2635771fe6b9SJerome Glisse static void combios_parse_ram_reset_table(struct drm_device *dev, 2636771fe6b9SJerome Glisse uint16_t offset) 2637771fe6b9SJerome Glisse { 2638771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2639771fe6b9SJerome Glisse uint32_t tmp; 2640771fe6b9SJerome Glisse 2641771fe6b9SJerome Glisse if (offset) { 2642771fe6b9SJerome Glisse uint8_t val = RBIOS8(offset); 2643771fe6b9SJerome Glisse while (val != 0xff) { 2644771fe6b9SJerome Glisse offset++; 2645771fe6b9SJerome Glisse 2646771fe6b9SJerome Glisse if (val == 0x0f) { 2647771fe6b9SJerome Glisse uint32_t channel_complete_mask; 2648771fe6b9SJerome Glisse 2649771fe6b9SJerome Glisse if (ASIC_IS_R300(rdev)) 2650771fe6b9SJerome Glisse channel_complete_mask = 2651771fe6b9SJerome Glisse R300_MEM_PWRUP_COMPLETE; 2652771fe6b9SJerome Glisse else 2653771fe6b9SJerome Glisse channel_complete_mask = 2654771fe6b9SJerome Glisse RADEON_MEM_PWRUP_COMPLETE; 2655771fe6b9SJerome Glisse tmp = 20000; 2656771fe6b9SJerome Glisse while (tmp--) { 2657771fe6b9SJerome Glisse if ((RREG32(RADEON_MEM_STR_CNTL) & 2658771fe6b9SJerome Glisse channel_complete_mask) == 2659771fe6b9SJerome Glisse channel_complete_mask) 2660771fe6b9SJerome Glisse break; 2661771fe6b9SJerome Glisse } 2662771fe6b9SJerome Glisse } else { 2663771fe6b9SJerome Glisse uint32_t or_mask = RBIOS16(offset); 2664771fe6b9SJerome Glisse offset += 2; 2665771fe6b9SJerome Glisse 2666771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 2667771fe6b9SJerome Glisse tmp &= RADEON_SDRAM_MODE_MASK; 2668771fe6b9SJerome Glisse tmp |= or_mask; 2669771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 2670771fe6b9SJerome Glisse 2671771fe6b9SJerome Glisse or_mask = val << 24; 2672771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 2673771fe6b9SJerome Glisse tmp &= RADEON_B3MEM_RESET_MASK; 2674771fe6b9SJerome Glisse tmp |= or_mask; 2675771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 2676771fe6b9SJerome Glisse } 2677771fe6b9SJerome Glisse val = RBIOS8(offset); 2678771fe6b9SJerome Glisse } 2679771fe6b9SJerome Glisse } 2680771fe6b9SJerome Glisse } 2681771fe6b9SJerome Glisse 2682771fe6b9SJerome Glisse static uint32_t combios_detect_ram(struct drm_device *dev, int ram, 2683771fe6b9SJerome Glisse int mem_addr_mapping) 2684771fe6b9SJerome Glisse { 2685771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2686771fe6b9SJerome Glisse uint32_t mem_cntl; 2687771fe6b9SJerome Glisse uint32_t mem_size; 2688771fe6b9SJerome Glisse uint32_t addr = 0; 2689771fe6b9SJerome Glisse 2690771fe6b9SJerome Glisse mem_cntl = RREG32(RADEON_MEM_CNTL); 2691771fe6b9SJerome Glisse if (mem_cntl & RV100_HALF_MODE) 2692771fe6b9SJerome Glisse ram /= 2; 2693771fe6b9SJerome Glisse mem_size = ram; 2694771fe6b9SJerome Glisse mem_cntl &= ~(0xff << 8); 2695771fe6b9SJerome Glisse mem_cntl |= (mem_addr_mapping & 0xff) << 8; 2696771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 2697771fe6b9SJerome Glisse RREG32(RADEON_MEM_CNTL); 2698771fe6b9SJerome Glisse 2699771fe6b9SJerome Glisse /* sdram reset ? */ 2700771fe6b9SJerome Glisse 2701771fe6b9SJerome Glisse /* something like this???? */ 2702771fe6b9SJerome Glisse while (ram--) { 2703771fe6b9SJerome Glisse addr = ram * 1024 * 1024; 2704771fe6b9SJerome Glisse /* write to each page */ 2705771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 2706771fe6b9SJerome Glisse WREG32(RADEON_MM_DATA, 0xdeadbeef); 2707771fe6b9SJerome Glisse /* read back and verify */ 2708771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 2709771fe6b9SJerome Glisse if (RREG32(RADEON_MM_DATA) != 0xdeadbeef) 2710771fe6b9SJerome Glisse return 0; 2711771fe6b9SJerome Glisse } 2712771fe6b9SJerome Glisse 2713771fe6b9SJerome Glisse return mem_size; 2714771fe6b9SJerome Glisse } 2715771fe6b9SJerome Glisse 2716771fe6b9SJerome Glisse static void combios_write_ram_size(struct drm_device *dev) 2717771fe6b9SJerome Glisse { 2718771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2719771fe6b9SJerome Glisse uint8_t rev; 2720771fe6b9SJerome Glisse uint16_t offset; 2721771fe6b9SJerome Glisse uint32_t mem_size = 0; 2722771fe6b9SJerome Glisse uint32_t mem_cntl = 0; 2723771fe6b9SJerome Glisse 2724771fe6b9SJerome Glisse /* should do something smarter here I guess... */ 2725771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_IGP) 2726771fe6b9SJerome Glisse return; 2727771fe6b9SJerome Glisse 2728771fe6b9SJerome Glisse /* first check detected mem table */ 2729771fe6b9SJerome Glisse offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE); 2730771fe6b9SJerome Glisse if (offset) { 2731771fe6b9SJerome Glisse rev = RBIOS8(offset); 2732771fe6b9SJerome Glisse if (rev < 3) { 2733771fe6b9SJerome Glisse mem_cntl = RBIOS32(offset + 1); 2734771fe6b9SJerome Glisse mem_size = RBIOS16(offset + 5); 2735771fe6b9SJerome Glisse if (((rdev->flags & RADEON_FAMILY_MASK) < CHIP_R200) && 2736771fe6b9SJerome Glisse ((dev->pdev->device != 0x515e) 2737771fe6b9SJerome Glisse && (dev->pdev->device != 0x5969))) 2738771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 2739771fe6b9SJerome Glisse } 2740771fe6b9SJerome Glisse } 2741771fe6b9SJerome Glisse 2742771fe6b9SJerome Glisse if (!mem_size) { 2743771fe6b9SJerome Glisse offset = 2744771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 2745771fe6b9SJerome Glisse if (offset) { 2746771fe6b9SJerome Glisse rev = RBIOS8(offset - 1); 2747771fe6b9SJerome Glisse if (rev < 1) { 2748771fe6b9SJerome Glisse if (((rdev->flags & RADEON_FAMILY_MASK) < 2749771fe6b9SJerome Glisse CHIP_R200) 2750771fe6b9SJerome Glisse && ((dev->pdev->device != 0x515e) 2751771fe6b9SJerome Glisse && (dev->pdev->device != 0x5969))) { 2752771fe6b9SJerome Glisse int ram = 0; 2753771fe6b9SJerome Glisse int mem_addr_mapping = 0; 2754771fe6b9SJerome Glisse 2755771fe6b9SJerome Glisse while (RBIOS8(offset)) { 2756771fe6b9SJerome Glisse ram = RBIOS8(offset); 2757771fe6b9SJerome Glisse mem_addr_mapping = 2758771fe6b9SJerome Glisse RBIOS8(offset + 1); 2759771fe6b9SJerome Glisse if (mem_addr_mapping != 0x25) 2760771fe6b9SJerome Glisse ram *= 2; 2761771fe6b9SJerome Glisse mem_size = 2762771fe6b9SJerome Glisse combios_detect_ram(dev, ram, 2763771fe6b9SJerome Glisse mem_addr_mapping); 2764771fe6b9SJerome Glisse if (mem_size) 2765771fe6b9SJerome Glisse break; 2766771fe6b9SJerome Glisse offset += 2; 2767771fe6b9SJerome Glisse } 2768771fe6b9SJerome Glisse } else 2769771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 2770771fe6b9SJerome Glisse } else { 2771771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 2772771fe6b9SJerome Glisse mem_size *= 2; /* convert to MB */ 2773771fe6b9SJerome Glisse } 2774771fe6b9SJerome Glisse } 2775771fe6b9SJerome Glisse } 2776771fe6b9SJerome Glisse 2777771fe6b9SJerome Glisse mem_size *= (1024 * 1024); /* convert to bytes */ 2778771fe6b9SJerome Glisse WREG32(RADEON_CONFIG_MEMSIZE, mem_size); 2779771fe6b9SJerome Glisse } 2780771fe6b9SJerome Glisse 2781771fe6b9SJerome Glisse void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable) 2782771fe6b9SJerome Glisse { 2783771fe6b9SJerome Glisse uint16_t dyn_clk_info = 2784771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 2785771fe6b9SJerome Glisse 2786771fe6b9SJerome Glisse if (dyn_clk_info) 2787771fe6b9SJerome Glisse combios_parse_pll_table(dev, dyn_clk_info); 2788771fe6b9SJerome Glisse } 2789771fe6b9SJerome Glisse 2790771fe6b9SJerome Glisse void radeon_combios_asic_init(struct drm_device *dev) 2791771fe6b9SJerome Glisse { 2792771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2793771fe6b9SJerome Glisse uint16_t table; 2794771fe6b9SJerome Glisse 2795771fe6b9SJerome Glisse /* port hardcoded mac stuff from radeonfb */ 2796771fe6b9SJerome Glisse if (rdev->bios == NULL) 2797771fe6b9SJerome Glisse return; 2798771fe6b9SJerome Glisse 2799771fe6b9SJerome Glisse /* ASIC INIT 1 */ 2800771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE); 2801771fe6b9SJerome Glisse if (table) 2802771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 2803771fe6b9SJerome Glisse 2804771fe6b9SJerome Glisse /* PLL INIT */ 2805771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE); 2806771fe6b9SJerome Glisse if (table) 2807771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 2808771fe6b9SJerome Glisse 2809771fe6b9SJerome Glisse /* ASIC INIT 2 */ 2810771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE); 2811771fe6b9SJerome Glisse if (table) 2812771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 2813771fe6b9SJerome Glisse 2814771fe6b9SJerome Glisse if (!(rdev->flags & RADEON_IS_IGP)) { 2815771fe6b9SJerome Glisse /* ASIC INIT 4 */ 2816771fe6b9SJerome Glisse table = 2817771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE); 2818771fe6b9SJerome Glisse if (table) 2819771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 2820771fe6b9SJerome Glisse 2821771fe6b9SJerome Glisse /* RAM RESET */ 2822771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE); 2823771fe6b9SJerome Glisse if (table) 2824771fe6b9SJerome Glisse combios_parse_ram_reset_table(dev, table); 2825771fe6b9SJerome Glisse 2826771fe6b9SJerome Glisse /* ASIC INIT 3 */ 2827771fe6b9SJerome Glisse table = 2828771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE); 2829771fe6b9SJerome Glisse if (table) 2830771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 2831771fe6b9SJerome Glisse 2832771fe6b9SJerome Glisse /* write CONFIG_MEMSIZE */ 2833771fe6b9SJerome Glisse combios_write_ram_size(dev); 2834771fe6b9SJerome Glisse } 2835771fe6b9SJerome Glisse 2836771fe6b9SJerome Glisse /* DYN CLK 1 */ 2837771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 2838771fe6b9SJerome Glisse if (table) 2839771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 2840771fe6b9SJerome Glisse 2841771fe6b9SJerome Glisse } 2842771fe6b9SJerome Glisse 2843771fe6b9SJerome Glisse void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev) 2844771fe6b9SJerome Glisse { 2845771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2846771fe6b9SJerome Glisse uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch; 2847771fe6b9SJerome Glisse 2848771fe6b9SJerome Glisse bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); 2849771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 2850771fe6b9SJerome Glisse bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH); 2851771fe6b9SJerome Glisse 2852771fe6b9SJerome Glisse /* let the bios control the backlight */ 2853771fe6b9SJerome Glisse bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN; 2854771fe6b9SJerome Glisse 2855771fe6b9SJerome Glisse /* tell the bios not to handle mode switching */ 2856771fe6b9SJerome Glisse bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS | 2857771fe6b9SJerome Glisse RADEON_ACC_MODE_CHANGE); 2858771fe6b9SJerome Glisse 2859771fe6b9SJerome Glisse /* tell the bios a driver is loaded */ 2860771fe6b9SJerome Glisse bios_7_scratch |= RADEON_DRV_LOADED; 2861771fe6b9SJerome Glisse 2862771fe6b9SJerome Glisse WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch); 2863771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 2864771fe6b9SJerome Glisse WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch); 2865771fe6b9SJerome Glisse } 2866771fe6b9SJerome Glisse 2867771fe6b9SJerome Glisse void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock) 2868771fe6b9SJerome Glisse { 2869771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 2870771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2871771fe6b9SJerome Glisse uint32_t bios_6_scratch; 2872771fe6b9SJerome Glisse 2873771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 2874771fe6b9SJerome Glisse 2875771fe6b9SJerome Glisse if (lock) 2876771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DRIVER_CRITICAL; 2877771fe6b9SJerome Glisse else 2878771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DRIVER_CRITICAL; 2879771fe6b9SJerome Glisse 2880771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 2881771fe6b9SJerome Glisse } 2882771fe6b9SJerome Glisse 2883771fe6b9SJerome Glisse void 2884771fe6b9SJerome Glisse radeon_combios_connected_scratch_regs(struct drm_connector *connector, 2885771fe6b9SJerome Glisse struct drm_encoder *encoder, 2886771fe6b9SJerome Glisse bool connected) 2887771fe6b9SJerome Glisse { 2888771fe6b9SJerome Glisse struct drm_device *dev = connector->dev; 2889771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2890771fe6b9SJerome Glisse struct radeon_connector *radeon_connector = 2891771fe6b9SJerome Glisse to_radeon_connector(connector); 2892771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2893771fe6b9SJerome Glisse uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH); 2894771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 2895771fe6b9SJerome Glisse 2896771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) && 2897771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) { 2898771fe6b9SJerome Glisse if (connected) { 2899771fe6b9SJerome Glisse DRM_DEBUG("TV1 connected\n"); 2900771fe6b9SJerome Glisse /* fix me */ 2901771fe6b9SJerome Glisse bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO; 2902771fe6b9SJerome Glisse /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */ 2903771fe6b9SJerome Glisse bios_5_scratch |= RADEON_TV1_ON; 2904771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_TV1; 2905771fe6b9SJerome Glisse } else { 2906771fe6b9SJerome Glisse DRM_DEBUG("TV1 disconnected\n"); 2907771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK; 2908771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_ON; 2909771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_TV1; 2910771fe6b9SJerome Glisse } 2911771fe6b9SJerome Glisse } 2912771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) && 2913771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) { 2914771fe6b9SJerome Glisse if (connected) { 2915771fe6b9SJerome Glisse DRM_DEBUG("LCD1 connected\n"); 2916771fe6b9SJerome Glisse bios_4_scratch |= RADEON_LCD1_ATTACHED; 2917771fe6b9SJerome Glisse bios_5_scratch |= RADEON_LCD1_ON; 2918771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_LCD1; 2919771fe6b9SJerome Glisse } else { 2920771fe6b9SJerome Glisse DRM_DEBUG("LCD1 disconnected\n"); 2921771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_LCD1_ATTACHED; 2922771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_ON; 2923771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_LCD1; 2924771fe6b9SJerome Glisse } 2925771fe6b9SJerome Glisse } 2926771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) && 2927771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) { 2928771fe6b9SJerome Glisse if (connected) { 2929771fe6b9SJerome Glisse DRM_DEBUG("CRT1 connected\n"); 2930771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR; 2931771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT1_ON; 2932771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT1; 2933771fe6b9SJerome Glisse } else { 2934771fe6b9SJerome Glisse DRM_DEBUG("CRT1 disconnected\n"); 2935771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK; 2936771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_ON; 2937771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT1; 2938771fe6b9SJerome Glisse } 2939771fe6b9SJerome Glisse } 2940771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) && 2941771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) { 2942771fe6b9SJerome Glisse if (connected) { 2943771fe6b9SJerome Glisse DRM_DEBUG("CRT2 connected\n"); 2944771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR; 2945771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT2_ON; 2946771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT2; 2947771fe6b9SJerome Glisse } else { 2948771fe6b9SJerome Glisse DRM_DEBUG("CRT2 disconnected\n"); 2949771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK; 2950771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_ON; 2951771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT2; 2952771fe6b9SJerome Glisse } 2953771fe6b9SJerome Glisse } 2954771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) && 2955771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) { 2956771fe6b9SJerome Glisse if (connected) { 2957771fe6b9SJerome Glisse DRM_DEBUG("DFP1 connected\n"); 2958771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP1_ATTACHED; 2959771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP1_ON; 2960771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP1; 2961771fe6b9SJerome Glisse } else { 2962771fe6b9SJerome Glisse DRM_DEBUG("DFP1 disconnected\n"); 2963771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP1_ATTACHED; 2964771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_ON; 2965771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP1; 2966771fe6b9SJerome Glisse } 2967771fe6b9SJerome Glisse } 2968771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) && 2969771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) { 2970771fe6b9SJerome Glisse if (connected) { 2971771fe6b9SJerome Glisse DRM_DEBUG("DFP2 connected\n"); 2972771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP2_ATTACHED; 2973771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP2_ON; 2974771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP2; 2975771fe6b9SJerome Glisse } else { 2976771fe6b9SJerome Glisse DRM_DEBUG("DFP2 disconnected\n"); 2977771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP2_ATTACHED; 2978771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_ON; 2979771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP2; 2980771fe6b9SJerome Glisse } 2981771fe6b9SJerome Glisse } 2982771fe6b9SJerome Glisse WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch); 2983771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 2984771fe6b9SJerome Glisse } 2985771fe6b9SJerome Glisse 2986771fe6b9SJerome Glisse void 2987771fe6b9SJerome Glisse radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc) 2988771fe6b9SJerome Glisse { 2989771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 2990771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2991771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2992771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 2993771fe6b9SJerome Glisse 2994771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { 2995771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_CRTC_MASK; 2996771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT); 2997771fe6b9SJerome Glisse } 2998771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { 2999771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK; 3000771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT); 3001771fe6b9SJerome Glisse } 3002771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { 3003771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK; 3004771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT); 3005771fe6b9SJerome Glisse } 3006771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { 3007771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK; 3008771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT); 3009771fe6b9SJerome Glisse } 3010771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { 3011771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK; 3012771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT); 3013771fe6b9SJerome Glisse } 3014771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { 3015771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK; 3016771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT); 3017771fe6b9SJerome Glisse } 3018771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3019771fe6b9SJerome Glisse } 3020771fe6b9SJerome Glisse 3021771fe6b9SJerome Glisse void 3022771fe6b9SJerome Glisse radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on) 3023771fe6b9SJerome Glisse { 3024771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3025771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3026771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3027771fe6b9SJerome Glisse uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3028771fe6b9SJerome Glisse 3029771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { 3030771fe6b9SJerome Glisse if (on) 3031771fe6b9SJerome Glisse bios_6_scratch |= RADEON_TV_DPMS_ON; 3032771fe6b9SJerome Glisse else 3033771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_TV_DPMS_ON; 3034771fe6b9SJerome Glisse } 3035771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) { 3036771fe6b9SJerome Glisse if (on) 3037771fe6b9SJerome Glisse bios_6_scratch |= RADEON_CRT_DPMS_ON; 3038771fe6b9SJerome Glisse else 3039771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_CRT_DPMS_ON; 3040771fe6b9SJerome Glisse } 3041771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 3042771fe6b9SJerome Glisse if (on) 3043771fe6b9SJerome Glisse bios_6_scratch |= RADEON_LCD_DPMS_ON; 3044771fe6b9SJerome Glisse else 3045771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_LCD_DPMS_ON; 3046771fe6b9SJerome Glisse } 3047771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 3048771fe6b9SJerome Glisse if (on) 3049771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DFP_DPMS_ON; 3050771fe6b9SJerome Glisse else 3051771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DFP_DPMS_ON; 3052771fe6b9SJerome Glisse } 3053771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3054771fe6b9SJerome Glisse } 3055