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 15303047cdfSMichel Dänzer if (!rdev->bios) 15403047cdfSMichel Dänzer return 0; 15503047cdfSMichel Dänzer 156771fe6b9SJerome Glisse switch (table) { 157771fe6b9SJerome Glisse /* absolute offset tables */ 158771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_1_TABLE: 159771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0xc); 160771fe6b9SJerome Glisse if (check_offset) 161771fe6b9SJerome Glisse offset = check_offset; 162771fe6b9SJerome Glisse break; 163771fe6b9SJerome Glisse case COMBIOS_BIOS_SUPPORT_TABLE: 164771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x14); 165771fe6b9SJerome Glisse if (check_offset) 166771fe6b9SJerome Glisse offset = check_offset; 167771fe6b9SJerome Glisse break; 168771fe6b9SJerome Glisse case COMBIOS_DAC_PROGRAMMING_TABLE: 169771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x2a); 170771fe6b9SJerome Glisse if (check_offset) 171771fe6b9SJerome Glisse offset = check_offset; 172771fe6b9SJerome Glisse break; 173771fe6b9SJerome Glisse case COMBIOS_MAX_COLOR_DEPTH_TABLE: 174771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x2c); 175771fe6b9SJerome Glisse if (check_offset) 176771fe6b9SJerome Glisse offset = check_offset; 177771fe6b9SJerome Glisse break; 178771fe6b9SJerome Glisse case COMBIOS_CRTC_INFO_TABLE: 179771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x2e); 180771fe6b9SJerome Glisse if (check_offset) 181771fe6b9SJerome Glisse offset = check_offset; 182771fe6b9SJerome Glisse break; 183771fe6b9SJerome Glisse case COMBIOS_PLL_INFO_TABLE: 184771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x30); 185771fe6b9SJerome Glisse if (check_offset) 186771fe6b9SJerome Glisse offset = check_offset; 187771fe6b9SJerome Glisse break; 188771fe6b9SJerome Glisse case COMBIOS_TV_INFO_TABLE: 189771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x32); 190771fe6b9SJerome Glisse if (check_offset) 191771fe6b9SJerome Glisse offset = check_offset; 192771fe6b9SJerome Glisse break; 193771fe6b9SJerome Glisse case COMBIOS_DFP_INFO_TABLE: 194771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x34); 195771fe6b9SJerome Glisse if (check_offset) 196771fe6b9SJerome Glisse offset = check_offset; 197771fe6b9SJerome Glisse break; 198771fe6b9SJerome Glisse case COMBIOS_HW_CONFIG_INFO_TABLE: 199771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x36); 200771fe6b9SJerome Glisse if (check_offset) 201771fe6b9SJerome Glisse offset = check_offset; 202771fe6b9SJerome Glisse break; 203771fe6b9SJerome Glisse case COMBIOS_MULTIMEDIA_INFO_TABLE: 204771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x38); 205771fe6b9SJerome Glisse if (check_offset) 206771fe6b9SJerome Glisse offset = check_offset; 207771fe6b9SJerome Glisse break; 208771fe6b9SJerome Glisse case COMBIOS_TV_STD_PATCH_TABLE: 209771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x3e); 210771fe6b9SJerome Glisse if (check_offset) 211771fe6b9SJerome Glisse offset = check_offset; 212771fe6b9SJerome Glisse break; 213771fe6b9SJerome Glisse case COMBIOS_LCD_INFO_TABLE: 214771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x40); 215771fe6b9SJerome Glisse if (check_offset) 216771fe6b9SJerome Glisse offset = check_offset; 217771fe6b9SJerome Glisse break; 218771fe6b9SJerome Glisse case COMBIOS_MOBILE_INFO_TABLE: 219771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x42); 220771fe6b9SJerome Glisse if (check_offset) 221771fe6b9SJerome Glisse offset = check_offset; 222771fe6b9SJerome Glisse break; 223771fe6b9SJerome Glisse case COMBIOS_PLL_INIT_TABLE: 224771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x46); 225771fe6b9SJerome Glisse if (check_offset) 226771fe6b9SJerome Glisse offset = check_offset; 227771fe6b9SJerome Glisse break; 228771fe6b9SJerome Glisse case COMBIOS_MEM_CONFIG_TABLE: 229771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x48); 230771fe6b9SJerome Glisse if (check_offset) 231771fe6b9SJerome Glisse offset = check_offset; 232771fe6b9SJerome Glisse break; 233771fe6b9SJerome Glisse case COMBIOS_SAVE_MASK_TABLE: 234771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x4a); 235771fe6b9SJerome Glisse if (check_offset) 236771fe6b9SJerome Glisse offset = check_offset; 237771fe6b9SJerome Glisse break; 238771fe6b9SJerome Glisse case COMBIOS_HARDCODED_EDID_TABLE: 239771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x4c); 240771fe6b9SJerome Glisse if (check_offset) 241771fe6b9SJerome Glisse offset = check_offset; 242771fe6b9SJerome Glisse break; 243771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_2_TABLE: 244771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x4e); 245771fe6b9SJerome Glisse if (check_offset) 246771fe6b9SJerome Glisse offset = check_offset; 247771fe6b9SJerome Glisse break; 248771fe6b9SJerome Glisse case COMBIOS_CONNECTOR_INFO_TABLE: 249771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x50); 250771fe6b9SJerome Glisse if (check_offset) 251771fe6b9SJerome Glisse offset = check_offset; 252771fe6b9SJerome Glisse break; 253771fe6b9SJerome Glisse case COMBIOS_DYN_CLK_1_TABLE: 254771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x52); 255771fe6b9SJerome Glisse if (check_offset) 256771fe6b9SJerome Glisse offset = check_offset; 257771fe6b9SJerome Glisse break; 258771fe6b9SJerome Glisse case COMBIOS_RESERVED_MEM_TABLE: 259771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x54); 260771fe6b9SJerome Glisse if (check_offset) 261771fe6b9SJerome Glisse offset = check_offset; 262771fe6b9SJerome Glisse break; 263771fe6b9SJerome Glisse case COMBIOS_EXT_TMDS_INFO_TABLE: 264771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x58); 265771fe6b9SJerome Glisse if (check_offset) 266771fe6b9SJerome Glisse offset = check_offset; 267771fe6b9SJerome Glisse break; 268771fe6b9SJerome Glisse case COMBIOS_MEM_CLK_INFO_TABLE: 269771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x5a); 270771fe6b9SJerome Glisse if (check_offset) 271771fe6b9SJerome Glisse offset = check_offset; 272771fe6b9SJerome Glisse break; 273771fe6b9SJerome Glisse case COMBIOS_EXT_DAC_INFO_TABLE: 274771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x5c); 275771fe6b9SJerome Glisse if (check_offset) 276771fe6b9SJerome Glisse offset = check_offset; 277771fe6b9SJerome Glisse break; 278771fe6b9SJerome Glisse case COMBIOS_MISC_INFO_TABLE: 279771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x5e); 280771fe6b9SJerome Glisse if (check_offset) 281771fe6b9SJerome Glisse offset = check_offset; 282771fe6b9SJerome Glisse break; 283771fe6b9SJerome Glisse case COMBIOS_CRT_INFO_TABLE: 284771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x60); 285771fe6b9SJerome Glisse if (check_offset) 286771fe6b9SJerome Glisse offset = check_offset; 287771fe6b9SJerome Glisse break; 288771fe6b9SJerome Glisse case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE: 289771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x62); 290771fe6b9SJerome Glisse if (check_offset) 291771fe6b9SJerome Glisse offset = check_offset; 292771fe6b9SJerome Glisse break; 293771fe6b9SJerome Glisse case COMBIOS_COMPONENT_VIDEO_INFO_TABLE: 294771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x64); 295771fe6b9SJerome Glisse if (check_offset) 296771fe6b9SJerome Glisse offset = check_offset; 297771fe6b9SJerome Glisse break; 298771fe6b9SJerome Glisse case COMBIOS_FAN_SPEED_INFO_TABLE: 299771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x66); 300771fe6b9SJerome Glisse if (check_offset) 301771fe6b9SJerome Glisse offset = check_offset; 302771fe6b9SJerome Glisse break; 303771fe6b9SJerome Glisse case COMBIOS_OVERDRIVE_INFO_TABLE: 304771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x68); 305771fe6b9SJerome Glisse if (check_offset) 306771fe6b9SJerome Glisse offset = check_offset; 307771fe6b9SJerome Glisse break; 308771fe6b9SJerome Glisse case COMBIOS_OEM_INFO_TABLE: 309771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x6a); 310771fe6b9SJerome Glisse if (check_offset) 311771fe6b9SJerome Glisse offset = check_offset; 312771fe6b9SJerome Glisse break; 313771fe6b9SJerome Glisse case COMBIOS_DYN_CLK_2_TABLE: 314771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x6c); 315771fe6b9SJerome Glisse if (check_offset) 316771fe6b9SJerome Glisse offset = check_offset; 317771fe6b9SJerome Glisse break; 318771fe6b9SJerome Glisse case COMBIOS_POWER_CONNECTOR_INFO_TABLE: 319771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x6e); 320771fe6b9SJerome Glisse if (check_offset) 321771fe6b9SJerome Glisse offset = check_offset; 322771fe6b9SJerome Glisse break; 323771fe6b9SJerome Glisse case COMBIOS_I2C_INFO_TABLE: 324771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x70); 325771fe6b9SJerome Glisse if (check_offset) 326771fe6b9SJerome Glisse offset = check_offset; 327771fe6b9SJerome Glisse break; 328771fe6b9SJerome Glisse /* relative offset tables */ 329771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_3_TABLE: /* offset from misc info */ 330771fe6b9SJerome Glisse check_offset = 331771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 332771fe6b9SJerome Glisse if (check_offset) { 333771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 334771fe6b9SJerome Glisse if (rev > 0) { 335771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x3); 336771fe6b9SJerome Glisse if (check_offset) 337771fe6b9SJerome Glisse offset = check_offset; 338771fe6b9SJerome Glisse } 339771fe6b9SJerome Glisse } 340771fe6b9SJerome Glisse break; 341771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_4_TABLE: /* offset from misc info */ 342771fe6b9SJerome Glisse check_offset = 343771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 344771fe6b9SJerome Glisse if (check_offset) { 345771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 346771fe6b9SJerome Glisse if (rev > 0) { 347771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x5); 348771fe6b9SJerome Glisse if (check_offset) 349771fe6b9SJerome Glisse offset = check_offset; 350771fe6b9SJerome Glisse } 351771fe6b9SJerome Glisse } 352771fe6b9SJerome Glisse break; 353771fe6b9SJerome Glisse case COMBIOS_DETECTED_MEM_TABLE: /* offset from misc info */ 354771fe6b9SJerome Glisse check_offset = 355771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 356771fe6b9SJerome Glisse if (check_offset) { 357771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 358771fe6b9SJerome Glisse if (rev > 0) { 359771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x7); 360771fe6b9SJerome Glisse if (check_offset) 361771fe6b9SJerome Glisse offset = check_offset; 362771fe6b9SJerome Glisse } 363771fe6b9SJerome Glisse } 364771fe6b9SJerome Glisse break; 365771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_5_TABLE: /* offset from misc info */ 366771fe6b9SJerome Glisse check_offset = 367771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 368771fe6b9SJerome Glisse if (check_offset) { 369771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 370771fe6b9SJerome Glisse if (rev == 2) { 371771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x9); 372771fe6b9SJerome Glisse if (check_offset) 373771fe6b9SJerome Glisse offset = check_offset; 374771fe6b9SJerome Glisse } 375771fe6b9SJerome Glisse } 376771fe6b9SJerome Glisse break; 377771fe6b9SJerome Glisse case COMBIOS_RAM_RESET_TABLE: /* offset from mem config */ 378771fe6b9SJerome Glisse check_offset = 379771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 380771fe6b9SJerome Glisse if (check_offset) { 381771fe6b9SJerome Glisse while (RBIOS8(check_offset++)); 382771fe6b9SJerome Glisse check_offset += 2; 383771fe6b9SJerome Glisse if (check_offset) 384771fe6b9SJerome Glisse offset = check_offset; 385771fe6b9SJerome Glisse } 386771fe6b9SJerome Glisse break; 387771fe6b9SJerome Glisse case COMBIOS_POWERPLAY_INFO_TABLE: /* offset from mobile info */ 388771fe6b9SJerome Glisse check_offset = 389771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 390771fe6b9SJerome Glisse if (check_offset) { 391771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x11); 392771fe6b9SJerome Glisse if (check_offset) 393771fe6b9SJerome Glisse offset = check_offset; 394771fe6b9SJerome Glisse } 395771fe6b9SJerome Glisse break; 396771fe6b9SJerome Glisse case COMBIOS_GPIO_INFO_TABLE: /* offset from mobile info */ 397771fe6b9SJerome Glisse check_offset = 398771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 399771fe6b9SJerome Glisse if (check_offset) { 400771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x13); 401771fe6b9SJerome Glisse if (check_offset) 402771fe6b9SJerome Glisse offset = check_offset; 403771fe6b9SJerome Glisse } 404771fe6b9SJerome Glisse break; 405771fe6b9SJerome Glisse case COMBIOS_LCD_DDC_INFO_TABLE: /* offset from mobile info */ 406771fe6b9SJerome Glisse check_offset = 407771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 408771fe6b9SJerome Glisse if (check_offset) { 409771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x15); 410771fe6b9SJerome Glisse if (check_offset) 411771fe6b9SJerome Glisse offset = check_offset; 412771fe6b9SJerome Glisse } 413771fe6b9SJerome Glisse break; 414771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_TABLE: /* offset from mobile info */ 415771fe6b9SJerome Glisse check_offset = 416771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 417771fe6b9SJerome Glisse if (check_offset) { 418771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x17); 419771fe6b9SJerome Glisse if (check_offset) 420771fe6b9SJerome Glisse offset = check_offset; 421771fe6b9SJerome Glisse } 422771fe6b9SJerome Glisse break; 423771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_ON_TABLE: /* offset from tmds power */ 424771fe6b9SJerome Glisse check_offset = 425771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); 426771fe6b9SJerome Glisse if (check_offset) { 427771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x2); 428771fe6b9SJerome Glisse if (check_offset) 429771fe6b9SJerome Glisse offset = check_offset; 430771fe6b9SJerome Glisse } 431771fe6b9SJerome Glisse break; 432771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_OFF_TABLE: /* offset from tmds power */ 433771fe6b9SJerome Glisse check_offset = 434771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); 435771fe6b9SJerome Glisse if (check_offset) { 436771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x4); 437771fe6b9SJerome Glisse if (check_offset) 438771fe6b9SJerome Glisse offset = check_offset; 439771fe6b9SJerome Glisse } 440771fe6b9SJerome Glisse break; 441771fe6b9SJerome Glisse default: 442771fe6b9SJerome Glisse break; 443771fe6b9SJerome Glisse } 444771fe6b9SJerome Glisse 445771fe6b9SJerome Glisse return offset; 446771fe6b9SJerome Glisse 447771fe6b9SJerome Glisse } 448771fe6b9SJerome Glisse 4493c537889SAlex Deucher bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev) 4503c537889SAlex Deucher { 4513c537889SAlex Deucher int edid_info; 4523c537889SAlex Deucher struct edid *edid; 4533c537889SAlex Deucher edid_info = combios_get_table_offset(rdev->ddev, COMBIOS_HARDCODED_EDID_TABLE); 4543c537889SAlex Deucher if (!edid_info) 4553c537889SAlex Deucher return false; 4563c537889SAlex Deucher 4573c537889SAlex Deucher edid = kmalloc(EDID_LENGTH * (DRM_MAX_EDID_EXT_NUM + 1), 4583c537889SAlex Deucher GFP_KERNEL); 4593c537889SAlex Deucher if (edid == NULL) 4603c537889SAlex Deucher return false; 4613c537889SAlex Deucher 4623c537889SAlex Deucher memcpy((unsigned char *)edid, 4633c537889SAlex Deucher (unsigned char *)(rdev->bios + edid_info), EDID_LENGTH); 4643c537889SAlex Deucher 4653c537889SAlex Deucher if (!drm_edid_is_valid(edid)) { 4663c537889SAlex Deucher kfree(edid); 4673c537889SAlex Deucher return false; 4683c537889SAlex Deucher } 4693c537889SAlex Deucher 4703c537889SAlex Deucher rdev->mode_info.bios_hardcoded_edid = edid; 4713c537889SAlex Deucher return true; 4723c537889SAlex Deucher } 4733c537889SAlex Deucher 4743c537889SAlex Deucher struct edid * 4753c537889SAlex Deucher radeon_combios_get_hardcoded_edid(struct radeon_device *rdev) 4763c537889SAlex Deucher { 4773c537889SAlex Deucher if (rdev->mode_info.bios_hardcoded_edid) 4783c537889SAlex Deucher return rdev->mode_info.bios_hardcoded_edid; 4793c537889SAlex Deucher return NULL; 4803c537889SAlex Deucher } 4813c537889SAlex Deucher 4826a93cb25SAlex Deucher static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev, 4836a93cb25SAlex Deucher int ddc_line) 484771fe6b9SJerome Glisse { 485771fe6b9SJerome Glisse struct radeon_i2c_bus_rec i2c; 486771fe6b9SJerome Glisse 4876a93cb25SAlex Deucher if (ddc_line == RADEON_GPIOPAD_MASK) { 4886a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_GPIOPAD_MASK; 4896a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_GPIOPAD_MASK; 4906a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_GPIOPAD_A; 4916a93cb25SAlex Deucher i2c.a_data_reg = RADEON_GPIOPAD_A; 4926a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_GPIOPAD_EN; 4936a93cb25SAlex Deucher i2c.en_data_reg = RADEON_GPIOPAD_EN; 4946a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_GPIOPAD_Y; 4956a93cb25SAlex Deucher i2c.y_data_reg = RADEON_GPIOPAD_Y; 4966a93cb25SAlex Deucher } else if (ddc_line == RADEON_MDGPIO_MASK) { 4976a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_MDGPIO_MASK; 4986a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_MDGPIO_MASK; 4996a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_MDGPIO_A; 5006a93cb25SAlex Deucher i2c.a_data_reg = RADEON_MDGPIO_A; 5016a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_MDGPIO_EN; 5026a93cb25SAlex Deucher i2c.en_data_reg = RADEON_MDGPIO_EN; 5036a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_MDGPIO_Y; 5046a93cb25SAlex Deucher i2c.y_data_reg = RADEON_MDGPIO_Y; 5056a93cb25SAlex Deucher } else { 506771fe6b9SJerome Glisse i2c.mask_clk_mask = RADEON_GPIO_EN_1; 507771fe6b9SJerome Glisse i2c.mask_data_mask = RADEON_GPIO_EN_0; 508771fe6b9SJerome Glisse i2c.a_clk_mask = RADEON_GPIO_A_1; 509771fe6b9SJerome Glisse i2c.a_data_mask = RADEON_GPIO_A_0; 5109b9fe724SAlex Deucher i2c.en_clk_mask = RADEON_GPIO_EN_1; 5119b9fe724SAlex Deucher i2c.en_data_mask = RADEON_GPIO_EN_0; 5129b9fe724SAlex Deucher i2c.y_clk_mask = RADEON_GPIO_Y_1; 5139b9fe724SAlex Deucher i2c.y_data_mask = RADEON_GPIO_Y_0; 5146a93cb25SAlex Deucher 515771fe6b9SJerome Glisse i2c.mask_clk_reg = ddc_line; 516771fe6b9SJerome Glisse i2c.mask_data_reg = ddc_line; 517771fe6b9SJerome Glisse i2c.a_clk_reg = ddc_line; 518771fe6b9SJerome Glisse i2c.a_data_reg = ddc_line; 5199b9fe724SAlex Deucher i2c.en_clk_reg = ddc_line; 5209b9fe724SAlex Deucher i2c.en_data_reg = ddc_line; 5219b9fe724SAlex Deucher i2c.y_clk_reg = ddc_line; 5229b9fe724SAlex Deucher i2c.y_data_reg = ddc_line; 523771fe6b9SJerome Glisse } 524771fe6b9SJerome Glisse 52540bacf16SAlex Deucher switch (rdev->family) { 52640bacf16SAlex Deucher case CHIP_R100: 52740bacf16SAlex Deucher case CHIP_RV100: 52840bacf16SAlex Deucher case CHIP_RS100: 52940bacf16SAlex Deucher case CHIP_RV200: 53040bacf16SAlex Deucher case CHIP_RS200: 53140bacf16SAlex Deucher case CHIP_RS300: 53240bacf16SAlex Deucher switch (ddc_line) { 53340bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 53440bacf16SAlex Deucher /* in theory this should be hw capable, 53540bacf16SAlex Deucher * but it doesn't seem to work 53640bacf16SAlex Deucher */ 5376a93cb25SAlex Deucher i2c.hw_capable = false; 53840bacf16SAlex Deucher break; 53940bacf16SAlex Deucher default: 54040bacf16SAlex Deucher i2c.hw_capable = false; 54140bacf16SAlex Deucher break; 54240bacf16SAlex Deucher } 54340bacf16SAlex Deucher break; 54440bacf16SAlex Deucher case CHIP_R200: 54540bacf16SAlex Deucher switch (ddc_line) { 54640bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 54740bacf16SAlex Deucher case RADEON_GPIO_MONID: 54840bacf16SAlex Deucher i2c.hw_capable = true; 54940bacf16SAlex Deucher break; 55040bacf16SAlex Deucher default: 55140bacf16SAlex Deucher i2c.hw_capable = false; 55240bacf16SAlex Deucher break; 55340bacf16SAlex Deucher } 55440bacf16SAlex Deucher break; 55540bacf16SAlex Deucher case CHIP_RV250: 55640bacf16SAlex Deucher case CHIP_RV280: 55740bacf16SAlex Deucher switch (ddc_line) { 55840bacf16SAlex Deucher case RADEON_GPIO_VGA_DDC: 55940bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 56040bacf16SAlex Deucher case RADEON_GPIO_CRT2_DDC: 56140bacf16SAlex Deucher i2c.hw_capable = true; 56240bacf16SAlex Deucher break; 56340bacf16SAlex Deucher default: 56440bacf16SAlex Deucher i2c.hw_capable = false; 56540bacf16SAlex Deucher break; 56640bacf16SAlex Deucher } 56740bacf16SAlex Deucher break; 56840bacf16SAlex Deucher case CHIP_R300: 56940bacf16SAlex Deucher case CHIP_R350: 57040bacf16SAlex Deucher switch (ddc_line) { 57140bacf16SAlex Deucher case RADEON_GPIO_VGA_DDC: 57240bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 57340bacf16SAlex Deucher i2c.hw_capable = true; 57440bacf16SAlex Deucher break; 57540bacf16SAlex Deucher default: 57640bacf16SAlex Deucher i2c.hw_capable = false; 57740bacf16SAlex Deucher break; 57840bacf16SAlex Deucher } 57940bacf16SAlex Deucher break; 58040bacf16SAlex Deucher case CHIP_RV350: 58140bacf16SAlex Deucher case CHIP_RV380: 58240bacf16SAlex Deucher case CHIP_RS400: 58340bacf16SAlex Deucher case CHIP_RS480: 5846a93cb25SAlex Deucher switch (ddc_line) { 5856a93cb25SAlex Deucher case RADEON_GPIO_VGA_DDC: 5866a93cb25SAlex Deucher case RADEON_GPIO_DVI_DDC: 5876a93cb25SAlex Deucher i2c.hw_capable = true; 5886a93cb25SAlex Deucher break; 5896a93cb25SAlex Deucher case RADEON_GPIO_MONID: 5906a93cb25SAlex Deucher /* hw i2c on RADEON_GPIO_MONID doesn't seem to work 5916a93cb25SAlex Deucher * reliably on some pre-r4xx hardware; not sure why. 5926a93cb25SAlex Deucher */ 5936a93cb25SAlex Deucher i2c.hw_capable = false; 5946a93cb25SAlex Deucher break; 5956a93cb25SAlex Deucher default: 5966a93cb25SAlex Deucher i2c.hw_capable = false; 5976a93cb25SAlex Deucher break; 5986a93cb25SAlex Deucher } 59940bacf16SAlex Deucher break; 60040bacf16SAlex Deucher default: 60140bacf16SAlex Deucher i2c.hw_capable = false; 60240bacf16SAlex Deucher break; 6036a93cb25SAlex Deucher } 6046a93cb25SAlex Deucher i2c.mm_i2c = false; 6056a93cb25SAlex Deucher i2c.i2c_id = 0; 606bcc1c2a1SAlex Deucher i2c.hpd_id = 0; 6076a93cb25SAlex Deucher 608771fe6b9SJerome Glisse if (ddc_line) 609771fe6b9SJerome Glisse i2c.valid = true; 610771fe6b9SJerome Glisse else 611771fe6b9SJerome Glisse i2c.valid = false; 612771fe6b9SJerome Glisse 613771fe6b9SJerome Glisse return i2c; 614771fe6b9SJerome Glisse } 615771fe6b9SJerome Glisse 616771fe6b9SJerome Glisse bool radeon_combios_get_clock_info(struct drm_device *dev) 617771fe6b9SJerome Glisse { 618771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 619771fe6b9SJerome Glisse uint16_t pll_info; 620771fe6b9SJerome Glisse struct radeon_pll *p1pll = &rdev->clock.p1pll; 621771fe6b9SJerome Glisse struct radeon_pll *p2pll = &rdev->clock.p2pll; 622771fe6b9SJerome Glisse struct radeon_pll *spll = &rdev->clock.spll; 623771fe6b9SJerome Glisse struct radeon_pll *mpll = &rdev->clock.mpll; 624771fe6b9SJerome Glisse int8_t rev; 625771fe6b9SJerome Glisse uint16_t sclk, mclk; 626771fe6b9SJerome Glisse 627771fe6b9SJerome Glisse pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE); 628771fe6b9SJerome Glisse if (pll_info) { 629771fe6b9SJerome Glisse rev = RBIOS8(pll_info); 630771fe6b9SJerome Glisse 631771fe6b9SJerome Glisse /* pixel clocks */ 632771fe6b9SJerome Glisse p1pll->reference_freq = RBIOS16(pll_info + 0xe); 633771fe6b9SJerome Glisse p1pll->reference_div = RBIOS16(pll_info + 0x10); 634771fe6b9SJerome Glisse p1pll->pll_out_min = RBIOS32(pll_info + 0x12); 635771fe6b9SJerome Glisse p1pll->pll_out_max = RBIOS32(pll_info + 0x16); 636771fe6b9SJerome Glisse 637771fe6b9SJerome Glisse if (rev > 9) { 638771fe6b9SJerome Glisse p1pll->pll_in_min = RBIOS32(pll_info + 0x36); 639771fe6b9SJerome Glisse p1pll->pll_in_max = RBIOS32(pll_info + 0x3a); 640771fe6b9SJerome Glisse } else { 641771fe6b9SJerome Glisse p1pll->pll_in_min = 40; 642771fe6b9SJerome Glisse p1pll->pll_in_max = 500; 643771fe6b9SJerome Glisse } 644771fe6b9SJerome Glisse *p2pll = *p1pll; 645771fe6b9SJerome Glisse 646771fe6b9SJerome Glisse /* system clock */ 647771fe6b9SJerome Glisse spll->reference_freq = RBIOS16(pll_info + 0x1a); 648771fe6b9SJerome Glisse spll->reference_div = RBIOS16(pll_info + 0x1c); 649771fe6b9SJerome Glisse spll->pll_out_min = RBIOS32(pll_info + 0x1e); 650771fe6b9SJerome Glisse spll->pll_out_max = RBIOS32(pll_info + 0x22); 651771fe6b9SJerome Glisse 652771fe6b9SJerome Glisse if (rev > 10) { 653771fe6b9SJerome Glisse spll->pll_in_min = RBIOS32(pll_info + 0x48); 654771fe6b9SJerome Glisse spll->pll_in_max = RBIOS32(pll_info + 0x4c); 655771fe6b9SJerome Glisse } else { 656771fe6b9SJerome Glisse /* ??? */ 657771fe6b9SJerome Glisse spll->pll_in_min = 40; 658771fe6b9SJerome Glisse spll->pll_in_max = 500; 659771fe6b9SJerome Glisse } 660771fe6b9SJerome Glisse 661771fe6b9SJerome Glisse /* memory clock */ 662771fe6b9SJerome Glisse mpll->reference_freq = RBIOS16(pll_info + 0x26); 663771fe6b9SJerome Glisse mpll->reference_div = RBIOS16(pll_info + 0x28); 664771fe6b9SJerome Glisse mpll->pll_out_min = RBIOS32(pll_info + 0x2a); 665771fe6b9SJerome Glisse mpll->pll_out_max = RBIOS32(pll_info + 0x2e); 666771fe6b9SJerome Glisse 667771fe6b9SJerome Glisse if (rev > 10) { 668771fe6b9SJerome Glisse mpll->pll_in_min = RBIOS32(pll_info + 0x5a); 669771fe6b9SJerome Glisse mpll->pll_in_max = RBIOS32(pll_info + 0x5e); 670771fe6b9SJerome Glisse } else { 671771fe6b9SJerome Glisse /* ??? */ 672771fe6b9SJerome Glisse mpll->pll_in_min = 40; 673771fe6b9SJerome Glisse mpll->pll_in_max = 500; 674771fe6b9SJerome Glisse } 675771fe6b9SJerome Glisse 676771fe6b9SJerome Glisse /* default sclk/mclk */ 677771fe6b9SJerome Glisse sclk = RBIOS16(pll_info + 0xa); 678771fe6b9SJerome Glisse mclk = RBIOS16(pll_info + 0x8); 679771fe6b9SJerome Glisse if (sclk == 0) 680771fe6b9SJerome Glisse sclk = 200 * 100; 681771fe6b9SJerome Glisse if (mclk == 0) 682771fe6b9SJerome Glisse mclk = 200 * 100; 683771fe6b9SJerome Glisse 684771fe6b9SJerome Glisse rdev->clock.default_sclk = sclk; 685771fe6b9SJerome Glisse rdev->clock.default_mclk = mclk; 686771fe6b9SJerome Glisse 687771fe6b9SJerome Glisse return true; 688771fe6b9SJerome Glisse } 689771fe6b9SJerome Glisse return false; 690771fe6b9SJerome Glisse } 691771fe6b9SJerome Glisse 69206b6476dSAlex Deucher bool radeon_combios_sideport_present(struct radeon_device *rdev) 69306b6476dSAlex Deucher { 69406b6476dSAlex Deucher struct drm_device *dev = rdev->ddev; 69506b6476dSAlex Deucher u16 igp_info; 69606b6476dSAlex Deucher 69706b6476dSAlex Deucher igp_info = combios_get_table_offset(dev, COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE); 69806b6476dSAlex Deucher 69906b6476dSAlex Deucher if (igp_info) { 70006b6476dSAlex Deucher if (RBIOS16(igp_info + 0x4)) 70106b6476dSAlex Deucher return true; 70206b6476dSAlex Deucher } 70306b6476dSAlex Deucher return false; 70406b6476dSAlex Deucher } 70506b6476dSAlex Deucher 706246263ccSAlex Deucher static const uint32_t default_primarydac_adj[CHIP_LAST] = { 707246263ccSAlex Deucher 0x00000808, /* r100 */ 708246263ccSAlex Deucher 0x00000808, /* rv100 */ 709246263ccSAlex Deucher 0x00000808, /* rs100 */ 710246263ccSAlex Deucher 0x00000808, /* rv200 */ 711246263ccSAlex Deucher 0x00000808, /* rs200 */ 712246263ccSAlex Deucher 0x00000808, /* r200 */ 713246263ccSAlex Deucher 0x00000808, /* rv250 */ 714246263ccSAlex Deucher 0x00000000, /* rs300 */ 715246263ccSAlex Deucher 0x00000808, /* rv280 */ 716246263ccSAlex Deucher 0x00000808, /* r300 */ 717246263ccSAlex Deucher 0x00000808, /* r350 */ 718246263ccSAlex Deucher 0x00000808, /* rv350 */ 719246263ccSAlex Deucher 0x00000808, /* rv380 */ 720246263ccSAlex Deucher 0x00000808, /* r420 */ 721246263ccSAlex Deucher 0x00000808, /* r423 */ 722246263ccSAlex Deucher 0x00000808, /* rv410 */ 723246263ccSAlex Deucher 0x00000000, /* rs400 */ 724246263ccSAlex Deucher 0x00000000, /* rs480 */ 725246263ccSAlex Deucher }; 726246263ccSAlex Deucher 727246263ccSAlex Deucher static void radeon_legacy_get_primary_dac_info_from_table(struct radeon_device *rdev, 728246263ccSAlex Deucher struct radeon_encoder_primary_dac *p_dac) 729246263ccSAlex Deucher { 730246263ccSAlex Deucher p_dac->ps2_pdac_adj = default_primarydac_adj[rdev->family]; 731246263ccSAlex Deucher return; 732246263ccSAlex Deucher } 733246263ccSAlex Deucher 734771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct 735771fe6b9SJerome Glisse radeon_encoder 736771fe6b9SJerome Glisse *encoder) 737771fe6b9SJerome Glisse { 738771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 739771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 740771fe6b9SJerome Glisse uint16_t dac_info; 741771fe6b9SJerome Glisse uint8_t rev, bg, dac; 742771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *p_dac = NULL; 743246263ccSAlex Deucher int found = 0; 744771fe6b9SJerome Glisse 745246263ccSAlex Deucher p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), 746771fe6b9SJerome Glisse GFP_KERNEL); 747771fe6b9SJerome Glisse 748771fe6b9SJerome Glisse if (!p_dac) 749771fe6b9SJerome Glisse return NULL; 750771fe6b9SJerome Glisse 751246263ccSAlex Deucher /* check CRT table */ 752246263ccSAlex Deucher dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 753246263ccSAlex Deucher if (dac_info) { 754771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 755771fe6b9SJerome Glisse if (rev < 2) { 756771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 757771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf; 758771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 759771fe6b9SJerome Glisse } else { 760771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 761771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x3) & 0xf; 762771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 763771fe6b9SJerome Glisse } 764246263ccSAlex Deucher found = 1; 765771fe6b9SJerome Glisse } 766771fe6b9SJerome Glisse 767246263ccSAlex Deucher if (!found) /* fallback to defaults */ 768246263ccSAlex Deucher radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac); 769246263ccSAlex Deucher 770771fe6b9SJerome Glisse return p_dac; 771771fe6b9SJerome Glisse } 772771fe6b9SJerome Glisse 773d79766faSAlex Deucher enum radeon_tv_std 774d79766faSAlex Deucher radeon_combios_get_tv_info(struct radeon_device *rdev) 775771fe6b9SJerome Glisse { 776d79766faSAlex Deucher struct drm_device *dev = rdev->ddev; 777771fe6b9SJerome Glisse uint16_t tv_info; 778771fe6b9SJerome Glisse enum radeon_tv_std tv_std = TV_STD_NTSC; 779771fe6b9SJerome Glisse 780771fe6b9SJerome Glisse tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 781771fe6b9SJerome Glisse if (tv_info) { 782771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 783771fe6b9SJerome Glisse switch (RBIOS8(tv_info + 7) & 0xf) { 784771fe6b9SJerome Glisse case 1: 785771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 786771fe6b9SJerome Glisse DRM_INFO("Default TV standard: NTSC\n"); 787771fe6b9SJerome Glisse break; 788771fe6b9SJerome Glisse case 2: 789771fe6b9SJerome Glisse tv_std = TV_STD_PAL; 790771fe6b9SJerome Glisse DRM_INFO("Default TV standard: PAL\n"); 791771fe6b9SJerome Glisse break; 792771fe6b9SJerome Glisse case 3: 793771fe6b9SJerome Glisse tv_std = TV_STD_PAL_M; 794771fe6b9SJerome Glisse DRM_INFO("Default TV standard: PAL-M\n"); 795771fe6b9SJerome Glisse break; 796771fe6b9SJerome Glisse case 4: 797771fe6b9SJerome Glisse tv_std = TV_STD_PAL_60; 798771fe6b9SJerome Glisse DRM_INFO("Default TV standard: PAL-60\n"); 799771fe6b9SJerome Glisse break; 800771fe6b9SJerome Glisse case 5: 801771fe6b9SJerome Glisse tv_std = TV_STD_NTSC_J; 802771fe6b9SJerome Glisse DRM_INFO("Default TV standard: NTSC-J\n"); 803771fe6b9SJerome Glisse break; 804771fe6b9SJerome Glisse case 6: 805771fe6b9SJerome Glisse tv_std = TV_STD_SCART_PAL; 806771fe6b9SJerome Glisse DRM_INFO("Default TV standard: SCART-PAL\n"); 807771fe6b9SJerome Glisse break; 808771fe6b9SJerome Glisse default: 809771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 810771fe6b9SJerome Glisse DRM_INFO 811771fe6b9SJerome Glisse ("Unknown TV standard; defaulting to NTSC\n"); 812771fe6b9SJerome Glisse break; 813771fe6b9SJerome Glisse } 814771fe6b9SJerome Glisse 815771fe6b9SJerome Glisse switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) { 816771fe6b9SJerome Glisse case 0: 817771fe6b9SJerome Glisse DRM_INFO("29.498928713 MHz TV ref clk\n"); 818771fe6b9SJerome Glisse break; 819771fe6b9SJerome Glisse case 1: 820771fe6b9SJerome Glisse DRM_INFO("28.636360000 MHz TV ref clk\n"); 821771fe6b9SJerome Glisse break; 822771fe6b9SJerome Glisse case 2: 823771fe6b9SJerome Glisse DRM_INFO("14.318180000 MHz TV ref clk\n"); 824771fe6b9SJerome Glisse break; 825771fe6b9SJerome Glisse case 3: 826771fe6b9SJerome Glisse DRM_INFO("27.000000000 MHz TV ref clk\n"); 827771fe6b9SJerome Glisse break; 828771fe6b9SJerome Glisse default: 829771fe6b9SJerome Glisse break; 830771fe6b9SJerome Glisse } 831771fe6b9SJerome Glisse } 832771fe6b9SJerome Glisse } 833771fe6b9SJerome Glisse return tv_std; 834771fe6b9SJerome Glisse } 835771fe6b9SJerome Glisse 836771fe6b9SJerome Glisse static const uint32_t default_tvdac_adj[CHIP_LAST] = { 837771fe6b9SJerome Glisse 0x00000000, /* r100 */ 838771fe6b9SJerome Glisse 0x00280000, /* rv100 */ 839771fe6b9SJerome Glisse 0x00000000, /* rs100 */ 840771fe6b9SJerome Glisse 0x00880000, /* rv200 */ 841771fe6b9SJerome Glisse 0x00000000, /* rs200 */ 842771fe6b9SJerome Glisse 0x00000000, /* r200 */ 843771fe6b9SJerome Glisse 0x00770000, /* rv250 */ 844771fe6b9SJerome Glisse 0x00290000, /* rs300 */ 845771fe6b9SJerome Glisse 0x00560000, /* rv280 */ 846771fe6b9SJerome Glisse 0x00780000, /* r300 */ 847771fe6b9SJerome Glisse 0x00770000, /* r350 */ 848771fe6b9SJerome Glisse 0x00780000, /* rv350 */ 849771fe6b9SJerome Glisse 0x00780000, /* rv380 */ 850771fe6b9SJerome Glisse 0x01080000, /* r420 */ 851771fe6b9SJerome Glisse 0x01080000, /* r423 */ 852771fe6b9SJerome Glisse 0x01080000, /* rv410 */ 853771fe6b9SJerome Glisse 0x00780000, /* rs400 */ 854771fe6b9SJerome Glisse 0x00780000, /* rs480 */ 855771fe6b9SJerome Glisse }; 856771fe6b9SJerome Glisse 8576a719e05SDave Airlie static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev, 8586a719e05SDave Airlie struct radeon_encoder_tv_dac *tv_dac) 859771fe6b9SJerome Glisse { 860771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; 861771fe6b9SJerome Glisse if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) 862771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 0x00880000; 863771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 864771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 8656a719e05SDave Airlie return; 866771fe6b9SJerome Glisse } 867771fe6b9SJerome Glisse 868771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct 869771fe6b9SJerome Glisse radeon_encoder 870771fe6b9SJerome Glisse *encoder) 871771fe6b9SJerome Glisse { 872771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 873771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 874771fe6b9SJerome Glisse uint16_t dac_info; 875771fe6b9SJerome Glisse uint8_t rev, bg, dac; 876771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *tv_dac = NULL; 8776a719e05SDave Airlie int found = 0; 8786a719e05SDave Airlie 8796a719e05SDave Airlie tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); 8806a719e05SDave Airlie if (!tv_dac) 8816a719e05SDave Airlie return NULL; 882771fe6b9SJerome Glisse 883771fe6b9SJerome Glisse /* first check TV table */ 884771fe6b9SJerome Glisse dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 885771fe6b9SJerome Glisse if (dac_info) { 886771fe6b9SJerome Glisse rev = RBIOS8(dac_info + 0x3); 887771fe6b9SJerome Glisse if (rev > 4) { 888771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 889771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xd) & 0xf; 890771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 891771fe6b9SJerome Glisse 892771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 893771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xf) & 0xf; 894771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 895771fe6b9SJerome Glisse 896771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x10) & 0xf; 897771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x11) & 0xf; 898771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 8996a719e05SDave Airlie found = 1; 900771fe6b9SJerome Glisse } else if (rev > 1) { 901771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 902771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; 903771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 904771fe6b9SJerome Glisse 905771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xd) & 0xf; 906771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf; 907771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 908771fe6b9SJerome Glisse 909771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 910771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; 911771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 9126a719e05SDave Airlie found = 1; 913771fe6b9SJerome Glisse } 914d79766faSAlex Deucher tv_dac->tv_std = radeon_combios_get_tv_info(rdev); 9156a719e05SDave Airlie } 9166a719e05SDave Airlie if (!found) { 917771fe6b9SJerome Glisse /* then check CRT table */ 918771fe6b9SJerome Glisse dac_info = 919771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 920771fe6b9SJerome Glisse if (dac_info) { 921771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 922771fe6b9SJerome Glisse if (rev < 2) { 923771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x3) & 0xf; 924771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf; 925771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 926771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 927771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 928771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 9296a719e05SDave Airlie found = 1; 930771fe6b9SJerome Glisse } else { 931771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x4) & 0xf; 932771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x5) & 0xf; 933771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 934771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 935771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 936771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 9376a719e05SDave Airlie found = 1; 938771fe6b9SJerome Glisse } 9396fe7ac3fSAlex Deucher } else { 9406fe7ac3fSAlex Deucher DRM_INFO("No TV DAC info found in BIOS\n"); 941771fe6b9SJerome Glisse } 942771fe6b9SJerome Glisse } 943771fe6b9SJerome Glisse 9446a719e05SDave Airlie if (!found) /* fallback to defaults */ 9456a719e05SDave Airlie radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac); 9466a719e05SDave Airlie 947771fe6b9SJerome Glisse return tv_dac; 948771fe6b9SJerome Glisse } 949771fe6b9SJerome Glisse 950771fe6b9SJerome Glisse static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct 951771fe6b9SJerome Glisse radeon_device 952771fe6b9SJerome Glisse *rdev) 953771fe6b9SJerome Glisse { 954771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 955771fe6b9SJerome Glisse uint32_t fp_vert_stretch, fp_horz_stretch; 956771fe6b9SJerome Glisse uint32_t ppll_div_sel, ppll_val; 9578b5c7444SMichel Dänzer uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL); 958771fe6b9SJerome Glisse 959771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 960771fe6b9SJerome Glisse 961771fe6b9SJerome Glisse if (!lvds) 962771fe6b9SJerome Glisse return NULL; 963771fe6b9SJerome Glisse 964771fe6b9SJerome Glisse fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH); 965771fe6b9SJerome Glisse fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH); 966771fe6b9SJerome Glisse 9678b5c7444SMichel Dänzer /* These should be fail-safe defaults, fingers crossed */ 9688b5c7444SMichel Dänzer lvds->panel_pwr_delay = 200; 9698b5c7444SMichel Dänzer lvds->panel_vcc_delay = 2000; 9708b5c7444SMichel Dänzer 9718b5c7444SMichel Dänzer lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL); 9728b5c7444SMichel Dänzer lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf; 9738b5c7444SMichel Dänzer lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf; 9748b5c7444SMichel Dänzer 975771fe6b9SJerome Glisse if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE) 976de2103e4SAlex Deucher lvds->native_mode.vdisplay = 977771fe6b9SJerome Glisse ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >> 978771fe6b9SJerome Glisse RADEON_VERT_PANEL_SHIFT) + 1; 979771fe6b9SJerome Glisse else 980de2103e4SAlex Deucher lvds->native_mode.vdisplay = 981771fe6b9SJerome Glisse (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1; 982771fe6b9SJerome Glisse 983771fe6b9SJerome Glisse if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE) 984de2103e4SAlex Deucher lvds->native_mode.hdisplay = 985771fe6b9SJerome Glisse (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >> 986771fe6b9SJerome Glisse RADEON_HORZ_PANEL_SHIFT) + 1) * 8; 987771fe6b9SJerome Glisse else 988de2103e4SAlex Deucher lvds->native_mode.hdisplay = 989771fe6b9SJerome Glisse ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8; 990771fe6b9SJerome Glisse 991de2103e4SAlex Deucher if ((lvds->native_mode.hdisplay < 640) || 992de2103e4SAlex Deucher (lvds->native_mode.vdisplay < 480)) { 993de2103e4SAlex Deucher lvds->native_mode.hdisplay = 640; 994de2103e4SAlex Deucher lvds->native_mode.vdisplay = 480; 995771fe6b9SJerome Glisse } 996771fe6b9SJerome Glisse 997771fe6b9SJerome Glisse ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3; 998771fe6b9SJerome Glisse ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel); 999771fe6b9SJerome Glisse if ((ppll_val & 0x000707ff) == 0x1bb) 1000771fe6b9SJerome Glisse lvds->use_bios_dividers = false; 1001771fe6b9SJerome Glisse else { 1002771fe6b9SJerome Glisse lvds->panel_ref_divider = 1003771fe6b9SJerome Glisse RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff; 1004771fe6b9SJerome Glisse lvds->panel_post_divider = (ppll_val >> 16) & 0x7; 1005771fe6b9SJerome Glisse lvds->panel_fb_divider = ppll_val & 0x7ff; 1006771fe6b9SJerome Glisse 1007771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1008771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1009771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1010771fe6b9SJerome Glisse } 1011771fe6b9SJerome Glisse lvds->panel_vcc_delay = 200; 1012771fe6b9SJerome Glisse 1013771fe6b9SJerome Glisse DRM_INFO("Panel info derived from registers\n"); 1014de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1015de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1016771fe6b9SJerome Glisse 1017771fe6b9SJerome Glisse return lvds; 1018771fe6b9SJerome Glisse } 1019771fe6b9SJerome Glisse 1020771fe6b9SJerome Glisse struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder 1021771fe6b9SJerome Glisse *encoder) 1022771fe6b9SJerome Glisse { 1023771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1024771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1025771fe6b9SJerome Glisse uint16_t lcd_info; 1026771fe6b9SJerome Glisse uint32_t panel_setup; 1027771fe6b9SJerome Glisse char stmp[30]; 1028771fe6b9SJerome Glisse int tmp, i; 1029771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 1030771fe6b9SJerome Glisse 1031771fe6b9SJerome Glisse lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 1032771fe6b9SJerome Glisse 1033771fe6b9SJerome Glisse if (lcd_info) { 1034771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 1035771fe6b9SJerome Glisse 1036771fe6b9SJerome Glisse if (!lvds) 1037771fe6b9SJerome Glisse return NULL; 1038771fe6b9SJerome Glisse 1039771fe6b9SJerome Glisse for (i = 0; i < 24; i++) 1040771fe6b9SJerome Glisse stmp[i] = RBIOS8(lcd_info + i + 1); 1041771fe6b9SJerome Glisse stmp[24] = 0; 1042771fe6b9SJerome Glisse 1043771fe6b9SJerome Glisse DRM_INFO("Panel ID String: %s\n", stmp); 1044771fe6b9SJerome Glisse 1045de2103e4SAlex Deucher lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19); 1046de2103e4SAlex Deucher lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b); 1047771fe6b9SJerome Glisse 1048de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1049de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1050771fe6b9SJerome Glisse 1051771fe6b9SJerome Glisse lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c); 105294cf6434SAndrew Morton lvds->panel_vcc_delay = min_t(u16, lvds->panel_vcc_delay, 2000); 1053771fe6b9SJerome Glisse 1054771fe6b9SJerome Glisse lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24); 1055771fe6b9SJerome Glisse lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf; 1056771fe6b9SJerome Glisse lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf; 1057771fe6b9SJerome Glisse 1058771fe6b9SJerome Glisse lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e); 1059771fe6b9SJerome Glisse lvds->panel_post_divider = RBIOS8(lcd_info + 0x30); 1060771fe6b9SJerome Glisse lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31); 1061771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1062771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1063771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1064771fe6b9SJerome Glisse 1065771fe6b9SJerome Glisse panel_setup = RBIOS32(lcd_info + 0x39); 1066771fe6b9SJerome Glisse lvds->lvds_gen_cntl = 0xff00; 1067771fe6b9SJerome Glisse if (panel_setup & 0x1) 1068771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT; 1069771fe6b9SJerome Glisse 1070771fe6b9SJerome Glisse if ((panel_setup >> 4) & 0x1) 1071771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE; 1072771fe6b9SJerome Glisse 1073771fe6b9SJerome Glisse switch ((panel_setup >> 8) & 0x7) { 1074771fe6b9SJerome Glisse case 0: 1075771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM; 1076771fe6b9SJerome Glisse break; 1077771fe6b9SJerome Glisse case 1: 1078771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY; 1079771fe6b9SJerome Glisse break; 1080771fe6b9SJerome Glisse case 2: 1081771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY; 1082771fe6b9SJerome Glisse break; 1083771fe6b9SJerome Glisse default: 1084771fe6b9SJerome Glisse break; 1085771fe6b9SJerome Glisse } 1086771fe6b9SJerome Glisse 1087771fe6b9SJerome Glisse if ((panel_setup >> 16) & 0x1) 1088771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW; 1089771fe6b9SJerome Glisse 1090771fe6b9SJerome Glisse if ((panel_setup >> 17) & 0x1) 1091771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW; 1092771fe6b9SJerome Glisse 1093771fe6b9SJerome Glisse if ((panel_setup >> 18) & 0x1) 1094771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW; 1095771fe6b9SJerome Glisse 1096771fe6b9SJerome Glisse if ((panel_setup >> 23) & 0x1) 1097771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL; 1098771fe6b9SJerome Glisse 1099771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000); 1100771fe6b9SJerome Glisse 1101771fe6b9SJerome Glisse for (i = 0; i < 32; i++) { 1102771fe6b9SJerome Glisse tmp = RBIOS16(lcd_info + 64 + i * 2); 1103771fe6b9SJerome Glisse if (tmp == 0) 1104771fe6b9SJerome Glisse break; 1105771fe6b9SJerome Glisse 1106de2103e4SAlex Deucher if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) && 1107771fe6b9SJerome Glisse (RBIOS16(tmp + 2) == 1108de2103e4SAlex Deucher lvds->native_mode.vdisplay)) { 1109de2103e4SAlex Deucher lvds->native_mode.htotal = RBIOS16(tmp + 17) * 8; 1110de2103e4SAlex Deucher lvds->native_mode.hsync_start = RBIOS16(tmp + 21) * 8; 1111de2103e4SAlex Deucher lvds->native_mode.hsync_end = (RBIOS8(tmp + 23) + 1112de2103e4SAlex Deucher RBIOS16(tmp + 21)) * 8; 1113771fe6b9SJerome Glisse 1114de2103e4SAlex Deucher lvds->native_mode.vtotal = RBIOS16(tmp + 24); 1115de2103e4SAlex Deucher lvds->native_mode.vsync_start = RBIOS16(tmp + 28) & 0x7ff; 1116de2103e4SAlex Deucher lvds->native_mode.vsync_end = 1117de2103e4SAlex Deucher ((RBIOS16(tmp + 28) & 0xf800) >> 11) + 1118de2103e4SAlex Deucher (RBIOS16(tmp + 28) & 0x7ff); 1119de2103e4SAlex Deucher 1120de2103e4SAlex Deucher lvds->native_mode.clock = RBIOS16(tmp + 9) * 10; 1121771fe6b9SJerome Glisse lvds->native_mode.flags = 0; 1122de2103e4SAlex Deucher /* set crtc values */ 1123de2103e4SAlex Deucher drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V); 1124de2103e4SAlex Deucher 1125771fe6b9SJerome Glisse } 1126771fe6b9SJerome Glisse } 11276fe7ac3fSAlex Deucher } else { 1128771fe6b9SJerome Glisse DRM_INFO("No panel info found in BIOS\n"); 11298dfaa8a7SMichel Dänzer lvds = radeon_legacy_get_lvds_info_from_regs(rdev); 11306fe7ac3fSAlex Deucher } 113103047cdfSMichel Dänzer 11328dfaa8a7SMichel Dänzer if (lvds) 11338dfaa8a7SMichel Dänzer encoder->native_mode = lvds->native_mode; 1134771fe6b9SJerome Glisse return lvds; 1135771fe6b9SJerome Glisse } 1136771fe6b9SJerome Glisse 1137771fe6b9SJerome Glisse static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = { 1138771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */ 1139771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */ 1140771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */ 1141771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */ 1142771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */ 1143771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */ 1144771fe6b9SJerome Glisse {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */ 1145771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */ 1146771fe6b9SJerome Glisse {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */ 1147771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */ 1148771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */ 1149771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */ 1150771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */ 1151771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */ 1152771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */ 1153771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */ 1154fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */ 1155fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */ 1156771fe6b9SJerome Glisse }; 1157771fe6b9SJerome Glisse 1158445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder, 1159445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1160771fe6b9SJerome Glisse { 1161445282dbSDave Airlie struct drm_device *dev = encoder->base.dev; 1162445282dbSDave Airlie struct radeon_device *rdev = dev->dev_private; 1163771fe6b9SJerome Glisse int i; 1164771fe6b9SJerome Glisse 1165771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 1166771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1167771fe6b9SJerome Glisse default_tmds_pll[rdev->family][i].value; 1168771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq; 1169771fe6b9SJerome Glisse } 1170771fe6b9SJerome Glisse 1171445282dbSDave Airlie return true; 1172771fe6b9SJerome Glisse } 1173771fe6b9SJerome Glisse 1174445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder, 1175445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1176771fe6b9SJerome Glisse { 1177771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1178771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1179771fe6b9SJerome Glisse uint16_t tmds_info; 1180771fe6b9SJerome Glisse int i, n; 1181771fe6b9SJerome Glisse uint8_t ver; 1182771fe6b9SJerome Glisse 1183771fe6b9SJerome Glisse tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 1184771fe6b9SJerome Glisse 1185771fe6b9SJerome Glisse if (tmds_info) { 1186771fe6b9SJerome Glisse ver = RBIOS8(tmds_info); 1187771fe6b9SJerome Glisse DRM_INFO("DFP table revision: %d\n", ver); 1188771fe6b9SJerome Glisse if (ver == 3) { 1189771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1190771fe6b9SJerome Glisse if (n > 4) 1191771fe6b9SJerome Glisse n = 4; 1192771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1193771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1194771fe6b9SJerome Glisse RBIOS32(tmds_info + i * 10 + 0x08); 1195771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1196771fe6b9SJerome Glisse RBIOS16(tmds_info + i * 10 + 0x10); 1197771fe6b9SJerome Glisse DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n", 1198771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1199771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1200771fe6b9SJerome Glisse } 1201771fe6b9SJerome Glisse } else if (ver == 4) { 1202771fe6b9SJerome Glisse int stride = 0; 1203771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1204771fe6b9SJerome Glisse if (n > 4) 1205771fe6b9SJerome Glisse n = 4; 1206771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1207771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1208771fe6b9SJerome Glisse RBIOS32(tmds_info + stride + 0x08); 1209771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1210771fe6b9SJerome Glisse RBIOS16(tmds_info + stride + 0x10); 1211771fe6b9SJerome Glisse if (i == 0) 1212771fe6b9SJerome Glisse stride += 10; 1213771fe6b9SJerome Glisse else 1214771fe6b9SJerome Glisse stride += 6; 1215771fe6b9SJerome Glisse DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n", 1216771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1217771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1218771fe6b9SJerome Glisse } 1219771fe6b9SJerome Glisse } 1220fcec570bSAlex Deucher } else { 1221771fe6b9SJerome Glisse DRM_INFO("No TMDS info found in BIOS\n"); 1222fcec570bSAlex Deucher return false; 1223fcec570bSAlex Deucher } 1224445282dbSDave Airlie return true; 1225445282dbSDave Airlie } 1226445282dbSDave Airlie 1227fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder, 1228fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1229771fe6b9SJerome Glisse { 1230771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1231771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1232fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1233fcec570bSAlex Deucher 1234fcec570bSAlex Deucher /* default for macs */ 12356a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1236fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1237fcec570bSAlex Deucher 1238fcec570bSAlex Deucher /* XXX some macs have duallink chips */ 1239fcec570bSAlex Deucher switch (rdev->mode_info.connector_table) { 1240fcec570bSAlex Deucher case CT_POWERBOOK_EXTERNAL: 1241fcec570bSAlex Deucher case CT_MINI_EXTERNAL: 1242fcec570bSAlex Deucher default: 1243fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1244fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1245fcec570bSAlex Deucher break; 1246fcec570bSAlex Deucher } 1247fcec570bSAlex Deucher 1248fcec570bSAlex Deucher return true; 1249fcec570bSAlex Deucher } 1250fcec570bSAlex Deucher 1251fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder, 1252fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1253fcec570bSAlex Deucher { 1254fcec570bSAlex Deucher struct drm_device *dev = encoder->base.dev; 1255fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 1256fcec570bSAlex Deucher uint16_t offset; 1257fcec570bSAlex Deucher uint8_t ver, id, blocks, clk, data; 1258fcec570bSAlex Deucher int i; 1259fcec570bSAlex Deucher enum radeon_combios_ddc gpio; 1260fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1261771fe6b9SJerome Glisse 1262fcec570bSAlex Deucher tmds->i2c_bus = NULL; 1263fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 1264fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE); 1265fcec570bSAlex Deucher if (offset) { 1266fcec570bSAlex Deucher ver = RBIOS8(offset); 1267fcec570bSAlex Deucher DRM_INFO("GPIO Table revision: %d\n", ver); 1268fcec570bSAlex Deucher blocks = RBIOS8(offset + 2); 1269fcec570bSAlex Deucher for (i = 0; i < blocks; i++) { 1270fcec570bSAlex Deucher id = RBIOS8(offset + 3 + (i * 5) + 0); 1271fcec570bSAlex Deucher if (id == 136) { 1272fcec570bSAlex Deucher clk = RBIOS8(offset + 3 + (i * 5) + 3); 1273fcec570bSAlex Deucher data = RBIOS8(offset + 3 + (i * 5) + 4); 1274fcec570bSAlex Deucher i2c_bus.valid = true; 1275fcec570bSAlex Deucher i2c_bus.mask_clk_mask = (1 << clk); 1276fcec570bSAlex Deucher i2c_bus.mask_data_mask = (1 << data); 1277fcec570bSAlex Deucher i2c_bus.a_clk_mask = (1 << clk); 1278fcec570bSAlex Deucher i2c_bus.a_data_mask = (1 << data); 1279fcec570bSAlex Deucher i2c_bus.en_clk_mask = (1 << clk); 1280fcec570bSAlex Deucher i2c_bus.en_data_mask = (1 << data); 1281fcec570bSAlex Deucher i2c_bus.y_clk_mask = (1 << clk); 1282fcec570bSAlex Deucher i2c_bus.y_data_mask = (1 << data); 1283fcec570bSAlex Deucher i2c_bus.mask_clk_reg = RADEON_GPIOPAD_MASK; 1284fcec570bSAlex Deucher i2c_bus.mask_data_reg = RADEON_GPIOPAD_MASK; 1285fcec570bSAlex Deucher i2c_bus.a_clk_reg = RADEON_GPIOPAD_A; 1286fcec570bSAlex Deucher i2c_bus.a_data_reg = RADEON_GPIOPAD_A; 1287fcec570bSAlex Deucher i2c_bus.en_clk_reg = RADEON_GPIOPAD_EN; 1288fcec570bSAlex Deucher i2c_bus.en_data_reg = RADEON_GPIOPAD_EN; 1289fcec570bSAlex Deucher i2c_bus.y_clk_reg = RADEON_GPIOPAD_Y; 1290fcec570bSAlex Deucher i2c_bus.y_data_reg = RADEON_GPIOPAD_Y; 1291fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1292fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1293fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1294fcec570bSAlex Deucher break; 1295771fe6b9SJerome Glisse } 1296771fe6b9SJerome Glisse } 1297fcec570bSAlex Deucher } 1298fcec570bSAlex Deucher } else { 1299fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 1300fcec570bSAlex Deucher if (offset) { 1301fcec570bSAlex Deucher ver = RBIOS8(offset); 1302fcec570bSAlex Deucher DRM_INFO("External TMDS Table revision: %d\n", ver); 1303fcec570bSAlex Deucher tmds->slave_addr = RBIOS8(offset + 4 + 2); 1304fcec570bSAlex Deucher tmds->slave_addr >>= 1; /* 7 bit addressing */ 1305fcec570bSAlex Deucher gpio = RBIOS8(offset + 4 + 3); 1306fcec570bSAlex Deucher switch (gpio) { 1307fcec570bSAlex Deucher case DDC_MONID: 13086a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1309fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1310fcec570bSAlex Deucher break; 1311fcec570bSAlex Deucher case DDC_DVI: 13126a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1313fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1314fcec570bSAlex Deucher break; 1315fcec570bSAlex Deucher case DDC_VGA: 13166a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1317fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1318fcec570bSAlex Deucher break; 1319fcec570bSAlex Deucher case DDC_CRT2: 1320fcec570bSAlex Deucher /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */ 1321fcec570bSAlex Deucher if (rdev->family >= CHIP_R300) 13226a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1323fcec570bSAlex Deucher else 13246a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); 1325fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1326fcec570bSAlex Deucher break; 1327fcec570bSAlex Deucher case DDC_LCD: /* MM i2c */ 132840bacf16SAlex Deucher i2c_bus.valid = true; 132940bacf16SAlex Deucher i2c_bus.hw_capable = true; 133040bacf16SAlex Deucher i2c_bus.mm_i2c = true; 133140bacf16SAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1332fcec570bSAlex Deucher break; 1333fcec570bSAlex Deucher default: 1334fcec570bSAlex Deucher DRM_ERROR("Unsupported gpio %d\n", gpio); 1335fcec570bSAlex Deucher break; 1336fcec570bSAlex Deucher } 1337fcec570bSAlex Deucher } 1338fcec570bSAlex Deucher } 1339fcec570bSAlex Deucher 1340fcec570bSAlex Deucher if (!tmds->i2c_bus) { 1341fcec570bSAlex Deucher DRM_INFO("No valid Ext TMDS info found in BIOS\n"); 1342fcec570bSAlex Deucher return false; 1343fcec570bSAlex Deucher } 1344fcec570bSAlex Deucher 1345fcec570bSAlex Deucher return true; 1346fcec570bSAlex Deucher } 1347771fe6b9SJerome Glisse 1348771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) 1349771fe6b9SJerome Glisse { 1350771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1351771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 1352eed45b30SAlex Deucher struct radeon_hpd hpd; 1353771fe6b9SJerome Glisse 1354771fe6b9SJerome Glisse rdev->mode_info.connector_table = radeon_connector_table; 1355771fe6b9SJerome Glisse if (rdev->mode_info.connector_table == CT_NONE) { 1356771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 1357771fe6b9SJerome Glisse if (machine_is_compatible("PowerBook3,3")) { 1358771fe6b9SJerome Glisse /* powerbook with VGA */ 1359771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_VGA; 1360771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook3,4") || 1361771fe6b9SJerome Glisse machine_is_compatible("PowerBook3,5")) { 1362771fe6b9SJerome Glisse /* powerbook with internal tmds */ 1363771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; 1364771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook5,1") || 1365771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,2") || 1366771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,3") || 1367771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,4") || 1368771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,5")) { 1369771fe6b9SJerome Glisse /* powerbook with external single link tmds (sil164) */ 1370771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 1371771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook5,6")) { 1372771fe6b9SJerome Glisse /* powerbook with external dual or single link tmds */ 1373771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 1374771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook5,7") || 1375771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,8") || 1376771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,9")) { 1377771fe6b9SJerome Glisse /* PowerBook6,2 ? */ 1378771fe6b9SJerome Glisse /* powerbook with external dual link tmds (sil1178?) */ 1379771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 1380771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook4,1") || 1381771fe6b9SJerome Glisse machine_is_compatible("PowerBook4,2") || 1382771fe6b9SJerome Glisse machine_is_compatible("PowerBook4,3") || 1383771fe6b9SJerome Glisse machine_is_compatible("PowerBook6,3") || 1384771fe6b9SJerome Glisse machine_is_compatible("PowerBook6,5") || 1385771fe6b9SJerome Glisse machine_is_compatible("PowerBook6,7")) { 1386771fe6b9SJerome Glisse /* ibook */ 1387771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IBOOK; 1388771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac4,4")) { 1389771fe6b9SJerome Glisse /* emac */ 1390771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_EMAC; 1391771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac10,1")) { 1392771fe6b9SJerome Glisse /* mini with internal tmds */ 1393771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_INTERNAL; 1394771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac10,2")) { 1395771fe6b9SJerome Glisse /* mini with external tmds */ 1396771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_EXTERNAL; 1397771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac12,1")) { 1398771fe6b9SJerome Glisse /* PowerMac8,1 ? */ 1399771fe6b9SJerome Glisse /* imac g5 isight */ 1400771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; 1401771fe6b9SJerome Glisse } else 1402771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 1403771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_GENERIC; 1404771fe6b9SJerome Glisse } 1405771fe6b9SJerome Glisse 1406771fe6b9SJerome Glisse switch (rdev->mode_info.connector_table) { 1407771fe6b9SJerome Glisse case CT_GENERIC: 1408771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (generic)\n", 1409771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1410771fe6b9SJerome Glisse /* these are the most common settings */ 1411771fe6b9SJerome Glisse if (rdev->flags & RADEON_SINGLE_CRTC) { 1412771fe6b9SJerome Glisse /* VGA - primary dac */ 14136a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1414eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1415771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1416771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1417771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1418771fe6b9SJerome Glisse 1), 1419771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1420771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1421771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1422771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1423b75fad06SAlex Deucher &ddc_i2c, 1424eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1425eed45b30SAlex Deucher &hpd); 1426771fe6b9SJerome Glisse } else if (rdev->flags & RADEON_IS_MOBILITY) { 1427771fe6b9SJerome Glisse /* LVDS */ 14286a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, 0); 1429eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1430771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1431771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1432771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1433771fe6b9SJerome Glisse 0), 1434771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1435771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1436771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1437771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 1438b75fad06SAlex Deucher &ddc_i2c, 1439eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1440eed45b30SAlex Deucher &hpd); 1441771fe6b9SJerome Glisse 1442771fe6b9SJerome Glisse /* VGA - primary dac */ 14436a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1444eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1445771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1446771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1447771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1448771fe6b9SJerome Glisse 1), 1449771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1450771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1451771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1452771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1453b75fad06SAlex Deucher &ddc_i2c, 1454eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1455eed45b30SAlex Deucher &hpd); 1456771fe6b9SJerome Glisse } else { 1457771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 14586a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1459eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 1460771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1461771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1462771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1463771fe6b9SJerome Glisse 0), 1464771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1465771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1466771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1467771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1468771fe6b9SJerome Glisse 2), 1469771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1470771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1471771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1472771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1473771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 1474b75fad06SAlex Deucher &ddc_i2c, 1475eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1476eed45b30SAlex Deucher &hpd); 1477771fe6b9SJerome Glisse 1478771fe6b9SJerome Glisse /* VGA - primary dac */ 14796a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_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_CRT1_SUPPORT, 1484771fe6b9SJerome Glisse 1), 1485771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1486771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1487771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1488771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1489b75fad06SAlex Deucher &ddc_i2c, 1490eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1491eed45b30SAlex Deucher &hpd); 1492771fe6b9SJerome Glisse } 1493771fe6b9SJerome Glisse 1494771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 1495771fe6b9SJerome Glisse /* TV - tv dac */ 1496eed45b30SAlex Deucher ddc_i2c.valid = false; 1497eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1498771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1499771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1500771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1501771fe6b9SJerome Glisse 2), 1502771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1503771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, 1504771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1505771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1506b75fad06SAlex Deucher &ddc_i2c, 1507eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1508eed45b30SAlex Deucher &hpd); 1509771fe6b9SJerome Glisse } 1510771fe6b9SJerome Glisse break; 1511771fe6b9SJerome Glisse case CT_IBOOK: 1512771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (ibook)\n", 1513771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1514771fe6b9SJerome Glisse /* LVDS */ 15156a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1516eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1517771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1518771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1519771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1520771fe6b9SJerome Glisse 0), 1521771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1522771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1523b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1524eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1525eed45b30SAlex Deucher &hpd); 1526771fe6b9SJerome Glisse /* VGA - TV DAC */ 15276a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1528eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1529771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1530771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1531771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1532771fe6b9SJerome Glisse 2), 1533771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1534771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1535b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1536eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1537eed45b30SAlex Deucher &hpd); 1538771fe6b9SJerome Glisse /* TV - TV DAC */ 1539eed45b30SAlex Deucher ddc_i2c.valid = false; 1540eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1541771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1542771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1543771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1544771fe6b9SJerome Glisse 2), 1545771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1546771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1547771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1548b75fad06SAlex Deucher &ddc_i2c, 1549eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1550eed45b30SAlex Deucher &hpd); 1551771fe6b9SJerome Glisse break; 1552771fe6b9SJerome Glisse case CT_POWERBOOK_EXTERNAL: 1553771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook external tmds)\n", 1554771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1555771fe6b9SJerome Glisse /* LVDS */ 15566a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1557eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1558771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1559771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1560771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1561771fe6b9SJerome Glisse 0), 1562771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1563771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1564b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1565eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1566eed45b30SAlex Deucher &hpd); 1567771fe6b9SJerome Glisse /* DVI-I - primary dac, ext tmds */ 15686a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1569eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1570771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1571771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1572771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1573771fe6b9SJerome Glisse 0), 1574771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1575771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1576771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1577771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1578771fe6b9SJerome Glisse 1), 1579771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1580b75fad06SAlex Deucher /* XXX some are SL */ 1581771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1582771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1583771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1584b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1585eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 1586eed45b30SAlex Deucher &hpd); 1587771fe6b9SJerome Glisse /* TV - TV DAC */ 1588eed45b30SAlex Deucher ddc_i2c.valid = false; 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_TV1_SUPPORT, 1593771fe6b9SJerome Glisse 2), 1594771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1595771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1596771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1597b75fad06SAlex Deucher &ddc_i2c, 1598eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1599eed45b30SAlex Deucher &hpd); 1600771fe6b9SJerome Glisse break; 1601771fe6b9SJerome Glisse case CT_POWERBOOK_INTERNAL: 1602771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook internal tmds)\n", 1603771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1604771fe6b9SJerome Glisse /* LVDS */ 16056a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1606eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1607771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1608771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1609771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1610771fe6b9SJerome Glisse 0), 1611771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1612771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1613b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1614eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1615eed45b30SAlex Deucher &hpd); 1616771fe6b9SJerome Glisse /* DVI-I - primary dac, int tmds */ 16176a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1618eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1619771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1620771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1621771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1622771fe6b9SJerome Glisse 0), 1623771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1624771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1625771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1626771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1627771fe6b9SJerome Glisse 1), 1628771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1629771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1630771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1631771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1632b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1633eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1634eed45b30SAlex Deucher &hpd); 1635771fe6b9SJerome Glisse /* TV - TV DAC */ 1636eed45b30SAlex Deucher ddc_i2c.valid = false; 1637eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1638771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1639771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1640771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1641771fe6b9SJerome Glisse 2), 1642771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1643771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1644771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1645b75fad06SAlex Deucher &ddc_i2c, 1646eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1647eed45b30SAlex Deucher &hpd); 1648771fe6b9SJerome Glisse break; 1649771fe6b9SJerome Glisse case CT_POWERBOOK_VGA: 1650771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook vga)\n", 1651771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1652771fe6b9SJerome Glisse /* LVDS */ 16536a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1654eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1655771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1656771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1657771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1658771fe6b9SJerome Glisse 0), 1659771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1660771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1661b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1662eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1663eed45b30SAlex Deucher &hpd); 1664771fe6b9SJerome Glisse /* VGA - primary dac */ 16656a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1666eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1667771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1668771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1669771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1670771fe6b9SJerome Glisse 1), 1671771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1672771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT, 1673b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1674eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1675eed45b30SAlex Deucher &hpd); 1676771fe6b9SJerome Glisse /* TV - TV DAC */ 1677eed45b30SAlex Deucher ddc_i2c.valid = false; 1678eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1679771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1680771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1681771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1682771fe6b9SJerome Glisse 2), 1683771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1684771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1685771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1686b75fad06SAlex Deucher &ddc_i2c, 1687eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1688eed45b30SAlex Deucher &hpd); 1689771fe6b9SJerome Glisse break; 1690771fe6b9SJerome Glisse case CT_MINI_EXTERNAL: 1691771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini external tmds)\n", 1692771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1693771fe6b9SJerome Glisse /* DVI-I - tv dac, ext tmds */ 16946a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); 1695eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1696771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1697771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1698771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1699771fe6b9SJerome Glisse 0), 1700771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1701771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1702771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1703771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1704771fe6b9SJerome Glisse 2), 1705771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1706b75fad06SAlex Deucher /* XXX are any DL? */ 1707771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1708771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1709771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1710b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1711eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 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, 1, 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_MINI_INTERNAL: 1728771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini internal tmds)\n", 1729771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1730771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 17316a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); 1732eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1733771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1734771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1735771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1736771fe6b9SJerome Glisse 0), 1737771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1738771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1739771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1740771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1741771fe6b9SJerome Glisse 2), 1742771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1743771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1744771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1745771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1746b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1747eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1748eed45b30SAlex Deucher &hpd); 1749771fe6b9SJerome Glisse /* TV - TV DAC */ 1750eed45b30SAlex Deucher ddc_i2c.valid = false; 1751eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1752771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1753771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1754771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1755771fe6b9SJerome Glisse 2), 1756771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1757771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1758771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1759b75fad06SAlex Deucher &ddc_i2c, 1760eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1761eed45b30SAlex Deucher &hpd); 1762771fe6b9SJerome Glisse break; 1763771fe6b9SJerome Glisse case CT_IMAC_G5_ISIGHT: 1764771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (imac g5 isight)\n", 1765771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1766771fe6b9SJerome Glisse /* DVI-D - int tmds */ 17676a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1768eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1769771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1770771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1771771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1772771fe6b9SJerome Glisse 0), 1773771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1774771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT, 1775b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVID, &ddc_i2c, 1776eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 1777eed45b30SAlex Deucher &hpd); 1778771fe6b9SJerome Glisse /* VGA - tv dac */ 17796a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1780eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1781771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1782771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1783771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1784771fe6b9SJerome Glisse 2), 1785771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1786771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1787b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1788eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1789eed45b30SAlex Deucher &hpd); 1790771fe6b9SJerome Glisse /* TV - TV DAC */ 1791eed45b30SAlex Deucher ddc_i2c.valid = false; 1792eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1793771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1794771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1795771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1796771fe6b9SJerome Glisse 2), 1797771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1798771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1799771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1800b75fad06SAlex Deucher &ddc_i2c, 1801eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1802eed45b30SAlex Deucher &hpd); 1803771fe6b9SJerome Glisse break; 1804771fe6b9SJerome Glisse case CT_EMAC: 1805771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (emac)\n", 1806771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1807771fe6b9SJerome Glisse /* VGA - primary dac */ 18086a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1809eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1810771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1811771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1812771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1813771fe6b9SJerome Glisse 1), 1814771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1815771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 1816b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1817eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1818eed45b30SAlex Deucher &hpd); 1819771fe6b9SJerome Glisse /* VGA - tv dac */ 18206a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); 1821eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1822771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1823771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1824771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1825771fe6b9SJerome Glisse 2), 1826771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1827771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1828b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1829eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1830eed45b30SAlex Deucher &hpd); 1831771fe6b9SJerome Glisse /* TV - TV DAC */ 1832eed45b30SAlex Deucher ddc_i2c.valid = false; 1833eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1834771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1835771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1836771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1837771fe6b9SJerome Glisse 2), 1838771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1839771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1840771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1841b75fad06SAlex Deucher &ddc_i2c, 1842eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1843eed45b30SAlex Deucher &hpd); 1844771fe6b9SJerome Glisse break; 1845771fe6b9SJerome Glisse default: 1846771fe6b9SJerome Glisse DRM_INFO("Connector table: %d (invalid)\n", 1847771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1848771fe6b9SJerome Glisse return false; 1849771fe6b9SJerome Glisse } 1850771fe6b9SJerome Glisse 1851771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 1852771fe6b9SJerome Glisse 1853771fe6b9SJerome Glisse return true; 1854771fe6b9SJerome Glisse } 1855771fe6b9SJerome Glisse 1856771fe6b9SJerome Glisse static bool radeon_apply_legacy_quirks(struct drm_device *dev, 1857771fe6b9SJerome Glisse int bios_index, 1858771fe6b9SJerome Glisse enum radeon_combios_connector 1859771fe6b9SJerome Glisse *legacy_connector, 1860eed45b30SAlex Deucher struct radeon_i2c_bus_rec *ddc_i2c, 1861eed45b30SAlex Deucher struct radeon_hpd *hpd) 1862771fe6b9SJerome Glisse { 1863771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1864771fe6b9SJerome Glisse 1865771fe6b9SJerome Glisse /* XPRESS DDC quirks */ 1866771fe6b9SJerome Glisse if ((rdev->family == CHIP_RS400 || 1867771fe6b9SJerome Glisse rdev->family == CHIP_RS480) && 1868771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 18696a93cb25SAlex Deucher *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1870771fe6b9SJerome Glisse else if ((rdev->family == CHIP_RS400 || 1871771fe6b9SJerome Glisse rdev->family == CHIP_RS480) && 1872771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_MONID) { 18736a93cb25SAlex Deucher *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIOPAD_MASK); 1874771fe6b9SJerome Glisse ddc_i2c->mask_clk_mask = (0x20 << 8); 1875771fe6b9SJerome Glisse ddc_i2c->mask_data_mask = 0x80; 1876771fe6b9SJerome Glisse ddc_i2c->a_clk_mask = (0x20 << 8); 1877771fe6b9SJerome Glisse ddc_i2c->a_data_mask = 0x80; 18789b9fe724SAlex Deucher ddc_i2c->en_clk_mask = (0x20 << 8); 18799b9fe724SAlex Deucher ddc_i2c->en_data_mask = 0x80; 18809b9fe724SAlex Deucher ddc_i2c->y_clk_mask = (0x20 << 8); 18819b9fe724SAlex Deucher ddc_i2c->y_data_mask = 0x80; 1882771fe6b9SJerome Glisse } 1883771fe6b9SJerome Glisse 1884fcec570bSAlex Deucher /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */ 1885fcec570bSAlex Deucher if ((rdev->family >= CHIP_R300) && 1886fcec570bSAlex Deucher ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 18876a93cb25SAlex Deucher *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1888fcec570bSAlex Deucher 1889771fe6b9SJerome Glisse /* Certain IBM chipset RN50s have a BIOS reporting two VGAs, 1890771fe6b9SJerome Glisse one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */ 1891771fe6b9SJerome Glisse if (dev->pdev->device == 0x515e && 1892771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x1014) { 1893771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_CRT_LEGACY && 1894771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 1895771fe6b9SJerome Glisse return false; 1896771fe6b9SJerome Glisse } 1897771fe6b9SJerome Glisse 1898771fe6b9SJerome Glisse /* Some RV100 cards with 2 VGA ports show up with DVI+VGA */ 1899771fe6b9SJerome Glisse if (dev->pdev->device == 0x5159 && 1900771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x1002 && 1901771fe6b9SJerome Glisse dev->pdev->subsystem_device == 0x013a) { 1902771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_DVI_I_LEGACY) 1903771fe6b9SJerome Glisse *legacy_connector = CONNECTOR_CRT_LEGACY; 1904771fe6b9SJerome Glisse 1905771fe6b9SJerome Glisse } 1906771fe6b9SJerome Glisse 1907771fe6b9SJerome Glisse /* X300 card with extra non-existent DVI port */ 1908771fe6b9SJerome Glisse if (dev->pdev->device == 0x5B60 && 1909771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x17af && 1910771fe6b9SJerome Glisse dev->pdev->subsystem_device == 0x201e && bios_index == 2) { 1911771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_DVI_I_LEGACY) 1912771fe6b9SJerome Glisse return false; 1913771fe6b9SJerome Glisse } 1914771fe6b9SJerome Glisse 1915771fe6b9SJerome Glisse return true; 1916771fe6b9SJerome Glisse } 1917771fe6b9SJerome Glisse 1918790cfb34SAlex Deucher static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev) 1919790cfb34SAlex Deucher { 1920790cfb34SAlex Deucher /* Acer 5102 has non-existent TV port */ 1921790cfb34SAlex Deucher if (dev->pdev->device == 0x5975 && 1922790cfb34SAlex Deucher dev->pdev->subsystem_vendor == 0x1025 && 1923790cfb34SAlex Deucher dev->pdev->subsystem_device == 0x009f) 1924790cfb34SAlex Deucher return false; 1925790cfb34SAlex Deucher 1926fc7f7119SAlex Deucher /* HP dc5750 has non-existent TV port */ 1927fc7f7119SAlex Deucher if (dev->pdev->device == 0x5974 && 1928fc7f7119SAlex Deucher dev->pdev->subsystem_vendor == 0x103c && 1929fc7f7119SAlex Deucher dev->pdev->subsystem_device == 0x280a) 1930fc7f7119SAlex Deucher return false; 1931fc7f7119SAlex Deucher 1932fd874ad0SAlex Deucher /* MSI S270 has non-existent TV port */ 1933fd874ad0SAlex Deucher if (dev->pdev->device == 0x5955 && 1934fd874ad0SAlex Deucher dev->pdev->subsystem_vendor == 0x1462 && 1935fd874ad0SAlex Deucher dev->pdev->subsystem_device == 0x0131) 1936fd874ad0SAlex Deucher return false; 1937fd874ad0SAlex Deucher 1938790cfb34SAlex Deucher return true; 1939790cfb34SAlex Deucher } 1940790cfb34SAlex Deucher 1941b75fad06SAlex Deucher static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d) 1942b75fad06SAlex Deucher { 1943b75fad06SAlex Deucher struct radeon_device *rdev = dev->dev_private; 1944b75fad06SAlex Deucher uint32_t ext_tmds_info; 1945b75fad06SAlex Deucher 1946b75fad06SAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 1947b75fad06SAlex Deucher if (is_dvi_d) 1948b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 1949b75fad06SAlex Deucher else 1950b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 1951b75fad06SAlex Deucher } 1952b75fad06SAlex Deucher ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 1953b75fad06SAlex Deucher if (ext_tmds_info) { 1954b75fad06SAlex Deucher uint8_t rev = RBIOS8(ext_tmds_info); 1955b75fad06SAlex Deucher uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5); 1956b75fad06SAlex Deucher if (rev >= 3) { 1957b75fad06SAlex Deucher if (is_dvi_d) 1958b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 1959b75fad06SAlex Deucher else 1960b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 1961b75fad06SAlex Deucher } else { 1962b75fad06SAlex Deucher if (flags & 1) { 1963b75fad06SAlex Deucher if (is_dvi_d) 1964b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 1965b75fad06SAlex Deucher else 1966b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 1967b75fad06SAlex Deucher } 1968b75fad06SAlex Deucher } 1969b75fad06SAlex Deucher } 1970b75fad06SAlex Deucher if (is_dvi_d) 1971b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 1972b75fad06SAlex Deucher else 1973b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 1974b75fad06SAlex Deucher } 1975b75fad06SAlex Deucher 1976771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) 1977771fe6b9SJerome Glisse { 1978771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1979771fe6b9SJerome Glisse uint32_t conn_info, entry, devices; 1980b75fad06SAlex Deucher uint16_t tmp, connector_object_id; 1981771fe6b9SJerome Glisse enum radeon_combios_ddc ddc_type; 1982771fe6b9SJerome Glisse enum radeon_combios_connector connector; 1983771fe6b9SJerome Glisse int i = 0; 1984771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 1985eed45b30SAlex Deucher struct radeon_hpd hpd; 1986771fe6b9SJerome Glisse 1987771fe6b9SJerome Glisse conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE); 1988771fe6b9SJerome Glisse if (conn_info) { 1989771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 1990771fe6b9SJerome Glisse entry = conn_info + 2 + i * 2; 1991771fe6b9SJerome Glisse 1992771fe6b9SJerome Glisse if (!RBIOS16(entry)) 1993771fe6b9SJerome Glisse break; 1994771fe6b9SJerome Glisse 1995771fe6b9SJerome Glisse tmp = RBIOS16(entry); 1996771fe6b9SJerome Glisse 1997771fe6b9SJerome Glisse connector = (tmp >> 12) & 0xf; 1998771fe6b9SJerome Glisse 1999771fe6b9SJerome Glisse ddc_type = (tmp >> 8) & 0xf; 2000771fe6b9SJerome Glisse switch (ddc_type) { 2001771fe6b9SJerome Glisse case DDC_MONID: 2002771fe6b9SJerome Glisse ddc_i2c = 20036a93cb25SAlex Deucher combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 2004771fe6b9SJerome Glisse break; 2005771fe6b9SJerome Glisse case DDC_DVI: 2006771fe6b9SJerome Glisse ddc_i2c = 20076a93cb25SAlex Deucher combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 2008771fe6b9SJerome Glisse break; 2009771fe6b9SJerome Glisse case DDC_VGA: 2010771fe6b9SJerome Glisse ddc_i2c = 20116a93cb25SAlex Deucher combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 2012771fe6b9SJerome Glisse break; 2013771fe6b9SJerome Glisse case DDC_CRT2: 2014771fe6b9SJerome Glisse ddc_i2c = 20156a93cb25SAlex Deucher combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); 2016771fe6b9SJerome Glisse break; 2017771fe6b9SJerome Glisse default: 2018771fe6b9SJerome Glisse break; 2019771fe6b9SJerome Glisse } 2020771fe6b9SJerome Glisse 2021eed45b30SAlex Deucher switch (connector) { 2022eed45b30SAlex Deucher case CONNECTOR_PROPRIETARY_LEGACY: 2023eed45b30SAlex Deucher case CONNECTOR_DVI_I_LEGACY: 2024eed45b30SAlex Deucher case CONNECTOR_DVI_D_LEGACY: 2025eed45b30SAlex Deucher if ((tmp >> 4) & 0x1) 2026eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; 2027eed45b30SAlex Deucher else 2028eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 2029eed45b30SAlex Deucher break; 2030eed45b30SAlex Deucher default: 2031eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2032eed45b30SAlex Deucher break; 2033eed45b30SAlex Deucher } 2034eed45b30SAlex Deucher 20352d152c6bSAlex Deucher if (!radeon_apply_legacy_quirks(dev, i, &connector, 2036eed45b30SAlex Deucher &ddc_i2c, &hpd)) 20372d152c6bSAlex Deucher continue; 2038771fe6b9SJerome Glisse 2039771fe6b9SJerome Glisse switch (connector) { 2040771fe6b9SJerome Glisse case CONNECTOR_PROPRIETARY_LEGACY: 2041771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) 2042771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2043771fe6b9SJerome Glisse else 2044771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2045771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2046771fe6b9SJerome Glisse radeon_get_encoder_id 2047771fe6b9SJerome Glisse (dev, devices, 0), 2048771fe6b9SJerome Glisse devices); 2049771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2050771fe6b9SJerome Glisse legacy_connector_convert 2051771fe6b9SJerome Glisse [connector], 2052b75fad06SAlex Deucher &ddc_i2c, 2053eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 2054eed45b30SAlex Deucher &hpd); 2055771fe6b9SJerome Glisse break; 2056771fe6b9SJerome Glisse case CONNECTOR_CRT_LEGACY: 2057771fe6b9SJerome Glisse if (tmp & 0x1) { 2058771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT2_SUPPORT; 2059771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2060771fe6b9SJerome Glisse radeon_get_encoder_id 2061771fe6b9SJerome Glisse (dev, 2062771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2063771fe6b9SJerome Glisse 2), 2064771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2065771fe6b9SJerome Glisse } else { 2066771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT1_SUPPORT; 2067771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2068771fe6b9SJerome Glisse radeon_get_encoder_id 2069771fe6b9SJerome Glisse (dev, 2070771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2071771fe6b9SJerome Glisse 1), 2072771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2073771fe6b9SJerome Glisse } 2074771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2075771fe6b9SJerome Glisse i, 2076771fe6b9SJerome Glisse devices, 2077771fe6b9SJerome Glisse legacy_connector_convert 2078771fe6b9SJerome Glisse [connector], 2079b75fad06SAlex Deucher &ddc_i2c, 2080eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2081eed45b30SAlex Deucher &hpd); 2082771fe6b9SJerome Glisse break; 2083771fe6b9SJerome Glisse case CONNECTOR_DVI_I_LEGACY: 2084771fe6b9SJerome Glisse devices = 0; 2085771fe6b9SJerome Glisse if (tmp & 0x1) { 2086771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT2_SUPPORT; 2087771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2088771fe6b9SJerome Glisse radeon_get_encoder_id 2089771fe6b9SJerome Glisse (dev, 2090771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2091771fe6b9SJerome Glisse 2), 2092771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2093771fe6b9SJerome Glisse } else { 2094771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT1_SUPPORT; 2095771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2096771fe6b9SJerome Glisse radeon_get_encoder_id 2097771fe6b9SJerome Glisse (dev, 2098771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2099771fe6b9SJerome Glisse 1), 2100771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2101771fe6b9SJerome Glisse } 2102771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) { 2103771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP2_SUPPORT; 2104771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2105771fe6b9SJerome Glisse radeon_get_encoder_id 2106771fe6b9SJerome Glisse (dev, 2107771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 2108771fe6b9SJerome Glisse 0), 2109771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 2110b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 0); 2111771fe6b9SJerome Glisse } else { 2112771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP1_SUPPORT; 2113771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2114771fe6b9SJerome Glisse radeon_get_encoder_id 2115771fe6b9SJerome Glisse (dev, 2116771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2117771fe6b9SJerome Glisse 0), 2118771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2119b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2120771fe6b9SJerome Glisse } 2121771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2122771fe6b9SJerome Glisse i, 2123771fe6b9SJerome Glisse devices, 2124771fe6b9SJerome Glisse legacy_connector_convert 2125771fe6b9SJerome Glisse [connector], 2126b75fad06SAlex Deucher &ddc_i2c, 2127eed45b30SAlex Deucher connector_object_id, 2128eed45b30SAlex Deucher &hpd); 2129771fe6b9SJerome Glisse break; 2130771fe6b9SJerome Glisse case CONNECTOR_DVI_D_LEGACY: 2131b75fad06SAlex Deucher if ((tmp >> 4) & 0x1) { 2132771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2133b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 1); 2134b75fad06SAlex Deucher } else { 2135771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2136b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2137b75fad06SAlex Deucher } 2138771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2139771fe6b9SJerome Glisse radeon_get_encoder_id 2140771fe6b9SJerome Glisse (dev, devices, 0), 2141771fe6b9SJerome Glisse devices); 2142771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2143771fe6b9SJerome Glisse legacy_connector_convert 2144771fe6b9SJerome Glisse [connector], 2145b75fad06SAlex Deucher &ddc_i2c, 2146eed45b30SAlex Deucher connector_object_id, 2147eed45b30SAlex Deucher &hpd); 2148771fe6b9SJerome Glisse break; 2149771fe6b9SJerome Glisse case CONNECTOR_CTV_LEGACY: 2150771fe6b9SJerome Glisse case CONNECTOR_STV_LEGACY: 2151771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2152771fe6b9SJerome Glisse radeon_get_encoder_id 2153771fe6b9SJerome Glisse (dev, 2154771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2155771fe6b9SJerome Glisse 2), 2156771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2157771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, 2158771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2159771fe6b9SJerome Glisse legacy_connector_convert 2160771fe6b9SJerome Glisse [connector], 2161b75fad06SAlex Deucher &ddc_i2c, 2162eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2163eed45b30SAlex Deucher &hpd); 2164771fe6b9SJerome Glisse break; 2165771fe6b9SJerome Glisse default: 2166771fe6b9SJerome Glisse DRM_ERROR("Unknown connector type: %d\n", 2167771fe6b9SJerome Glisse connector); 2168771fe6b9SJerome Glisse continue; 2169771fe6b9SJerome Glisse } 2170771fe6b9SJerome Glisse 2171771fe6b9SJerome Glisse } 2172771fe6b9SJerome Glisse } else { 2173771fe6b9SJerome Glisse uint16_t tmds_info = 2174771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 2175771fe6b9SJerome Glisse if (tmds_info) { 2176771fe6b9SJerome Glisse DRM_DEBUG("Found DFP table, assuming DVI connector\n"); 2177771fe6b9SJerome Glisse 2178771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2179771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 2180771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2181771fe6b9SJerome Glisse 1), 2182771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2183771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2184771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 2185771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2186771fe6b9SJerome Glisse 0), 2187771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2188771fe6b9SJerome Glisse 21896a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 2190eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2191771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2192771fe6b9SJerome Glisse 0, 2193771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT | 2194771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2195771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 2196b75fad06SAlex Deucher &ddc_i2c, 2197eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2198eed45b30SAlex Deucher &hpd); 2199771fe6b9SJerome Glisse } else { 2200d0c403e9SAlex Deucher uint16_t crt_info = 2201d0c403e9SAlex Deucher combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 2202d0c403e9SAlex Deucher DRM_DEBUG("Found CRT table, assuming VGA connector\n"); 2203d0c403e9SAlex Deucher if (crt_info) { 2204d0c403e9SAlex Deucher radeon_add_legacy_encoder(dev, 2205d0c403e9SAlex Deucher radeon_get_encoder_id(dev, 2206d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2207d0c403e9SAlex Deucher 1), 2208d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 22096a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 2210eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2211d0c403e9SAlex Deucher radeon_add_legacy_connector(dev, 2212d0c403e9SAlex Deucher 0, 2213d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2214d0c403e9SAlex Deucher DRM_MODE_CONNECTOR_VGA, 2215b75fad06SAlex Deucher &ddc_i2c, 2216eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2217eed45b30SAlex Deucher &hpd); 2218d0c403e9SAlex Deucher } else { 2219771fe6b9SJerome Glisse DRM_DEBUG("No connector info found\n"); 2220771fe6b9SJerome Glisse return false; 2221771fe6b9SJerome Glisse } 2222771fe6b9SJerome Glisse } 2223d0c403e9SAlex Deucher } 2224771fe6b9SJerome Glisse 2225771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) { 2226771fe6b9SJerome Glisse uint16_t lcd_info = 2227771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 2228771fe6b9SJerome Glisse if (lcd_info) { 2229771fe6b9SJerome Glisse uint16_t lcd_ddc_info = 2230771fe6b9SJerome Glisse combios_get_table_offset(dev, 2231771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE); 2232771fe6b9SJerome Glisse 2233771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2234771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 2235771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2236771fe6b9SJerome Glisse 0), 2237771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 2238771fe6b9SJerome Glisse 2239771fe6b9SJerome Glisse if (lcd_ddc_info) { 2240771fe6b9SJerome Glisse ddc_type = RBIOS8(lcd_ddc_info + 2); 2241771fe6b9SJerome Glisse switch (ddc_type) { 2242771fe6b9SJerome Glisse case DDC_MONID: 2243771fe6b9SJerome Glisse ddc_i2c = 2244771fe6b9SJerome Glisse combios_setup_i2c_bus 22456a93cb25SAlex Deucher (rdev, RADEON_GPIO_MONID); 2246771fe6b9SJerome Glisse break; 2247771fe6b9SJerome Glisse case DDC_DVI: 2248771fe6b9SJerome Glisse ddc_i2c = 2249771fe6b9SJerome Glisse combios_setup_i2c_bus 22506a93cb25SAlex Deucher (rdev, RADEON_GPIO_DVI_DDC); 2251771fe6b9SJerome Glisse break; 2252771fe6b9SJerome Glisse case DDC_VGA: 2253771fe6b9SJerome Glisse ddc_i2c = 2254771fe6b9SJerome Glisse combios_setup_i2c_bus 22556a93cb25SAlex Deucher (rdev, RADEON_GPIO_VGA_DDC); 2256771fe6b9SJerome Glisse break; 2257771fe6b9SJerome Glisse case DDC_CRT2: 2258771fe6b9SJerome Glisse ddc_i2c = 2259771fe6b9SJerome Glisse combios_setup_i2c_bus 22606a93cb25SAlex Deucher (rdev, RADEON_GPIO_CRT2_DDC); 2261771fe6b9SJerome Glisse break; 2262771fe6b9SJerome Glisse case DDC_LCD: 2263771fe6b9SJerome Glisse ddc_i2c = 2264771fe6b9SJerome Glisse combios_setup_i2c_bus 22656a93cb25SAlex Deucher (rdev, RADEON_GPIOPAD_MASK); 2266771fe6b9SJerome Glisse ddc_i2c.mask_clk_mask = 2267771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2268771fe6b9SJerome Glisse ddc_i2c.mask_data_mask = 2269771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2270771fe6b9SJerome Glisse ddc_i2c.a_clk_mask = 2271771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2272771fe6b9SJerome Glisse ddc_i2c.a_data_mask = 2273771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 22749b9fe724SAlex Deucher ddc_i2c.en_clk_mask = 2275771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 22769b9fe724SAlex Deucher ddc_i2c.en_data_mask = 2277771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 22789b9fe724SAlex Deucher ddc_i2c.y_clk_mask = 2279771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 22809b9fe724SAlex Deucher ddc_i2c.y_data_mask = 2281771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2282771fe6b9SJerome Glisse break; 2283771fe6b9SJerome Glisse case DDC_GPIO: 2284771fe6b9SJerome Glisse ddc_i2c = 2285771fe6b9SJerome Glisse combios_setup_i2c_bus 22866a93cb25SAlex Deucher (rdev, RADEON_MDGPIO_MASK); 2287771fe6b9SJerome Glisse ddc_i2c.mask_clk_mask = 2288771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2289771fe6b9SJerome Glisse ddc_i2c.mask_data_mask = 2290771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2291771fe6b9SJerome Glisse ddc_i2c.a_clk_mask = 2292771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2293771fe6b9SJerome Glisse ddc_i2c.a_data_mask = 2294771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 22959b9fe724SAlex Deucher ddc_i2c.en_clk_mask = 2296771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 22979b9fe724SAlex Deucher ddc_i2c.en_data_mask = 2298771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 22999b9fe724SAlex Deucher ddc_i2c.y_clk_mask = 2300771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 23019b9fe724SAlex Deucher ddc_i2c.y_data_mask = 2302771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2303771fe6b9SJerome Glisse break; 2304771fe6b9SJerome Glisse default: 2305771fe6b9SJerome Glisse ddc_i2c.valid = false; 2306771fe6b9SJerome Glisse break; 2307771fe6b9SJerome Glisse } 2308771fe6b9SJerome Glisse DRM_DEBUG("LCD DDC Info Table found!\n"); 2309771fe6b9SJerome Glisse } else 2310771fe6b9SJerome Glisse ddc_i2c.valid = false; 2311771fe6b9SJerome Glisse 2312eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2313771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2314771fe6b9SJerome Glisse 5, 2315771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2316771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 2317b75fad06SAlex Deucher &ddc_i2c, 2318eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 2319eed45b30SAlex Deucher &hpd); 2320771fe6b9SJerome Glisse } 2321771fe6b9SJerome Glisse } 2322771fe6b9SJerome Glisse 2323771fe6b9SJerome Glisse /* check TV table */ 2324771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 2325771fe6b9SJerome Glisse uint32_t tv_info = 2326771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 2327771fe6b9SJerome Glisse if (tv_info) { 2328771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 2329790cfb34SAlex Deucher if (radeon_apply_legacy_tv_quirks(dev)) { 2330eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2331771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2332771fe6b9SJerome Glisse radeon_get_encoder_id 2333771fe6b9SJerome Glisse (dev, 2334771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2335771fe6b9SJerome Glisse 2), 2336771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2337771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 6, 2338771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2339771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 2340b75fad06SAlex Deucher &ddc_i2c, 2341eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2342eed45b30SAlex Deucher &hpd); 2343771fe6b9SJerome Glisse } 2344771fe6b9SJerome Glisse } 2345771fe6b9SJerome Glisse } 2346790cfb34SAlex Deucher } 2347771fe6b9SJerome Glisse 2348771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2349771fe6b9SJerome Glisse 2350771fe6b9SJerome Glisse return true; 2351771fe6b9SJerome Glisse } 2352771fe6b9SJerome Glisse 235356278a8eSAlex Deucher void radeon_combios_get_power_modes(struct radeon_device *rdev) 235456278a8eSAlex Deucher { 235556278a8eSAlex Deucher struct drm_device *dev = rdev->ddev; 235656278a8eSAlex Deucher u16 offset, misc, misc2 = 0; 235756278a8eSAlex Deucher u8 rev, blocks, tmp; 235856278a8eSAlex Deucher int state_index = 0; 235956278a8eSAlex Deucher 236056278a8eSAlex Deucher rdev->pm.default_power_state = NULL; 236156278a8eSAlex Deucher 236256278a8eSAlex Deucher if (rdev->flags & RADEON_IS_MOBILITY) { 236356278a8eSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE); 236456278a8eSAlex Deucher if (offset) { 236556278a8eSAlex Deucher rev = RBIOS8(offset); 236656278a8eSAlex Deucher blocks = RBIOS8(offset + 0x2); 236756278a8eSAlex Deucher /* power mode 0 tends to be the only valid one */ 236856278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 236956278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = RBIOS32(offset + 0x5 + 0x2); 237056278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = RBIOS32(offset + 0x5 + 0x6); 237156278a8eSAlex Deucher if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) || 237256278a8eSAlex Deucher (rdev->pm.power_state[state_index].clock_info[0].sclk == 0)) 237356278a8eSAlex Deucher goto default_mode; 237456278a8eSAlex Deucher /* skip overclock modes for now */ 237556278a8eSAlex Deucher if ((rdev->pm.power_state[state_index].clock_info[0].mclk > 237627459324SRafał Miłecki rdev->clock.default_mclk + RADEON_MODE_OVERCLOCK_MARGIN) || 237756278a8eSAlex Deucher (rdev->pm.power_state[state_index].clock_info[0].sclk > 237827459324SRafał Miłecki rdev->clock.default_sclk + RADEON_MODE_OVERCLOCK_MARGIN)) 237956278a8eSAlex Deucher goto default_mode; 23800ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 23810ec0e74fSAlex Deucher POWER_STATE_TYPE_BATTERY; 238256278a8eSAlex Deucher misc = RBIOS16(offset + 0x5 + 0x0); 238356278a8eSAlex Deucher if (rev > 4) 238456278a8eSAlex Deucher misc2 = RBIOS16(offset + 0x5 + 0xe); 238556278a8eSAlex Deucher if (misc & 0x4) { 238656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_GPIO; 238756278a8eSAlex Deucher if (misc & 0x8) 238856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 238956278a8eSAlex Deucher true; 239056278a8eSAlex Deucher else 239156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 239256278a8eSAlex Deucher false; 239356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = true; 239456278a8eSAlex Deucher if (rev < 6) { 239556278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 239656278a8eSAlex Deucher RBIOS16(offset + 0x5 + 0xb) * 4; 239756278a8eSAlex Deucher tmp = RBIOS8(offset + 0x5 + 0xd); 239856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 239956278a8eSAlex Deucher } else { 240056278a8eSAlex Deucher u8 entries = RBIOS8(offset + 0x5 + 0xb); 240156278a8eSAlex Deucher u16 voltage_table_offset = RBIOS16(offset + 0x5 + 0xc); 240256278a8eSAlex Deucher if (entries && voltage_table_offset) { 240356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 240456278a8eSAlex Deucher RBIOS16(voltage_table_offset) * 4; 240556278a8eSAlex Deucher tmp = RBIOS8(voltage_table_offset + 0x2); 240656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 240756278a8eSAlex Deucher } else 240856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = false; 240956278a8eSAlex Deucher } 241056278a8eSAlex Deucher switch ((misc2 & 0x700) >> 8) { 241156278a8eSAlex Deucher case 0: 241256278a8eSAlex Deucher default: 241356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 0; 241456278a8eSAlex Deucher break; 241556278a8eSAlex Deucher case 1: 241656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 33; 241756278a8eSAlex Deucher break; 241856278a8eSAlex Deucher case 2: 241956278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 66; 242056278a8eSAlex Deucher break; 242156278a8eSAlex Deucher case 3: 242256278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 99; 242356278a8eSAlex Deucher break; 242456278a8eSAlex Deucher case 4: 242556278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 132; 242656278a8eSAlex Deucher break; 242756278a8eSAlex Deucher } 242856278a8eSAlex Deucher } else 242956278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 243056278a8eSAlex Deucher if (rev > 6) 243156278a8eSAlex Deucher rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = 243256278a8eSAlex Deucher RBIOS8(offset + 0x5 + 0x10); 243356278a8eSAlex Deucher state_index++; 243456278a8eSAlex Deucher } else { 243556278a8eSAlex Deucher /* XXX figure out some good default low power mode for mobility cards w/out power tables */ 243656278a8eSAlex Deucher } 243756278a8eSAlex Deucher } else { 243856278a8eSAlex Deucher /* XXX figure out some good default low power mode for desktop cards */ 243956278a8eSAlex Deucher } 244056278a8eSAlex Deucher 244156278a8eSAlex Deucher default_mode: 244256278a8eSAlex Deucher /* add the default mode */ 24430ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 24440ec0e74fSAlex Deucher POWER_STATE_TYPE_DEFAULT; 244556278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 244656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk; 244756278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk; 244856278a8eSAlex Deucher rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0]; 244956278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 245056278a8eSAlex Deucher if (rdev->asic->get_pcie_lanes) 245156278a8eSAlex Deucher rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = radeon_get_pcie_lanes(rdev); 245256278a8eSAlex Deucher else 245356278a8eSAlex Deucher rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = 16; 245456278a8eSAlex Deucher rdev->pm.default_power_state = &rdev->pm.power_state[state_index]; 245556278a8eSAlex Deucher rdev->pm.num_power_states = state_index + 1; 2456*9038dfdfSRafał Miłecki 2457*9038dfdfSRafał Miłecki rdev->pm.current_power_state = rdev->pm.default_power_state; 2458*9038dfdfSRafał Miłecki rdev->pm.current_clock_mode = 2459*9038dfdfSRafał Miłecki rdev->pm.default_power_state->default_clock_mode; 246056278a8eSAlex Deucher } 246156278a8eSAlex Deucher 2462fcec570bSAlex Deucher void radeon_external_tmds_setup(struct drm_encoder *encoder) 2463fcec570bSAlex Deucher { 2464fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2465fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2466fcec570bSAlex Deucher 2467fcec570bSAlex Deucher if (!tmds) 2468fcec570bSAlex Deucher return; 2469fcec570bSAlex Deucher 2470fcec570bSAlex Deucher switch (tmds->dvo_chip) { 2471fcec570bSAlex Deucher case DVO_SIL164: 2472fcec570bSAlex Deucher /* sil 164 */ 24735a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2474fcec570bSAlex Deucher tmds->slave_addr, 2475fcec570bSAlex Deucher 0x08, 0x30); 24765a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2477fcec570bSAlex Deucher tmds->slave_addr, 2478fcec570bSAlex Deucher 0x09, 0x00); 24795a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2480fcec570bSAlex Deucher tmds->slave_addr, 2481fcec570bSAlex Deucher 0x0a, 0x90); 24825a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2483fcec570bSAlex Deucher tmds->slave_addr, 2484fcec570bSAlex Deucher 0x0c, 0x89); 24855a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2486fcec570bSAlex Deucher tmds->slave_addr, 2487fcec570bSAlex Deucher 0x08, 0x3b); 2488fcec570bSAlex Deucher break; 2489fcec570bSAlex Deucher case DVO_SIL1178: 2490fcec570bSAlex Deucher /* sil 1178 - untested */ 2491fcec570bSAlex Deucher /* 2492fcec570bSAlex Deucher * 0x0f, 0x44 2493fcec570bSAlex Deucher * 0x0f, 0x4c 2494fcec570bSAlex Deucher * 0x0e, 0x01 2495fcec570bSAlex Deucher * 0x0a, 0x80 2496fcec570bSAlex Deucher * 0x09, 0x30 2497fcec570bSAlex Deucher * 0x0c, 0xc9 2498fcec570bSAlex Deucher * 0x0d, 0x70 2499fcec570bSAlex Deucher * 0x08, 0x32 2500fcec570bSAlex Deucher * 0x08, 0x33 2501fcec570bSAlex Deucher */ 2502fcec570bSAlex Deucher break; 2503fcec570bSAlex Deucher default: 2504fcec570bSAlex Deucher break; 2505fcec570bSAlex Deucher } 2506fcec570bSAlex Deucher 2507fcec570bSAlex Deucher } 2508fcec570bSAlex Deucher 2509fcec570bSAlex Deucher bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder) 2510fcec570bSAlex Deucher { 2511fcec570bSAlex Deucher struct drm_device *dev = encoder->dev; 2512fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 2513fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2514fcec570bSAlex Deucher uint16_t offset; 2515fcec570bSAlex Deucher uint8_t blocks, slave_addr, rev; 2516fcec570bSAlex Deucher uint32_t index, id; 2517fcec570bSAlex Deucher uint32_t reg, val, and_mask, or_mask; 2518fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2519fcec570bSAlex Deucher 2520fcec570bSAlex Deucher if (!tmds) 2521fcec570bSAlex Deucher return false; 2522fcec570bSAlex Deucher 2523fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2524fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE); 2525fcec570bSAlex Deucher rev = RBIOS8(offset); 2526fcec570bSAlex Deucher if (offset) { 2527fcec570bSAlex Deucher rev = RBIOS8(offset); 2528fcec570bSAlex Deucher if (rev > 1) { 2529fcec570bSAlex Deucher blocks = RBIOS8(offset + 3); 2530fcec570bSAlex Deucher index = offset + 4; 2531fcec570bSAlex Deucher while (blocks > 0) { 2532fcec570bSAlex Deucher id = RBIOS16(index); 2533fcec570bSAlex Deucher index += 2; 2534fcec570bSAlex Deucher switch (id >> 13) { 2535fcec570bSAlex Deucher case 0: 2536fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2537fcec570bSAlex Deucher val = RBIOS32(index); 2538fcec570bSAlex Deucher index += 4; 2539fcec570bSAlex Deucher WREG32(reg, val); 2540fcec570bSAlex Deucher break; 2541fcec570bSAlex Deucher case 2: 2542fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2543fcec570bSAlex Deucher and_mask = RBIOS32(index); 2544fcec570bSAlex Deucher index += 4; 2545fcec570bSAlex Deucher or_mask = RBIOS32(index); 2546fcec570bSAlex Deucher index += 4; 2547fcec570bSAlex Deucher val = RREG32(reg); 2548fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2549fcec570bSAlex Deucher WREG32(reg, val); 2550fcec570bSAlex Deucher break; 2551fcec570bSAlex Deucher case 3: 2552fcec570bSAlex Deucher val = RBIOS16(index); 2553fcec570bSAlex Deucher index += 2; 2554fcec570bSAlex Deucher udelay(val); 2555fcec570bSAlex Deucher break; 2556fcec570bSAlex Deucher case 4: 2557fcec570bSAlex Deucher val = RBIOS16(index); 2558fcec570bSAlex Deucher index += 2; 2559fcec570bSAlex Deucher udelay(val * 1000); 2560fcec570bSAlex Deucher break; 2561fcec570bSAlex Deucher case 6: 2562fcec570bSAlex Deucher slave_addr = id & 0xff; 2563fcec570bSAlex Deucher slave_addr >>= 1; /* 7 bit addressing */ 2564fcec570bSAlex Deucher index++; 2565fcec570bSAlex Deucher reg = RBIOS8(index); 2566fcec570bSAlex Deucher index++; 2567fcec570bSAlex Deucher val = RBIOS8(index); 2568fcec570bSAlex Deucher index++; 25695a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2570fcec570bSAlex Deucher slave_addr, 2571fcec570bSAlex Deucher reg, val); 2572fcec570bSAlex Deucher break; 2573fcec570bSAlex Deucher default: 2574fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2575fcec570bSAlex Deucher break; 2576fcec570bSAlex Deucher } 2577fcec570bSAlex Deucher blocks--; 2578fcec570bSAlex Deucher } 2579fcec570bSAlex Deucher return true; 2580fcec570bSAlex Deucher } 2581fcec570bSAlex Deucher } 2582fcec570bSAlex Deucher } else { 2583fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2584fcec570bSAlex Deucher if (offset) { 2585fcec570bSAlex Deucher index = offset + 10; 2586fcec570bSAlex Deucher id = RBIOS16(index); 2587fcec570bSAlex Deucher while (id != 0xffff) { 2588fcec570bSAlex Deucher index += 2; 2589fcec570bSAlex Deucher switch (id >> 13) { 2590fcec570bSAlex Deucher case 0: 2591fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2592fcec570bSAlex Deucher val = RBIOS32(index); 2593fcec570bSAlex Deucher WREG32(reg, val); 2594fcec570bSAlex Deucher break; 2595fcec570bSAlex Deucher case 2: 2596fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2597fcec570bSAlex Deucher and_mask = RBIOS32(index); 2598fcec570bSAlex Deucher index += 4; 2599fcec570bSAlex Deucher or_mask = RBIOS32(index); 2600fcec570bSAlex Deucher index += 4; 2601fcec570bSAlex Deucher val = RREG32(reg); 2602fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2603fcec570bSAlex Deucher WREG32(reg, val); 2604fcec570bSAlex Deucher break; 2605fcec570bSAlex Deucher case 4: 2606fcec570bSAlex Deucher val = RBIOS16(index); 2607fcec570bSAlex Deucher index += 2; 2608fcec570bSAlex Deucher udelay(val); 2609fcec570bSAlex Deucher break; 2610fcec570bSAlex Deucher case 5: 2611fcec570bSAlex Deucher reg = id & 0x1fff; 2612fcec570bSAlex Deucher and_mask = RBIOS32(index); 2613fcec570bSAlex Deucher index += 4; 2614fcec570bSAlex Deucher or_mask = RBIOS32(index); 2615fcec570bSAlex Deucher index += 4; 2616fcec570bSAlex Deucher val = RREG32_PLL(reg); 2617fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2618fcec570bSAlex Deucher WREG32_PLL(reg, val); 2619fcec570bSAlex Deucher break; 2620fcec570bSAlex Deucher case 6: 2621fcec570bSAlex Deucher reg = id & 0x1fff; 2622fcec570bSAlex Deucher val = RBIOS8(index); 2623fcec570bSAlex Deucher index += 1; 26245a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2625fcec570bSAlex Deucher tmds->slave_addr, 2626fcec570bSAlex Deucher reg, val); 2627fcec570bSAlex Deucher break; 2628fcec570bSAlex Deucher default: 2629fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2630fcec570bSAlex Deucher break; 2631fcec570bSAlex Deucher } 2632fcec570bSAlex Deucher id = RBIOS16(index); 2633fcec570bSAlex Deucher } 2634fcec570bSAlex Deucher return true; 2635fcec570bSAlex Deucher } 2636fcec570bSAlex Deucher } 2637fcec570bSAlex Deucher return false; 2638fcec570bSAlex Deucher } 2639fcec570bSAlex Deucher 2640771fe6b9SJerome Glisse static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset) 2641771fe6b9SJerome Glisse { 2642771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2643771fe6b9SJerome Glisse 2644771fe6b9SJerome Glisse if (offset) { 2645771fe6b9SJerome Glisse while (RBIOS16(offset)) { 2646771fe6b9SJerome Glisse uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13); 2647771fe6b9SJerome Glisse uint32_t addr = (RBIOS16(offset) & 0x1fff); 2648771fe6b9SJerome Glisse uint32_t val, and_mask, or_mask; 2649771fe6b9SJerome Glisse uint32_t tmp; 2650771fe6b9SJerome Glisse 2651771fe6b9SJerome Glisse offset += 2; 2652771fe6b9SJerome Glisse switch (cmd) { 2653771fe6b9SJerome Glisse case 0: 2654771fe6b9SJerome Glisse val = RBIOS32(offset); 2655771fe6b9SJerome Glisse offset += 4; 2656771fe6b9SJerome Glisse WREG32(addr, val); 2657771fe6b9SJerome Glisse break; 2658771fe6b9SJerome Glisse case 1: 2659771fe6b9SJerome Glisse val = RBIOS32(offset); 2660771fe6b9SJerome Glisse offset += 4; 2661771fe6b9SJerome Glisse WREG32(addr, val); 2662771fe6b9SJerome Glisse break; 2663771fe6b9SJerome Glisse case 2: 2664771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2665771fe6b9SJerome Glisse offset += 4; 2666771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2667771fe6b9SJerome Glisse offset += 4; 2668771fe6b9SJerome Glisse tmp = RREG32(addr); 2669771fe6b9SJerome Glisse tmp &= and_mask; 2670771fe6b9SJerome Glisse tmp |= or_mask; 2671771fe6b9SJerome Glisse WREG32(addr, tmp); 2672771fe6b9SJerome Glisse break; 2673771fe6b9SJerome Glisse case 3: 2674771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2675771fe6b9SJerome Glisse offset += 4; 2676771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2677771fe6b9SJerome Glisse offset += 4; 2678771fe6b9SJerome Glisse tmp = RREG32(addr); 2679771fe6b9SJerome Glisse tmp &= and_mask; 2680771fe6b9SJerome Glisse tmp |= or_mask; 2681771fe6b9SJerome Glisse WREG32(addr, tmp); 2682771fe6b9SJerome Glisse break; 2683771fe6b9SJerome Glisse case 4: 2684771fe6b9SJerome Glisse val = RBIOS16(offset); 2685771fe6b9SJerome Glisse offset += 2; 2686771fe6b9SJerome Glisse udelay(val); 2687771fe6b9SJerome Glisse break; 2688771fe6b9SJerome Glisse case 5: 2689771fe6b9SJerome Glisse val = RBIOS16(offset); 2690771fe6b9SJerome Glisse offset += 2; 2691771fe6b9SJerome Glisse switch (addr) { 2692771fe6b9SJerome Glisse case 8: 2693771fe6b9SJerome Glisse while (val--) { 2694771fe6b9SJerome Glisse if (! 2695771fe6b9SJerome Glisse (RREG32_PLL 2696771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2697771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2698771fe6b9SJerome Glisse break; 2699771fe6b9SJerome Glisse } 2700771fe6b9SJerome Glisse break; 2701771fe6b9SJerome Glisse case 9: 2702771fe6b9SJerome Glisse while (val--) { 2703771fe6b9SJerome Glisse if ((RREG32(RADEON_MC_STATUS) & 2704771fe6b9SJerome Glisse RADEON_MC_IDLE)) 2705771fe6b9SJerome Glisse break; 2706771fe6b9SJerome Glisse } 2707771fe6b9SJerome Glisse break; 2708771fe6b9SJerome Glisse default: 2709771fe6b9SJerome Glisse break; 2710771fe6b9SJerome Glisse } 2711771fe6b9SJerome Glisse break; 2712771fe6b9SJerome Glisse default: 2713771fe6b9SJerome Glisse break; 2714771fe6b9SJerome Glisse } 2715771fe6b9SJerome Glisse } 2716771fe6b9SJerome Glisse } 2717771fe6b9SJerome Glisse } 2718771fe6b9SJerome Glisse 2719771fe6b9SJerome Glisse static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset) 2720771fe6b9SJerome Glisse { 2721771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2722771fe6b9SJerome Glisse 2723771fe6b9SJerome Glisse if (offset) { 2724771fe6b9SJerome Glisse while (RBIOS8(offset)) { 2725771fe6b9SJerome Glisse uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6); 2726771fe6b9SJerome Glisse uint8_t addr = (RBIOS8(offset) & 0x3f); 2727771fe6b9SJerome Glisse uint32_t val, shift, tmp; 2728771fe6b9SJerome Glisse uint32_t and_mask, or_mask; 2729771fe6b9SJerome Glisse 2730771fe6b9SJerome Glisse offset++; 2731771fe6b9SJerome Glisse switch (cmd) { 2732771fe6b9SJerome Glisse case 0: 2733771fe6b9SJerome Glisse val = RBIOS32(offset); 2734771fe6b9SJerome Glisse offset += 4; 2735771fe6b9SJerome Glisse WREG32_PLL(addr, val); 2736771fe6b9SJerome Glisse break; 2737771fe6b9SJerome Glisse case 1: 2738771fe6b9SJerome Glisse shift = RBIOS8(offset) * 8; 2739771fe6b9SJerome Glisse offset++; 2740771fe6b9SJerome Glisse and_mask = RBIOS8(offset) << shift; 2741771fe6b9SJerome Glisse and_mask |= ~(0xff << shift); 2742771fe6b9SJerome Glisse offset++; 2743771fe6b9SJerome Glisse or_mask = RBIOS8(offset) << shift; 2744771fe6b9SJerome Glisse offset++; 2745771fe6b9SJerome Glisse tmp = RREG32_PLL(addr); 2746771fe6b9SJerome Glisse tmp &= and_mask; 2747771fe6b9SJerome Glisse tmp |= or_mask; 2748771fe6b9SJerome Glisse WREG32_PLL(addr, tmp); 2749771fe6b9SJerome Glisse break; 2750771fe6b9SJerome Glisse case 2: 2751771fe6b9SJerome Glisse case 3: 2752771fe6b9SJerome Glisse tmp = 1000; 2753771fe6b9SJerome Glisse switch (addr) { 2754771fe6b9SJerome Glisse case 1: 2755771fe6b9SJerome Glisse udelay(150); 2756771fe6b9SJerome Glisse break; 2757771fe6b9SJerome Glisse case 2: 2758771fe6b9SJerome Glisse udelay(1000); 2759771fe6b9SJerome Glisse break; 2760771fe6b9SJerome Glisse case 3: 2761771fe6b9SJerome Glisse while (tmp--) { 2762771fe6b9SJerome Glisse if (! 2763771fe6b9SJerome Glisse (RREG32_PLL 2764771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2765771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2766771fe6b9SJerome Glisse break; 2767771fe6b9SJerome Glisse } 2768771fe6b9SJerome Glisse break; 2769771fe6b9SJerome Glisse case 4: 2770771fe6b9SJerome Glisse while (tmp--) { 2771771fe6b9SJerome Glisse if (RREG32_PLL 2772771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2773771fe6b9SJerome Glisse RADEON_DLL_READY) 2774771fe6b9SJerome Glisse break; 2775771fe6b9SJerome Glisse } 2776771fe6b9SJerome Glisse break; 2777771fe6b9SJerome Glisse case 5: 2778771fe6b9SJerome Glisse tmp = 2779771fe6b9SJerome Glisse RREG32_PLL(RADEON_CLK_PWRMGT_CNTL); 2780771fe6b9SJerome Glisse if (tmp & RADEON_CG_NO1_DEBUG_0) { 2781771fe6b9SJerome Glisse #if 0 2782771fe6b9SJerome Glisse uint32_t mclk_cntl = 2783771fe6b9SJerome Glisse RREG32_PLL 2784771fe6b9SJerome Glisse (RADEON_MCLK_CNTL); 2785771fe6b9SJerome Glisse mclk_cntl &= 0xffff0000; 2786771fe6b9SJerome Glisse /*mclk_cntl |= 0x00001111;*//* ??? */ 2787771fe6b9SJerome Glisse WREG32_PLL(RADEON_MCLK_CNTL, 2788771fe6b9SJerome Glisse mclk_cntl); 2789771fe6b9SJerome Glisse udelay(10000); 2790771fe6b9SJerome Glisse #endif 2791771fe6b9SJerome Glisse WREG32_PLL 2792771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL, 2793771fe6b9SJerome Glisse tmp & 2794771fe6b9SJerome Glisse ~RADEON_CG_NO1_DEBUG_0); 2795771fe6b9SJerome Glisse udelay(10000); 2796771fe6b9SJerome Glisse } 2797771fe6b9SJerome Glisse break; 2798771fe6b9SJerome Glisse default: 2799771fe6b9SJerome Glisse break; 2800771fe6b9SJerome Glisse } 2801771fe6b9SJerome Glisse break; 2802771fe6b9SJerome Glisse default: 2803771fe6b9SJerome Glisse break; 2804771fe6b9SJerome Glisse } 2805771fe6b9SJerome Glisse } 2806771fe6b9SJerome Glisse } 2807771fe6b9SJerome Glisse } 2808771fe6b9SJerome Glisse 2809771fe6b9SJerome Glisse static void combios_parse_ram_reset_table(struct drm_device *dev, 2810771fe6b9SJerome Glisse uint16_t offset) 2811771fe6b9SJerome Glisse { 2812771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2813771fe6b9SJerome Glisse uint32_t tmp; 2814771fe6b9SJerome Glisse 2815771fe6b9SJerome Glisse if (offset) { 2816771fe6b9SJerome Glisse uint8_t val = RBIOS8(offset); 2817771fe6b9SJerome Glisse while (val != 0xff) { 2818771fe6b9SJerome Glisse offset++; 2819771fe6b9SJerome Glisse 2820771fe6b9SJerome Glisse if (val == 0x0f) { 2821771fe6b9SJerome Glisse uint32_t channel_complete_mask; 2822771fe6b9SJerome Glisse 2823771fe6b9SJerome Glisse if (ASIC_IS_R300(rdev)) 2824771fe6b9SJerome Glisse channel_complete_mask = 2825771fe6b9SJerome Glisse R300_MEM_PWRUP_COMPLETE; 2826771fe6b9SJerome Glisse else 2827771fe6b9SJerome Glisse channel_complete_mask = 2828771fe6b9SJerome Glisse RADEON_MEM_PWRUP_COMPLETE; 2829771fe6b9SJerome Glisse tmp = 20000; 2830771fe6b9SJerome Glisse while (tmp--) { 2831771fe6b9SJerome Glisse if ((RREG32(RADEON_MEM_STR_CNTL) & 2832771fe6b9SJerome Glisse channel_complete_mask) == 2833771fe6b9SJerome Glisse channel_complete_mask) 2834771fe6b9SJerome Glisse break; 2835771fe6b9SJerome Glisse } 2836771fe6b9SJerome Glisse } else { 2837771fe6b9SJerome Glisse uint32_t or_mask = RBIOS16(offset); 2838771fe6b9SJerome Glisse offset += 2; 2839771fe6b9SJerome Glisse 2840771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 2841771fe6b9SJerome Glisse tmp &= RADEON_SDRAM_MODE_MASK; 2842771fe6b9SJerome Glisse tmp |= or_mask; 2843771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 2844771fe6b9SJerome Glisse 2845771fe6b9SJerome Glisse or_mask = val << 24; 2846771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 2847771fe6b9SJerome Glisse tmp &= RADEON_B3MEM_RESET_MASK; 2848771fe6b9SJerome Glisse tmp |= or_mask; 2849771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 2850771fe6b9SJerome Glisse } 2851771fe6b9SJerome Glisse val = RBIOS8(offset); 2852771fe6b9SJerome Glisse } 2853771fe6b9SJerome Glisse } 2854771fe6b9SJerome Glisse } 2855771fe6b9SJerome Glisse 2856771fe6b9SJerome Glisse static uint32_t combios_detect_ram(struct drm_device *dev, int ram, 2857771fe6b9SJerome Glisse int mem_addr_mapping) 2858771fe6b9SJerome Glisse { 2859771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2860771fe6b9SJerome Glisse uint32_t mem_cntl; 2861771fe6b9SJerome Glisse uint32_t mem_size; 2862771fe6b9SJerome Glisse uint32_t addr = 0; 2863771fe6b9SJerome Glisse 2864771fe6b9SJerome Glisse mem_cntl = RREG32(RADEON_MEM_CNTL); 2865771fe6b9SJerome Glisse if (mem_cntl & RV100_HALF_MODE) 2866771fe6b9SJerome Glisse ram /= 2; 2867771fe6b9SJerome Glisse mem_size = ram; 2868771fe6b9SJerome Glisse mem_cntl &= ~(0xff << 8); 2869771fe6b9SJerome Glisse mem_cntl |= (mem_addr_mapping & 0xff) << 8; 2870771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 2871771fe6b9SJerome Glisse RREG32(RADEON_MEM_CNTL); 2872771fe6b9SJerome Glisse 2873771fe6b9SJerome Glisse /* sdram reset ? */ 2874771fe6b9SJerome Glisse 2875771fe6b9SJerome Glisse /* something like this???? */ 2876771fe6b9SJerome Glisse while (ram--) { 2877771fe6b9SJerome Glisse addr = ram * 1024 * 1024; 2878771fe6b9SJerome Glisse /* write to each page */ 2879771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 2880771fe6b9SJerome Glisse WREG32(RADEON_MM_DATA, 0xdeadbeef); 2881771fe6b9SJerome Glisse /* read back and verify */ 2882771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 2883771fe6b9SJerome Glisse if (RREG32(RADEON_MM_DATA) != 0xdeadbeef) 2884771fe6b9SJerome Glisse return 0; 2885771fe6b9SJerome Glisse } 2886771fe6b9SJerome Glisse 2887771fe6b9SJerome Glisse return mem_size; 2888771fe6b9SJerome Glisse } 2889771fe6b9SJerome Glisse 2890771fe6b9SJerome Glisse static void combios_write_ram_size(struct drm_device *dev) 2891771fe6b9SJerome Glisse { 2892771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2893771fe6b9SJerome Glisse uint8_t rev; 2894771fe6b9SJerome Glisse uint16_t offset; 2895771fe6b9SJerome Glisse uint32_t mem_size = 0; 2896771fe6b9SJerome Glisse uint32_t mem_cntl = 0; 2897771fe6b9SJerome Glisse 2898771fe6b9SJerome Glisse /* should do something smarter here I guess... */ 2899771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_IGP) 2900771fe6b9SJerome Glisse return; 2901771fe6b9SJerome Glisse 2902771fe6b9SJerome Glisse /* first check detected mem table */ 2903771fe6b9SJerome Glisse offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE); 2904771fe6b9SJerome Glisse if (offset) { 2905771fe6b9SJerome Glisse rev = RBIOS8(offset); 2906771fe6b9SJerome Glisse if (rev < 3) { 2907771fe6b9SJerome Glisse mem_cntl = RBIOS32(offset + 1); 2908771fe6b9SJerome Glisse mem_size = RBIOS16(offset + 5); 2909771fe6b9SJerome Glisse if (((rdev->flags & RADEON_FAMILY_MASK) < CHIP_R200) && 2910771fe6b9SJerome Glisse ((dev->pdev->device != 0x515e) 2911771fe6b9SJerome Glisse && (dev->pdev->device != 0x5969))) 2912771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 2913771fe6b9SJerome Glisse } 2914771fe6b9SJerome Glisse } 2915771fe6b9SJerome Glisse 2916771fe6b9SJerome Glisse if (!mem_size) { 2917771fe6b9SJerome Glisse offset = 2918771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 2919771fe6b9SJerome Glisse if (offset) { 2920771fe6b9SJerome Glisse rev = RBIOS8(offset - 1); 2921771fe6b9SJerome Glisse if (rev < 1) { 2922771fe6b9SJerome Glisse if (((rdev->flags & RADEON_FAMILY_MASK) < 2923771fe6b9SJerome Glisse CHIP_R200) 2924771fe6b9SJerome Glisse && ((dev->pdev->device != 0x515e) 2925771fe6b9SJerome Glisse && (dev->pdev->device != 0x5969))) { 2926771fe6b9SJerome Glisse int ram = 0; 2927771fe6b9SJerome Glisse int mem_addr_mapping = 0; 2928771fe6b9SJerome Glisse 2929771fe6b9SJerome Glisse while (RBIOS8(offset)) { 2930771fe6b9SJerome Glisse ram = RBIOS8(offset); 2931771fe6b9SJerome Glisse mem_addr_mapping = 2932771fe6b9SJerome Glisse RBIOS8(offset + 1); 2933771fe6b9SJerome Glisse if (mem_addr_mapping != 0x25) 2934771fe6b9SJerome Glisse ram *= 2; 2935771fe6b9SJerome Glisse mem_size = 2936771fe6b9SJerome Glisse combios_detect_ram(dev, ram, 2937771fe6b9SJerome Glisse mem_addr_mapping); 2938771fe6b9SJerome Glisse if (mem_size) 2939771fe6b9SJerome Glisse break; 2940771fe6b9SJerome Glisse offset += 2; 2941771fe6b9SJerome Glisse } 2942771fe6b9SJerome Glisse } else 2943771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 2944771fe6b9SJerome Glisse } else { 2945771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 2946771fe6b9SJerome Glisse mem_size *= 2; /* convert to MB */ 2947771fe6b9SJerome Glisse } 2948771fe6b9SJerome Glisse } 2949771fe6b9SJerome Glisse } 2950771fe6b9SJerome Glisse 2951771fe6b9SJerome Glisse mem_size *= (1024 * 1024); /* convert to bytes */ 2952771fe6b9SJerome Glisse WREG32(RADEON_CONFIG_MEMSIZE, mem_size); 2953771fe6b9SJerome Glisse } 2954771fe6b9SJerome Glisse 2955771fe6b9SJerome Glisse void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable) 2956771fe6b9SJerome Glisse { 2957771fe6b9SJerome Glisse uint16_t dyn_clk_info = 2958771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 2959771fe6b9SJerome Glisse 2960771fe6b9SJerome Glisse if (dyn_clk_info) 2961771fe6b9SJerome Glisse combios_parse_pll_table(dev, dyn_clk_info); 2962771fe6b9SJerome Glisse } 2963771fe6b9SJerome Glisse 2964771fe6b9SJerome Glisse void radeon_combios_asic_init(struct drm_device *dev) 2965771fe6b9SJerome Glisse { 2966771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2967771fe6b9SJerome Glisse uint16_t table; 2968771fe6b9SJerome Glisse 2969771fe6b9SJerome Glisse /* port hardcoded mac stuff from radeonfb */ 2970771fe6b9SJerome Glisse if (rdev->bios == NULL) 2971771fe6b9SJerome Glisse return; 2972771fe6b9SJerome Glisse 2973771fe6b9SJerome Glisse /* ASIC INIT 1 */ 2974771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE); 2975771fe6b9SJerome Glisse if (table) 2976771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 2977771fe6b9SJerome Glisse 2978771fe6b9SJerome Glisse /* PLL INIT */ 2979771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE); 2980771fe6b9SJerome Glisse if (table) 2981771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 2982771fe6b9SJerome Glisse 2983771fe6b9SJerome Glisse /* ASIC INIT 2 */ 2984771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE); 2985771fe6b9SJerome Glisse if (table) 2986771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 2987771fe6b9SJerome Glisse 2988771fe6b9SJerome Glisse if (!(rdev->flags & RADEON_IS_IGP)) { 2989771fe6b9SJerome Glisse /* ASIC INIT 4 */ 2990771fe6b9SJerome Glisse table = 2991771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE); 2992771fe6b9SJerome Glisse if (table) 2993771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 2994771fe6b9SJerome Glisse 2995771fe6b9SJerome Glisse /* RAM RESET */ 2996771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE); 2997771fe6b9SJerome Glisse if (table) 2998771fe6b9SJerome Glisse combios_parse_ram_reset_table(dev, table); 2999771fe6b9SJerome Glisse 3000771fe6b9SJerome Glisse /* ASIC INIT 3 */ 3001771fe6b9SJerome Glisse table = 3002771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE); 3003771fe6b9SJerome Glisse if (table) 3004771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3005771fe6b9SJerome Glisse 3006771fe6b9SJerome Glisse /* write CONFIG_MEMSIZE */ 3007771fe6b9SJerome Glisse combios_write_ram_size(dev); 3008771fe6b9SJerome Glisse } 3009771fe6b9SJerome Glisse 3010771fe6b9SJerome Glisse /* DYN CLK 1 */ 3011771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 3012771fe6b9SJerome Glisse if (table) 3013771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 3014771fe6b9SJerome Glisse 3015771fe6b9SJerome Glisse } 3016771fe6b9SJerome Glisse 3017771fe6b9SJerome Glisse void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev) 3018771fe6b9SJerome Glisse { 3019771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3020771fe6b9SJerome Glisse uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch; 3021771fe6b9SJerome Glisse 3022771fe6b9SJerome Glisse bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); 3023771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3024771fe6b9SJerome Glisse bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH); 3025771fe6b9SJerome Glisse 3026771fe6b9SJerome Glisse /* let the bios control the backlight */ 3027771fe6b9SJerome Glisse bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN; 3028771fe6b9SJerome Glisse 3029771fe6b9SJerome Glisse /* tell the bios not to handle mode switching */ 3030771fe6b9SJerome Glisse bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS | 3031771fe6b9SJerome Glisse RADEON_ACC_MODE_CHANGE); 3032771fe6b9SJerome Glisse 3033771fe6b9SJerome Glisse /* tell the bios a driver is loaded */ 3034771fe6b9SJerome Glisse bios_7_scratch |= RADEON_DRV_LOADED; 3035771fe6b9SJerome Glisse 3036771fe6b9SJerome Glisse WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch); 3037771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3038771fe6b9SJerome Glisse WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch); 3039771fe6b9SJerome Glisse } 3040771fe6b9SJerome Glisse 3041771fe6b9SJerome Glisse void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock) 3042771fe6b9SJerome Glisse { 3043771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3044771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3045771fe6b9SJerome Glisse uint32_t bios_6_scratch; 3046771fe6b9SJerome Glisse 3047771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3048771fe6b9SJerome Glisse 3049771fe6b9SJerome Glisse if (lock) 3050771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DRIVER_CRITICAL; 3051771fe6b9SJerome Glisse else 3052771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DRIVER_CRITICAL; 3053771fe6b9SJerome Glisse 3054771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3055771fe6b9SJerome Glisse } 3056771fe6b9SJerome Glisse 3057771fe6b9SJerome Glisse void 3058771fe6b9SJerome Glisse radeon_combios_connected_scratch_regs(struct drm_connector *connector, 3059771fe6b9SJerome Glisse struct drm_encoder *encoder, 3060771fe6b9SJerome Glisse bool connected) 3061771fe6b9SJerome Glisse { 3062771fe6b9SJerome Glisse struct drm_device *dev = connector->dev; 3063771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3064771fe6b9SJerome Glisse struct radeon_connector *radeon_connector = 3065771fe6b9SJerome Glisse to_radeon_connector(connector); 3066771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3067771fe6b9SJerome Glisse uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH); 3068771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3069771fe6b9SJerome Glisse 3070771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) && 3071771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) { 3072771fe6b9SJerome Glisse if (connected) { 3073771fe6b9SJerome Glisse DRM_DEBUG("TV1 connected\n"); 3074771fe6b9SJerome Glisse /* fix me */ 3075771fe6b9SJerome Glisse bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO; 3076771fe6b9SJerome Glisse /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */ 3077771fe6b9SJerome Glisse bios_5_scratch |= RADEON_TV1_ON; 3078771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_TV1; 3079771fe6b9SJerome Glisse } else { 3080771fe6b9SJerome Glisse DRM_DEBUG("TV1 disconnected\n"); 3081771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK; 3082771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_ON; 3083771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_TV1; 3084771fe6b9SJerome Glisse } 3085771fe6b9SJerome Glisse } 3086771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) && 3087771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) { 3088771fe6b9SJerome Glisse if (connected) { 3089771fe6b9SJerome Glisse DRM_DEBUG("LCD1 connected\n"); 3090771fe6b9SJerome Glisse bios_4_scratch |= RADEON_LCD1_ATTACHED; 3091771fe6b9SJerome Glisse bios_5_scratch |= RADEON_LCD1_ON; 3092771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_LCD1; 3093771fe6b9SJerome Glisse } else { 3094771fe6b9SJerome Glisse DRM_DEBUG("LCD1 disconnected\n"); 3095771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_LCD1_ATTACHED; 3096771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_ON; 3097771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_LCD1; 3098771fe6b9SJerome Glisse } 3099771fe6b9SJerome Glisse } 3100771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) && 3101771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) { 3102771fe6b9SJerome Glisse if (connected) { 3103771fe6b9SJerome Glisse DRM_DEBUG("CRT1 connected\n"); 3104771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR; 3105771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT1_ON; 3106771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT1; 3107771fe6b9SJerome Glisse } else { 3108771fe6b9SJerome Glisse DRM_DEBUG("CRT1 disconnected\n"); 3109771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK; 3110771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_ON; 3111771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT1; 3112771fe6b9SJerome Glisse } 3113771fe6b9SJerome Glisse } 3114771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) && 3115771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) { 3116771fe6b9SJerome Glisse if (connected) { 3117771fe6b9SJerome Glisse DRM_DEBUG("CRT2 connected\n"); 3118771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR; 3119771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT2_ON; 3120771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT2; 3121771fe6b9SJerome Glisse } else { 3122771fe6b9SJerome Glisse DRM_DEBUG("CRT2 disconnected\n"); 3123771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK; 3124771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_ON; 3125771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT2; 3126771fe6b9SJerome Glisse } 3127771fe6b9SJerome Glisse } 3128771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) && 3129771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) { 3130771fe6b9SJerome Glisse if (connected) { 3131771fe6b9SJerome Glisse DRM_DEBUG("DFP1 connected\n"); 3132771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP1_ATTACHED; 3133771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP1_ON; 3134771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP1; 3135771fe6b9SJerome Glisse } else { 3136771fe6b9SJerome Glisse DRM_DEBUG("DFP1 disconnected\n"); 3137771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP1_ATTACHED; 3138771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_ON; 3139771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP1; 3140771fe6b9SJerome Glisse } 3141771fe6b9SJerome Glisse } 3142771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) && 3143771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) { 3144771fe6b9SJerome Glisse if (connected) { 3145771fe6b9SJerome Glisse DRM_DEBUG("DFP2 connected\n"); 3146771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP2_ATTACHED; 3147771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP2_ON; 3148771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP2; 3149771fe6b9SJerome Glisse } else { 3150771fe6b9SJerome Glisse DRM_DEBUG("DFP2 disconnected\n"); 3151771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP2_ATTACHED; 3152771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_ON; 3153771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP2; 3154771fe6b9SJerome Glisse } 3155771fe6b9SJerome Glisse } 3156771fe6b9SJerome Glisse WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch); 3157771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3158771fe6b9SJerome Glisse } 3159771fe6b9SJerome Glisse 3160771fe6b9SJerome Glisse void 3161771fe6b9SJerome Glisse radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc) 3162771fe6b9SJerome Glisse { 3163771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3164771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3165771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3166771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3167771fe6b9SJerome Glisse 3168771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { 3169771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_CRTC_MASK; 3170771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT); 3171771fe6b9SJerome Glisse } 3172771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { 3173771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK; 3174771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT); 3175771fe6b9SJerome Glisse } 3176771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { 3177771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK; 3178771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT); 3179771fe6b9SJerome Glisse } 3180771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { 3181771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK; 3182771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT); 3183771fe6b9SJerome Glisse } 3184771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { 3185771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK; 3186771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT); 3187771fe6b9SJerome Glisse } 3188771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { 3189771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK; 3190771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT); 3191771fe6b9SJerome Glisse } 3192771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3193771fe6b9SJerome Glisse } 3194771fe6b9SJerome Glisse 3195771fe6b9SJerome Glisse void 3196771fe6b9SJerome Glisse radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on) 3197771fe6b9SJerome Glisse { 3198771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3199771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3200771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3201771fe6b9SJerome Glisse uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3202771fe6b9SJerome Glisse 3203771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { 3204771fe6b9SJerome Glisse if (on) 3205771fe6b9SJerome Glisse bios_6_scratch |= RADEON_TV_DPMS_ON; 3206771fe6b9SJerome Glisse else 3207771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_TV_DPMS_ON; 3208771fe6b9SJerome Glisse } 3209771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) { 3210771fe6b9SJerome Glisse if (on) 3211771fe6b9SJerome Glisse bios_6_scratch |= RADEON_CRT_DPMS_ON; 3212771fe6b9SJerome Glisse else 3213771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_CRT_DPMS_ON; 3214771fe6b9SJerome Glisse } 3215771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 3216771fe6b9SJerome Glisse if (on) 3217771fe6b9SJerome Glisse bios_6_scratch |= RADEON_LCD_DPMS_ON; 3218771fe6b9SJerome Glisse else 3219771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_LCD_DPMS_ON; 3220771fe6b9SJerome Glisse } 3221771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 3222771fe6b9SJerome Glisse if (on) 3223771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DFP_DPMS_ON; 3224771fe6b9SJerome Glisse else 3225771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DFP_DPMS_ON; 3226771fe6b9SJerome Glisse } 3227771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3228771fe6b9SJerome Glisse } 3229