1771fe6b9SJerome Glisse /* 2771fe6b9SJerome Glisse * Copyright 2004 ATI Technologies Inc., Markham, Ontario 3771fe6b9SJerome Glisse * Copyright 2007-8 Advanced Micro Devices, Inc. 4771fe6b9SJerome Glisse * Copyright 2008 Red Hat Inc. 5771fe6b9SJerome Glisse * 6771fe6b9SJerome Glisse * Permission is hereby granted, free of charge, to any person obtaining a 7771fe6b9SJerome Glisse * copy of this software and associated documentation files (the "Software"), 8771fe6b9SJerome Glisse * to deal in the Software without restriction, including without limitation 9771fe6b9SJerome Glisse * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10771fe6b9SJerome Glisse * and/or sell copies of the Software, and to permit persons to whom the 11771fe6b9SJerome Glisse * Software is furnished to do so, subject to the following conditions: 12771fe6b9SJerome Glisse * 13771fe6b9SJerome Glisse * The above copyright notice and this permission notice shall be included in 14771fe6b9SJerome Glisse * all copies or substantial portions of the Software. 15771fe6b9SJerome Glisse * 16771fe6b9SJerome Glisse * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17771fe6b9SJerome Glisse * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18771fe6b9SJerome Glisse * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19771fe6b9SJerome Glisse * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20771fe6b9SJerome Glisse * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21771fe6b9SJerome Glisse * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22771fe6b9SJerome Glisse * OTHER DEALINGS IN THE SOFTWARE. 23771fe6b9SJerome Glisse * 24771fe6b9SJerome Glisse * Authors: Dave Airlie 25771fe6b9SJerome Glisse * Alex Deucher 26771fe6b9SJerome Glisse */ 27771fe6b9SJerome Glisse #include "drmP.h" 28771fe6b9SJerome Glisse #include "radeon_drm.h" 29771fe6b9SJerome Glisse #include "radeon.h" 30771fe6b9SJerome Glisse #include "atom.h" 31771fe6b9SJerome Glisse 32771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 33771fe6b9SJerome Glisse /* not sure which of these are needed */ 34771fe6b9SJerome Glisse #include <asm/machdep.h> 35771fe6b9SJerome Glisse #include <asm/pmac_feature.h> 36771fe6b9SJerome Glisse #include <asm/prom.h> 37771fe6b9SJerome Glisse #include <asm/pci-bridge.h> 38771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 39771fe6b9SJerome Glisse 40771fe6b9SJerome Glisse /* from radeon_encoder.c */ 41771fe6b9SJerome Glisse extern uint32_t 425137ee94SAlex Deucher radeon_get_encoder_enum(struct drm_device *dev, uint32_t supported_device, 43771fe6b9SJerome Glisse uint8_t dac); 44771fe6b9SJerome Glisse extern void radeon_link_encoder_connector(struct drm_device *dev); 45771fe6b9SJerome Glisse 46771fe6b9SJerome Glisse /* from radeon_connector.c */ 47771fe6b9SJerome Glisse extern void 48771fe6b9SJerome Glisse radeon_add_legacy_connector(struct drm_device *dev, 49771fe6b9SJerome Glisse uint32_t connector_id, 50771fe6b9SJerome Glisse uint32_t supported_device, 51771fe6b9SJerome Glisse int connector_type, 52b75fad06SAlex Deucher struct radeon_i2c_bus_rec *i2c_bus, 53eed45b30SAlex Deucher uint16_t connector_object_id, 54eed45b30SAlex Deucher struct radeon_hpd *hpd); 55771fe6b9SJerome Glisse 56771fe6b9SJerome Glisse /* from radeon_legacy_encoder.c */ 57771fe6b9SJerome Glisse extern void 585137ee94SAlex Deucher radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_enum, 59771fe6b9SJerome Glisse uint32_t supported_device); 60771fe6b9SJerome Glisse 61771fe6b9SJerome Glisse /* old legacy ATI BIOS routines */ 62771fe6b9SJerome Glisse 63771fe6b9SJerome Glisse /* COMBIOS table offsets */ 64771fe6b9SJerome Glisse enum radeon_combios_table_offset { 65771fe6b9SJerome Glisse /* absolute offset tables */ 66771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_1_TABLE, 67771fe6b9SJerome Glisse COMBIOS_BIOS_SUPPORT_TABLE, 68771fe6b9SJerome Glisse COMBIOS_DAC_PROGRAMMING_TABLE, 69771fe6b9SJerome Glisse COMBIOS_MAX_COLOR_DEPTH_TABLE, 70771fe6b9SJerome Glisse COMBIOS_CRTC_INFO_TABLE, 71771fe6b9SJerome Glisse COMBIOS_PLL_INFO_TABLE, 72771fe6b9SJerome Glisse COMBIOS_TV_INFO_TABLE, 73771fe6b9SJerome Glisse COMBIOS_DFP_INFO_TABLE, 74771fe6b9SJerome Glisse COMBIOS_HW_CONFIG_INFO_TABLE, 75771fe6b9SJerome Glisse COMBIOS_MULTIMEDIA_INFO_TABLE, 76771fe6b9SJerome Glisse COMBIOS_TV_STD_PATCH_TABLE, 77771fe6b9SJerome Glisse COMBIOS_LCD_INFO_TABLE, 78771fe6b9SJerome Glisse COMBIOS_MOBILE_INFO_TABLE, 79771fe6b9SJerome Glisse COMBIOS_PLL_INIT_TABLE, 80771fe6b9SJerome Glisse COMBIOS_MEM_CONFIG_TABLE, 81771fe6b9SJerome Glisse COMBIOS_SAVE_MASK_TABLE, 82771fe6b9SJerome Glisse COMBIOS_HARDCODED_EDID_TABLE, 83771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_2_TABLE, 84771fe6b9SJerome Glisse COMBIOS_CONNECTOR_INFO_TABLE, 85771fe6b9SJerome Glisse COMBIOS_DYN_CLK_1_TABLE, 86771fe6b9SJerome Glisse COMBIOS_RESERVED_MEM_TABLE, 87771fe6b9SJerome Glisse COMBIOS_EXT_TMDS_INFO_TABLE, 88771fe6b9SJerome Glisse COMBIOS_MEM_CLK_INFO_TABLE, 89771fe6b9SJerome Glisse COMBIOS_EXT_DAC_INFO_TABLE, 90771fe6b9SJerome Glisse COMBIOS_MISC_INFO_TABLE, 91771fe6b9SJerome Glisse COMBIOS_CRT_INFO_TABLE, 92771fe6b9SJerome Glisse COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE, 93771fe6b9SJerome Glisse COMBIOS_COMPONENT_VIDEO_INFO_TABLE, 94771fe6b9SJerome Glisse COMBIOS_FAN_SPEED_INFO_TABLE, 95771fe6b9SJerome Glisse COMBIOS_OVERDRIVE_INFO_TABLE, 96771fe6b9SJerome Glisse COMBIOS_OEM_INFO_TABLE, 97771fe6b9SJerome Glisse COMBIOS_DYN_CLK_2_TABLE, 98771fe6b9SJerome Glisse COMBIOS_POWER_CONNECTOR_INFO_TABLE, 99771fe6b9SJerome Glisse COMBIOS_I2C_INFO_TABLE, 100771fe6b9SJerome Glisse /* relative offset tables */ 101771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_3_TABLE, /* offset from misc info */ 102771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_4_TABLE, /* offset from misc info */ 103771fe6b9SJerome Glisse COMBIOS_DETECTED_MEM_TABLE, /* offset from misc info */ 104771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_5_TABLE, /* offset from misc info */ 105771fe6b9SJerome Glisse COMBIOS_RAM_RESET_TABLE, /* offset from mem config */ 106771fe6b9SJerome Glisse COMBIOS_POWERPLAY_INFO_TABLE, /* offset from mobile info */ 107771fe6b9SJerome Glisse COMBIOS_GPIO_INFO_TABLE, /* offset from mobile info */ 108771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE, /* offset from mobile info */ 109771fe6b9SJerome Glisse COMBIOS_TMDS_POWER_TABLE, /* offset from mobile info */ 110771fe6b9SJerome Glisse COMBIOS_TMDS_POWER_ON_TABLE, /* offset from tmds power */ 111771fe6b9SJerome Glisse COMBIOS_TMDS_POWER_OFF_TABLE, /* offset from tmds power */ 112771fe6b9SJerome Glisse }; 113771fe6b9SJerome Glisse 114771fe6b9SJerome Glisse enum radeon_combios_ddc { 115771fe6b9SJerome Glisse DDC_NONE_DETECTED, 116771fe6b9SJerome Glisse DDC_MONID, 117771fe6b9SJerome Glisse DDC_DVI, 118771fe6b9SJerome Glisse DDC_VGA, 119771fe6b9SJerome Glisse DDC_CRT2, 120771fe6b9SJerome Glisse DDC_LCD, 121771fe6b9SJerome Glisse DDC_GPIO, 122771fe6b9SJerome Glisse }; 123771fe6b9SJerome Glisse 124771fe6b9SJerome Glisse enum radeon_combios_connector { 125771fe6b9SJerome Glisse CONNECTOR_NONE_LEGACY, 126771fe6b9SJerome Glisse CONNECTOR_PROPRIETARY_LEGACY, 127771fe6b9SJerome Glisse CONNECTOR_CRT_LEGACY, 128771fe6b9SJerome Glisse CONNECTOR_DVI_I_LEGACY, 129771fe6b9SJerome Glisse CONNECTOR_DVI_D_LEGACY, 130771fe6b9SJerome Glisse CONNECTOR_CTV_LEGACY, 131771fe6b9SJerome Glisse CONNECTOR_STV_LEGACY, 132771fe6b9SJerome Glisse CONNECTOR_UNSUPPORTED_LEGACY 133771fe6b9SJerome Glisse }; 134771fe6b9SJerome Glisse 135771fe6b9SJerome Glisse const int legacy_connector_convert[] = { 136771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_Unknown, 137771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVID, 138771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 139771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 140771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVID, 141771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_Composite, 142771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 143771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_Unknown, 144771fe6b9SJerome Glisse }; 145771fe6b9SJerome Glisse 146771fe6b9SJerome Glisse static uint16_t combios_get_table_offset(struct drm_device *dev, 147771fe6b9SJerome Glisse enum radeon_combios_table_offset table) 148771fe6b9SJerome Glisse { 149771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 150771fe6b9SJerome Glisse int rev; 151771fe6b9SJerome Glisse uint16_t offset = 0, check_offset; 152771fe6b9SJerome Glisse 15303047cdfSMichel Dänzer if (!rdev->bios) 15403047cdfSMichel Dänzer return 0; 15503047cdfSMichel Dänzer 156771fe6b9SJerome Glisse switch (table) { 157771fe6b9SJerome Glisse /* absolute offset tables */ 158771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_1_TABLE: 159771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0xc); 160771fe6b9SJerome Glisse if (check_offset) 161771fe6b9SJerome Glisse offset = check_offset; 162771fe6b9SJerome Glisse break; 163771fe6b9SJerome Glisse case COMBIOS_BIOS_SUPPORT_TABLE: 164771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x14); 165771fe6b9SJerome Glisse if (check_offset) 166771fe6b9SJerome Glisse offset = check_offset; 167771fe6b9SJerome Glisse break; 168771fe6b9SJerome Glisse case COMBIOS_DAC_PROGRAMMING_TABLE: 169771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x2a); 170771fe6b9SJerome Glisse if (check_offset) 171771fe6b9SJerome Glisse offset = check_offset; 172771fe6b9SJerome Glisse break; 173771fe6b9SJerome Glisse case COMBIOS_MAX_COLOR_DEPTH_TABLE: 174771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x2c); 175771fe6b9SJerome Glisse if (check_offset) 176771fe6b9SJerome Glisse offset = check_offset; 177771fe6b9SJerome Glisse break; 178771fe6b9SJerome Glisse case COMBIOS_CRTC_INFO_TABLE: 179771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x2e); 180771fe6b9SJerome Glisse if (check_offset) 181771fe6b9SJerome Glisse offset = check_offset; 182771fe6b9SJerome Glisse break; 183771fe6b9SJerome Glisse case COMBIOS_PLL_INFO_TABLE: 184771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x30); 185771fe6b9SJerome Glisse if (check_offset) 186771fe6b9SJerome Glisse offset = check_offset; 187771fe6b9SJerome Glisse break; 188771fe6b9SJerome Glisse case COMBIOS_TV_INFO_TABLE: 189771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x32); 190771fe6b9SJerome Glisse if (check_offset) 191771fe6b9SJerome Glisse offset = check_offset; 192771fe6b9SJerome Glisse break; 193771fe6b9SJerome Glisse case COMBIOS_DFP_INFO_TABLE: 194771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x34); 195771fe6b9SJerome Glisse if (check_offset) 196771fe6b9SJerome Glisse offset = check_offset; 197771fe6b9SJerome Glisse break; 198771fe6b9SJerome Glisse case COMBIOS_HW_CONFIG_INFO_TABLE: 199771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x36); 200771fe6b9SJerome Glisse if (check_offset) 201771fe6b9SJerome Glisse offset = check_offset; 202771fe6b9SJerome Glisse break; 203771fe6b9SJerome Glisse case COMBIOS_MULTIMEDIA_INFO_TABLE: 204771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x38); 205771fe6b9SJerome Glisse if (check_offset) 206771fe6b9SJerome Glisse offset = check_offset; 207771fe6b9SJerome Glisse break; 208771fe6b9SJerome Glisse case COMBIOS_TV_STD_PATCH_TABLE: 209771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x3e); 210771fe6b9SJerome Glisse if (check_offset) 211771fe6b9SJerome Glisse offset = check_offset; 212771fe6b9SJerome Glisse break; 213771fe6b9SJerome Glisse case COMBIOS_LCD_INFO_TABLE: 214771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x40); 215771fe6b9SJerome Glisse if (check_offset) 216771fe6b9SJerome Glisse offset = check_offset; 217771fe6b9SJerome Glisse break; 218771fe6b9SJerome Glisse case COMBIOS_MOBILE_INFO_TABLE: 219771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x42); 220771fe6b9SJerome Glisse if (check_offset) 221771fe6b9SJerome Glisse offset = check_offset; 222771fe6b9SJerome Glisse break; 223771fe6b9SJerome Glisse case COMBIOS_PLL_INIT_TABLE: 224771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x46); 225771fe6b9SJerome Glisse if (check_offset) 226771fe6b9SJerome Glisse offset = check_offset; 227771fe6b9SJerome Glisse break; 228771fe6b9SJerome Glisse case COMBIOS_MEM_CONFIG_TABLE: 229771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x48); 230771fe6b9SJerome Glisse if (check_offset) 231771fe6b9SJerome Glisse offset = check_offset; 232771fe6b9SJerome Glisse break; 233771fe6b9SJerome Glisse case COMBIOS_SAVE_MASK_TABLE: 234771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x4a); 235771fe6b9SJerome Glisse if (check_offset) 236771fe6b9SJerome Glisse offset = check_offset; 237771fe6b9SJerome Glisse break; 238771fe6b9SJerome Glisse case COMBIOS_HARDCODED_EDID_TABLE: 239771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x4c); 240771fe6b9SJerome Glisse if (check_offset) 241771fe6b9SJerome Glisse offset = check_offset; 242771fe6b9SJerome Glisse break; 243771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_2_TABLE: 244771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x4e); 245771fe6b9SJerome Glisse if (check_offset) 246771fe6b9SJerome Glisse offset = check_offset; 247771fe6b9SJerome Glisse break; 248771fe6b9SJerome Glisse case COMBIOS_CONNECTOR_INFO_TABLE: 249771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x50); 250771fe6b9SJerome Glisse if (check_offset) 251771fe6b9SJerome Glisse offset = check_offset; 252771fe6b9SJerome Glisse break; 253771fe6b9SJerome Glisse case COMBIOS_DYN_CLK_1_TABLE: 254771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x52); 255771fe6b9SJerome Glisse if (check_offset) 256771fe6b9SJerome Glisse offset = check_offset; 257771fe6b9SJerome Glisse break; 258771fe6b9SJerome Glisse case COMBIOS_RESERVED_MEM_TABLE: 259771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x54); 260771fe6b9SJerome Glisse if (check_offset) 261771fe6b9SJerome Glisse offset = check_offset; 262771fe6b9SJerome Glisse break; 263771fe6b9SJerome Glisse case COMBIOS_EXT_TMDS_INFO_TABLE: 264771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x58); 265771fe6b9SJerome Glisse if (check_offset) 266771fe6b9SJerome Glisse offset = check_offset; 267771fe6b9SJerome Glisse break; 268771fe6b9SJerome Glisse case COMBIOS_MEM_CLK_INFO_TABLE: 269771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x5a); 270771fe6b9SJerome Glisse if (check_offset) 271771fe6b9SJerome Glisse offset = check_offset; 272771fe6b9SJerome Glisse break; 273771fe6b9SJerome Glisse case COMBIOS_EXT_DAC_INFO_TABLE: 274771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x5c); 275771fe6b9SJerome Glisse if (check_offset) 276771fe6b9SJerome Glisse offset = check_offset; 277771fe6b9SJerome Glisse break; 278771fe6b9SJerome Glisse case COMBIOS_MISC_INFO_TABLE: 279771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x5e); 280771fe6b9SJerome Glisse if (check_offset) 281771fe6b9SJerome Glisse offset = check_offset; 282771fe6b9SJerome Glisse break; 283771fe6b9SJerome Glisse case COMBIOS_CRT_INFO_TABLE: 284771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x60); 285771fe6b9SJerome Glisse if (check_offset) 286771fe6b9SJerome Glisse offset = check_offset; 287771fe6b9SJerome Glisse break; 288771fe6b9SJerome Glisse case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE: 289771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x62); 290771fe6b9SJerome Glisse if (check_offset) 291771fe6b9SJerome Glisse offset = check_offset; 292771fe6b9SJerome Glisse break; 293771fe6b9SJerome Glisse case COMBIOS_COMPONENT_VIDEO_INFO_TABLE: 294771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x64); 295771fe6b9SJerome Glisse if (check_offset) 296771fe6b9SJerome Glisse offset = check_offset; 297771fe6b9SJerome Glisse break; 298771fe6b9SJerome Glisse case COMBIOS_FAN_SPEED_INFO_TABLE: 299771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x66); 300771fe6b9SJerome Glisse if (check_offset) 301771fe6b9SJerome Glisse offset = check_offset; 302771fe6b9SJerome Glisse break; 303771fe6b9SJerome Glisse case COMBIOS_OVERDRIVE_INFO_TABLE: 304771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x68); 305771fe6b9SJerome Glisse if (check_offset) 306771fe6b9SJerome Glisse offset = check_offset; 307771fe6b9SJerome Glisse break; 308771fe6b9SJerome Glisse case COMBIOS_OEM_INFO_TABLE: 309771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x6a); 310771fe6b9SJerome Glisse if (check_offset) 311771fe6b9SJerome Glisse offset = check_offset; 312771fe6b9SJerome Glisse break; 313771fe6b9SJerome Glisse case COMBIOS_DYN_CLK_2_TABLE: 314771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x6c); 315771fe6b9SJerome Glisse if (check_offset) 316771fe6b9SJerome Glisse offset = check_offset; 317771fe6b9SJerome Glisse break; 318771fe6b9SJerome Glisse case COMBIOS_POWER_CONNECTOR_INFO_TABLE: 319771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x6e); 320771fe6b9SJerome Glisse if (check_offset) 321771fe6b9SJerome Glisse offset = check_offset; 322771fe6b9SJerome Glisse break; 323771fe6b9SJerome Glisse case COMBIOS_I2C_INFO_TABLE: 324771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x70); 325771fe6b9SJerome Glisse if (check_offset) 326771fe6b9SJerome Glisse offset = check_offset; 327771fe6b9SJerome Glisse break; 328771fe6b9SJerome Glisse /* relative offset tables */ 329771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_3_TABLE: /* offset from misc info */ 330771fe6b9SJerome Glisse check_offset = 331771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 332771fe6b9SJerome Glisse if (check_offset) { 333771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 334771fe6b9SJerome Glisse if (rev > 0) { 335771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x3); 336771fe6b9SJerome Glisse if (check_offset) 337771fe6b9SJerome Glisse offset = check_offset; 338771fe6b9SJerome Glisse } 339771fe6b9SJerome Glisse } 340771fe6b9SJerome Glisse break; 341771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_4_TABLE: /* offset from misc info */ 342771fe6b9SJerome Glisse check_offset = 343771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 344771fe6b9SJerome Glisse if (check_offset) { 345771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 346771fe6b9SJerome Glisse if (rev > 0) { 347771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x5); 348771fe6b9SJerome Glisse if (check_offset) 349771fe6b9SJerome Glisse offset = check_offset; 350771fe6b9SJerome Glisse } 351771fe6b9SJerome Glisse } 352771fe6b9SJerome Glisse break; 353771fe6b9SJerome Glisse case COMBIOS_DETECTED_MEM_TABLE: /* offset from misc info */ 354771fe6b9SJerome Glisse check_offset = 355771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 356771fe6b9SJerome Glisse if (check_offset) { 357771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 358771fe6b9SJerome Glisse if (rev > 0) { 359771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x7); 360771fe6b9SJerome Glisse if (check_offset) 361771fe6b9SJerome Glisse offset = check_offset; 362771fe6b9SJerome Glisse } 363771fe6b9SJerome Glisse } 364771fe6b9SJerome Glisse break; 365771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_5_TABLE: /* offset from misc info */ 366771fe6b9SJerome Glisse check_offset = 367771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 368771fe6b9SJerome Glisse if (check_offset) { 369771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 370771fe6b9SJerome Glisse if (rev == 2) { 371771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x9); 372771fe6b9SJerome Glisse if (check_offset) 373771fe6b9SJerome Glisse offset = check_offset; 374771fe6b9SJerome Glisse } 375771fe6b9SJerome Glisse } 376771fe6b9SJerome Glisse break; 377771fe6b9SJerome Glisse case COMBIOS_RAM_RESET_TABLE: /* offset from mem config */ 378771fe6b9SJerome Glisse check_offset = 379771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 380771fe6b9SJerome Glisse if (check_offset) { 381771fe6b9SJerome Glisse while (RBIOS8(check_offset++)); 382771fe6b9SJerome Glisse check_offset += 2; 383771fe6b9SJerome Glisse if (check_offset) 384771fe6b9SJerome Glisse offset = check_offset; 385771fe6b9SJerome Glisse } 386771fe6b9SJerome Glisse break; 387771fe6b9SJerome Glisse case COMBIOS_POWERPLAY_INFO_TABLE: /* offset from mobile info */ 388771fe6b9SJerome Glisse check_offset = 389771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 390771fe6b9SJerome Glisse if (check_offset) { 391771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x11); 392771fe6b9SJerome Glisse if (check_offset) 393771fe6b9SJerome Glisse offset = check_offset; 394771fe6b9SJerome Glisse } 395771fe6b9SJerome Glisse break; 396771fe6b9SJerome Glisse case COMBIOS_GPIO_INFO_TABLE: /* offset from mobile info */ 397771fe6b9SJerome Glisse check_offset = 398771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 399771fe6b9SJerome Glisse if (check_offset) { 400771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x13); 401771fe6b9SJerome Glisse if (check_offset) 402771fe6b9SJerome Glisse offset = check_offset; 403771fe6b9SJerome Glisse } 404771fe6b9SJerome Glisse break; 405771fe6b9SJerome Glisse case COMBIOS_LCD_DDC_INFO_TABLE: /* offset from mobile info */ 406771fe6b9SJerome Glisse check_offset = 407771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 408771fe6b9SJerome Glisse if (check_offset) { 409771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x15); 410771fe6b9SJerome Glisse if (check_offset) 411771fe6b9SJerome Glisse offset = check_offset; 412771fe6b9SJerome Glisse } 413771fe6b9SJerome Glisse break; 414771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_TABLE: /* offset from mobile info */ 415771fe6b9SJerome Glisse check_offset = 416771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 417771fe6b9SJerome Glisse if (check_offset) { 418771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x17); 419771fe6b9SJerome Glisse if (check_offset) 420771fe6b9SJerome Glisse offset = check_offset; 421771fe6b9SJerome Glisse } 422771fe6b9SJerome Glisse break; 423771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_ON_TABLE: /* offset from tmds power */ 424771fe6b9SJerome Glisse check_offset = 425771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); 426771fe6b9SJerome Glisse if (check_offset) { 427771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x2); 428771fe6b9SJerome Glisse if (check_offset) 429771fe6b9SJerome Glisse offset = check_offset; 430771fe6b9SJerome Glisse } 431771fe6b9SJerome Glisse break; 432771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_OFF_TABLE: /* offset from tmds power */ 433771fe6b9SJerome Glisse check_offset = 434771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); 435771fe6b9SJerome Glisse if (check_offset) { 436771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x4); 437771fe6b9SJerome Glisse if (check_offset) 438771fe6b9SJerome Glisse offset = check_offset; 439771fe6b9SJerome Glisse } 440771fe6b9SJerome Glisse break; 441771fe6b9SJerome Glisse default: 442771fe6b9SJerome Glisse break; 443771fe6b9SJerome Glisse } 444771fe6b9SJerome Glisse 445771fe6b9SJerome Glisse return offset; 446771fe6b9SJerome Glisse 447771fe6b9SJerome Glisse } 448771fe6b9SJerome Glisse 4493c537889SAlex Deucher bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev) 4503c537889SAlex Deucher { 451fafcf94eSAlex Deucher int edid_info, size; 4523c537889SAlex Deucher struct edid *edid; 4537466f4ccSAdam Jackson unsigned char *raw; 4543c537889SAlex Deucher edid_info = combios_get_table_offset(rdev->ddev, COMBIOS_HARDCODED_EDID_TABLE); 4553c537889SAlex Deucher if (!edid_info) 4563c537889SAlex Deucher return false; 4573c537889SAlex Deucher 4587466f4ccSAdam Jackson raw = rdev->bios + edid_info; 459fafcf94eSAlex Deucher size = EDID_LENGTH * (raw[0x7e] + 1); 460fafcf94eSAlex Deucher edid = kmalloc(size, GFP_KERNEL); 4613c537889SAlex Deucher if (edid == NULL) 4623c537889SAlex Deucher return false; 4633c537889SAlex Deucher 464fafcf94eSAlex Deucher memcpy((unsigned char *)edid, raw, size); 4653c537889SAlex Deucher 4663c537889SAlex Deucher if (!drm_edid_is_valid(edid)) { 4673c537889SAlex Deucher kfree(edid); 4683c537889SAlex Deucher return false; 4693c537889SAlex Deucher } 4703c537889SAlex Deucher 4713c537889SAlex Deucher rdev->mode_info.bios_hardcoded_edid = edid; 472fafcf94eSAlex Deucher rdev->mode_info.bios_hardcoded_edid_size = size; 4733c537889SAlex Deucher return true; 4743c537889SAlex Deucher } 4753c537889SAlex Deucher 476c324acd5SAlex Deucher /* this is used for atom LCDs as well */ 4773c537889SAlex Deucher struct edid * 478c324acd5SAlex Deucher radeon_bios_get_hardcoded_edid(struct radeon_device *rdev) 4793c537889SAlex Deucher { 480fafcf94eSAlex Deucher struct edid *edid; 481fafcf94eSAlex Deucher 482fafcf94eSAlex Deucher if (rdev->mode_info.bios_hardcoded_edid) { 483fafcf94eSAlex Deucher edid = kmalloc(rdev->mode_info.bios_hardcoded_edid_size, GFP_KERNEL); 484fafcf94eSAlex Deucher if (edid) { 485fafcf94eSAlex Deucher memcpy((unsigned char *)edid, 486fafcf94eSAlex Deucher (unsigned char *)rdev->mode_info.bios_hardcoded_edid, 487fafcf94eSAlex Deucher rdev->mode_info.bios_hardcoded_edid_size); 488fafcf94eSAlex Deucher return edid; 489fafcf94eSAlex Deucher } 490fafcf94eSAlex Deucher } 4913c537889SAlex Deucher return NULL; 4923c537889SAlex Deucher } 4933c537889SAlex Deucher 4946a93cb25SAlex Deucher static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev, 495179e8078SAlex Deucher enum radeon_combios_ddc ddc, 496179e8078SAlex Deucher u32 clk_mask, 497179e8078SAlex Deucher u32 data_mask) 498771fe6b9SJerome Glisse { 499771fe6b9SJerome Glisse struct radeon_i2c_bus_rec i2c; 500179e8078SAlex Deucher int ddc_line = 0; 501179e8078SAlex Deucher 502179e8078SAlex Deucher /* ddc id = mask reg 503179e8078SAlex Deucher * DDC_NONE_DETECTED = none 504179e8078SAlex Deucher * DDC_DVI = RADEON_GPIO_DVI_DDC 505179e8078SAlex Deucher * DDC_VGA = RADEON_GPIO_VGA_DDC 506179e8078SAlex Deucher * DDC_LCD = RADEON_GPIOPAD_MASK 507179e8078SAlex Deucher * DDC_GPIO = RADEON_MDGPIO_MASK 508508c8d60SAlex Deucher * r1xx 509179e8078SAlex Deucher * DDC_MONID = RADEON_GPIO_MONID 510179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_CRT2_DDC 511508c8d60SAlex Deucher * r200 512179e8078SAlex Deucher * DDC_MONID = RADEON_GPIO_MONID 513179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_DVI_DDC 514508c8d60SAlex Deucher * r300/r350 515508c8d60SAlex Deucher * DDC_MONID = RADEON_GPIO_DVI_DDC 516508c8d60SAlex Deucher * DDC_CRT2 = RADEON_GPIO_DVI_DDC 517508c8d60SAlex Deucher * rv2xx/rv3xx 518508c8d60SAlex Deucher * DDC_MONID = RADEON_GPIO_MONID 519508c8d60SAlex Deucher * DDC_CRT2 = RADEON_GPIO_MONID 520179e8078SAlex Deucher * rs3xx/rs4xx 521179e8078SAlex Deucher * DDC_MONID = RADEON_GPIOPAD_MASK 522179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_MONID 523179e8078SAlex Deucher */ 524179e8078SAlex Deucher switch (ddc) { 525179e8078SAlex Deucher case DDC_NONE_DETECTED: 526179e8078SAlex Deucher default: 527179e8078SAlex Deucher ddc_line = 0; 528179e8078SAlex Deucher break; 529179e8078SAlex Deucher case DDC_DVI: 530179e8078SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 531179e8078SAlex Deucher break; 532179e8078SAlex Deucher case DDC_VGA: 533179e8078SAlex Deucher ddc_line = RADEON_GPIO_VGA_DDC; 534179e8078SAlex Deucher break; 535179e8078SAlex Deucher case DDC_LCD: 536179e8078SAlex Deucher ddc_line = RADEON_GPIOPAD_MASK; 537179e8078SAlex Deucher break; 538179e8078SAlex Deucher case DDC_GPIO: 539179e8078SAlex Deucher ddc_line = RADEON_MDGPIO_MASK; 540179e8078SAlex Deucher break; 541179e8078SAlex Deucher case DDC_MONID: 542179e8078SAlex Deucher if (rdev->family == CHIP_RS300 || 543179e8078SAlex Deucher rdev->family == CHIP_RS400 || 544179e8078SAlex Deucher rdev->family == CHIP_RS480) 545179e8078SAlex Deucher ddc_line = RADEON_GPIOPAD_MASK; 546508c8d60SAlex Deucher else if (rdev->family == CHIP_R300 || 547776f2b7cSAlex Deucher rdev->family == CHIP_R350) { 548508c8d60SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 549776f2b7cSAlex Deucher ddc = DDC_DVI; 550776f2b7cSAlex Deucher } else 551179e8078SAlex Deucher ddc_line = RADEON_GPIO_MONID; 552179e8078SAlex Deucher break; 553179e8078SAlex Deucher case DDC_CRT2: 554508c8d60SAlex Deucher if (rdev->family == CHIP_R200 || 555508c8d60SAlex Deucher rdev->family == CHIP_R300 || 556776f2b7cSAlex Deucher rdev->family == CHIP_R350) { 557179e8078SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 558776f2b7cSAlex Deucher ddc = DDC_DVI; 559776f2b7cSAlex Deucher } else if (rdev->family == CHIP_RS300 || 560776f2b7cSAlex Deucher rdev->family == CHIP_RS400 || 561776f2b7cSAlex Deucher rdev->family == CHIP_RS480) 562508c8d60SAlex Deucher ddc_line = RADEON_GPIO_MONID; 563776f2b7cSAlex Deucher else if (rdev->family >= CHIP_RV350) { 564776f2b7cSAlex Deucher ddc_line = RADEON_GPIO_MONID; 565776f2b7cSAlex Deucher ddc = DDC_MONID; 566776f2b7cSAlex Deucher } else 567179e8078SAlex Deucher ddc_line = RADEON_GPIO_CRT2_DDC; 568179e8078SAlex Deucher break; 569179e8078SAlex Deucher } 570771fe6b9SJerome Glisse 5716a93cb25SAlex Deucher if (ddc_line == RADEON_GPIOPAD_MASK) { 5726a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_GPIOPAD_MASK; 5736a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_GPIOPAD_MASK; 5746a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_GPIOPAD_A; 5756a93cb25SAlex Deucher i2c.a_data_reg = RADEON_GPIOPAD_A; 5766a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_GPIOPAD_EN; 5776a93cb25SAlex Deucher i2c.en_data_reg = RADEON_GPIOPAD_EN; 5786a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_GPIOPAD_Y; 5796a93cb25SAlex Deucher i2c.y_data_reg = RADEON_GPIOPAD_Y; 5806a93cb25SAlex Deucher } else if (ddc_line == RADEON_MDGPIO_MASK) { 5816a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_MDGPIO_MASK; 5826a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_MDGPIO_MASK; 5836a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_MDGPIO_A; 5846a93cb25SAlex Deucher i2c.a_data_reg = RADEON_MDGPIO_A; 5856a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_MDGPIO_EN; 5866a93cb25SAlex Deucher i2c.en_data_reg = RADEON_MDGPIO_EN; 5876a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_MDGPIO_Y; 5886a93cb25SAlex Deucher i2c.y_data_reg = RADEON_MDGPIO_Y; 5896a93cb25SAlex Deucher } else { 590771fe6b9SJerome Glisse i2c.mask_clk_reg = ddc_line; 591771fe6b9SJerome Glisse i2c.mask_data_reg = ddc_line; 592771fe6b9SJerome Glisse i2c.a_clk_reg = ddc_line; 593771fe6b9SJerome Glisse i2c.a_data_reg = ddc_line; 5949b9fe724SAlex Deucher i2c.en_clk_reg = ddc_line; 5959b9fe724SAlex Deucher i2c.en_data_reg = ddc_line; 5969b9fe724SAlex Deucher i2c.y_clk_reg = ddc_line; 5979b9fe724SAlex Deucher i2c.y_data_reg = ddc_line; 598771fe6b9SJerome Glisse } 599771fe6b9SJerome Glisse 600179e8078SAlex Deucher if (clk_mask && data_mask) { 601be663057SAlex Deucher /* system specific masks */ 602179e8078SAlex Deucher i2c.mask_clk_mask = clk_mask; 603179e8078SAlex Deucher i2c.mask_data_mask = data_mask; 604179e8078SAlex Deucher i2c.a_clk_mask = clk_mask; 605179e8078SAlex Deucher i2c.a_data_mask = data_mask; 606179e8078SAlex Deucher i2c.en_clk_mask = clk_mask; 607179e8078SAlex Deucher i2c.en_data_mask = data_mask; 608179e8078SAlex Deucher i2c.y_clk_mask = clk_mask; 609179e8078SAlex Deucher i2c.y_data_mask = data_mask; 610be663057SAlex Deucher } else if ((ddc_line == RADEON_GPIOPAD_MASK) || 611be663057SAlex Deucher (ddc_line == RADEON_MDGPIO_MASK)) { 612be663057SAlex Deucher /* default gpiopad masks */ 613be663057SAlex Deucher i2c.mask_clk_mask = (0x20 << 8); 614be663057SAlex Deucher i2c.mask_data_mask = 0x80; 615be663057SAlex Deucher i2c.a_clk_mask = (0x20 << 8); 616be663057SAlex Deucher i2c.a_data_mask = 0x80; 617be663057SAlex Deucher i2c.en_clk_mask = (0x20 << 8); 618be663057SAlex Deucher i2c.en_data_mask = 0x80; 619be663057SAlex Deucher i2c.y_clk_mask = (0x20 << 8); 620be663057SAlex Deucher i2c.y_data_mask = 0x80; 621179e8078SAlex Deucher } else { 622be663057SAlex Deucher /* default masks for ddc pads */ 623*286e0c94SJean Delvare i2c.mask_clk_mask = RADEON_GPIO_MASK_1; 624*286e0c94SJean Delvare i2c.mask_data_mask = RADEON_GPIO_MASK_0; 625179e8078SAlex Deucher i2c.a_clk_mask = RADEON_GPIO_A_1; 626179e8078SAlex Deucher i2c.a_data_mask = RADEON_GPIO_A_0; 627179e8078SAlex Deucher i2c.en_clk_mask = RADEON_GPIO_EN_1; 628179e8078SAlex Deucher i2c.en_data_mask = RADEON_GPIO_EN_0; 629179e8078SAlex Deucher i2c.y_clk_mask = RADEON_GPIO_Y_1; 630179e8078SAlex Deucher i2c.y_data_mask = RADEON_GPIO_Y_0; 631179e8078SAlex Deucher } 632179e8078SAlex Deucher 63340bacf16SAlex Deucher switch (rdev->family) { 63440bacf16SAlex Deucher case CHIP_R100: 63540bacf16SAlex Deucher case CHIP_RV100: 63640bacf16SAlex Deucher case CHIP_RS100: 63740bacf16SAlex Deucher case CHIP_RV200: 63840bacf16SAlex Deucher case CHIP_RS200: 63940bacf16SAlex Deucher case CHIP_RS300: 64040bacf16SAlex Deucher switch (ddc_line) { 64140bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 642b28ea411SAlex Deucher i2c.hw_capable = true; 64340bacf16SAlex Deucher break; 64440bacf16SAlex Deucher default: 64540bacf16SAlex Deucher i2c.hw_capable = false; 64640bacf16SAlex Deucher break; 64740bacf16SAlex Deucher } 64840bacf16SAlex Deucher break; 64940bacf16SAlex Deucher case CHIP_R200: 65040bacf16SAlex Deucher switch (ddc_line) { 65140bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 65240bacf16SAlex Deucher case RADEON_GPIO_MONID: 65340bacf16SAlex Deucher i2c.hw_capable = true; 65440bacf16SAlex Deucher break; 65540bacf16SAlex Deucher default: 65640bacf16SAlex Deucher i2c.hw_capable = false; 65740bacf16SAlex Deucher break; 65840bacf16SAlex Deucher } 65940bacf16SAlex Deucher break; 66040bacf16SAlex Deucher case CHIP_RV250: 66140bacf16SAlex Deucher case CHIP_RV280: 66240bacf16SAlex Deucher switch (ddc_line) { 66340bacf16SAlex Deucher case RADEON_GPIO_VGA_DDC: 66440bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 66540bacf16SAlex Deucher case RADEON_GPIO_CRT2_DDC: 66640bacf16SAlex Deucher i2c.hw_capable = true; 66740bacf16SAlex Deucher break; 66840bacf16SAlex Deucher default: 66940bacf16SAlex Deucher i2c.hw_capable = false; 67040bacf16SAlex Deucher break; 67140bacf16SAlex Deucher } 67240bacf16SAlex Deucher break; 67340bacf16SAlex Deucher case CHIP_R300: 67440bacf16SAlex Deucher case CHIP_R350: 67540bacf16SAlex Deucher switch (ddc_line) { 67640bacf16SAlex Deucher case RADEON_GPIO_VGA_DDC: 67740bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 67840bacf16SAlex Deucher i2c.hw_capable = true; 67940bacf16SAlex Deucher break; 68040bacf16SAlex Deucher default: 68140bacf16SAlex Deucher i2c.hw_capable = false; 68240bacf16SAlex Deucher break; 68340bacf16SAlex Deucher } 68440bacf16SAlex Deucher break; 68540bacf16SAlex Deucher case CHIP_RV350: 68640bacf16SAlex Deucher case CHIP_RV380: 68740bacf16SAlex Deucher case CHIP_RS400: 68840bacf16SAlex Deucher case CHIP_RS480: 6896a93cb25SAlex Deucher switch (ddc_line) { 6906a93cb25SAlex Deucher case RADEON_GPIO_VGA_DDC: 6916a93cb25SAlex Deucher case RADEON_GPIO_DVI_DDC: 6926a93cb25SAlex Deucher i2c.hw_capable = true; 6936a93cb25SAlex Deucher break; 6946a93cb25SAlex Deucher case RADEON_GPIO_MONID: 6956a93cb25SAlex Deucher /* hw i2c on RADEON_GPIO_MONID doesn't seem to work 6966a93cb25SAlex Deucher * reliably on some pre-r4xx hardware; not sure why. 6976a93cb25SAlex Deucher */ 6986a93cb25SAlex Deucher i2c.hw_capable = false; 6996a93cb25SAlex Deucher break; 7006a93cb25SAlex Deucher default: 7016a93cb25SAlex Deucher i2c.hw_capable = false; 7026a93cb25SAlex Deucher break; 7036a93cb25SAlex Deucher } 70440bacf16SAlex Deucher break; 70540bacf16SAlex Deucher default: 70640bacf16SAlex Deucher i2c.hw_capable = false; 70740bacf16SAlex Deucher break; 7086a93cb25SAlex Deucher } 7096a93cb25SAlex Deucher i2c.mm_i2c = false; 710f376b94fSAlex Deucher 711179e8078SAlex Deucher i2c.i2c_id = ddc; 7128e36ed00SAlex Deucher i2c.hpd = RADEON_HPD_NONE; 7136a93cb25SAlex Deucher 714771fe6b9SJerome Glisse if (ddc_line) 715771fe6b9SJerome Glisse i2c.valid = true; 716771fe6b9SJerome Glisse else 717771fe6b9SJerome Glisse i2c.valid = false; 718771fe6b9SJerome Glisse 719771fe6b9SJerome Glisse return i2c; 720771fe6b9SJerome Glisse } 721771fe6b9SJerome Glisse 722f376b94fSAlex Deucher void radeon_combios_i2c_init(struct radeon_device *rdev) 723f376b94fSAlex Deucher { 724f376b94fSAlex Deucher struct drm_device *dev = rdev->ddev; 725f376b94fSAlex Deucher struct radeon_i2c_bus_rec i2c; 726f376b94fSAlex Deucher 727508c8d60SAlex Deucher /* actual hw pads 728508c8d60SAlex Deucher * r1xx/rs2xx/rs3xx 729508c8d60SAlex Deucher * 0x60, 0x64, 0x68, 0x6c, gpiopads, mm 730508c8d60SAlex Deucher * r200 731508c8d60SAlex Deucher * 0x60, 0x64, 0x68, mm 732508c8d60SAlex Deucher * r300/r350 733508c8d60SAlex Deucher * 0x60, 0x64, mm 734508c8d60SAlex Deucher * rv2xx/rv3xx/rs4xx 735508c8d60SAlex Deucher * 0x60, 0x64, 0x68, gpiopads, mm 736508c8d60SAlex Deucher */ 737f376b94fSAlex Deucher 738508c8d60SAlex Deucher /* 0x60 */ 739179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 740179e8078SAlex Deucher rdev->i2c_bus[0] = radeon_i2c_create(dev, &i2c, "DVI_DDC"); 741508c8d60SAlex Deucher /* 0x64 */ 742179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 743179e8078SAlex Deucher rdev->i2c_bus[1] = radeon_i2c_create(dev, &i2c, "VGA_DDC"); 744f376b94fSAlex Deucher 745508c8d60SAlex Deucher /* mm i2c */ 746f376b94fSAlex Deucher i2c.valid = true; 747f376b94fSAlex Deucher i2c.hw_capable = true; 748f376b94fSAlex Deucher i2c.mm_i2c = true; 749179e8078SAlex Deucher i2c.i2c_id = 0xa0; 750179e8078SAlex Deucher rdev->i2c_bus[2] = radeon_i2c_create(dev, &i2c, "MM_I2C"); 751179e8078SAlex Deucher 752508c8d60SAlex Deucher if (rdev->family == CHIP_R300 || 753508c8d60SAlex Deucher rdev->family == CHIP_R350) { 754508c8d60SAlex Deucher /* only 2 sw i2c pads */ 755508c8d60SAlex Deucher } else if (rdev->family == CHIP_RS300 || 756179e8078SAlex Deucher rdev->family == CHIP_RS400 || 757179e8078SAlex Deucher rdev->family == CHIP_RS480) { 758179e8078SAlex Deucher u16 offset; 759179e8078SAlex Deucher u8 id, blocks, clk, data; 760179e8078SAlex Deucher int i; 761179e8078SAlex Deucher 762508c8d60SAlex Deucher /* 0x68 */ 763179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 764179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 765179e8078SAlex Deucher 766179e8078SAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE); 767179e8078SAlex Deucher if (offset) { 768179e8078SAlex Deucher blocks = RBIOS8(offset + 2); 769179e8078SAlex Deucher for (i = 0; i < blocks; i++) { 770179e8078SAlex Deucher id = RBIOS8(offset + 3 + (i * 5) + 0); 771179e8078SAlex Deucher if (id == 136) { 772179e8078SAlex Deucher clk = RBIOS8(offset + 3 + (i * 5) + 3); 773179e8078SAlex Deucher data = RBIOS8(offset + 3 + (i * 5) + 4); 774508c8d60SAlex Deucher /* gpiopad */ 775179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 776791cfe26SAlex Deucher (1 << clk), (1 << data)); 777179e8078SAlex Deucher rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "GPIOPAD_MASK"); 778179e8078SAlex Deucher break; 779179e8078SAlex Deucher } 780179e8078SAlex Deucher } 781179e8078SAlex Deucher } 7826dd66633SAlex Deucher } else if ((rdev->family == CHIP_R200) || 7836dd66633SAlex Deucher (rdev->family >= CHIP_R300)) { 784508c8d60SAlex Deucher /* 0x68 */ 785179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 786179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 787179e8078SAlex Deucher } else { 788508c8d60SAlex Deucher /* 0x68 */ 789179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 790179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 791508c8d60SAlex Deucher /* 0x6c */ 792179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 793179e8078SAlex Deucher rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "CRT2_DDC"); 794179e8078SAlex Deucher } 795f376b94fSAlex Deucher } 796f376b94fSAlex Deucher 797771fe6b9SJerome Glisse bool radeon_combios_get_clock_info(struct drm_device *dev) 798771fe6b9SJerome Glisse { 799771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 800771fe6b9SJerome Glisse uint16_t pll_info; 801771fe6b9SJerome Glisse struct radeon_pll *p1pll = &rdev->clock.p1pll; 802771fe6b9SJerome Glisse struct radeon_pll *p2pll = &rdev->clock.p2pll; 803771fe6b9SJerome Glisse struct radeon_pll *spll = &rdev->clock.spll; 804771fe6b9SJerome Glisse struct radeon_pll *mpll = &rdev->clock.mpll; 805771fe6b9SJerome Glisse int8_t rev; 806771fe6b9SJerome Glisse uint16_t sclk, mclk; 807771fe6b9SJerome Glisse 808771fe6b9SJerome Glisse pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE); 809771fe6b9SJerome Glisse if (pll_info) { 810771fe6b9SJerome Glisse rev = RBIOS8(pll_info); 811771fe6b9SJerome Glisse 812771fe6b9SJerome Glisse /* pixel clocks */ 813771fe6b9SJerome Glisse p1pll->reference_freq = RBIOS16(pll_info + 0xe); 814771fe6b9SJerome Glisse p1pll->reference_div = RBIOS16(pll_info + 0x10); 815771fe6b9SJerome Glisse p1pll->pll_out_min = RBIOS32(pll_info + 0x12); 816771fe6b9SJerome Glisse p1pll->pll_out_max = RBIOS32(pll_info + 0x16); 81786cb2bbfSAlex Deucher p1pll->lcd_pll_out_min = p1pll->pll_out_min; 81886cb2bbfSAlex Deucher p1pll->lcd_pll_out_max = p1pll->pll_out_max; 819771fe6b9SJerome Glisse 820771fe6b9SJerome Glisse if (rev > 9) { 821771fe6b9SJerome Glisse p1pll->pll_in_min = RBIOS32(pll_info + 0x36); 822771fe6b9SJerome Glisse p1pll->pll_in_max = RBIOS32(pll_info + 0x3a); 823771fe6b9SJerome Glisse } else { 824771fe6b9SJerome Glisse p1pll->pll_in_min = 40; 825771fe6b9SJerome Glisse p1pll->pll_in_max = 500; 826771fe6b9SJerome Glisse } 827771fe6b9SJerome Glisse *p2pll = *p1pll; 828771fe6b9SJerome Glisse 829771fe6b9SJerome Glisse /* system clock */ 830771fe6b9SJerome Glisse spll->reference_freq = RBIOS16(pll_info + 0x1a); 831771fe6b9SJerome Glisse spll->reference_div = RBIOS16(pll_info + 0x1c); 832771fe6b9SJerome Glisse spll->pll_out_min = RBIOS32(pll_info + 0x1e); 833771fe6b9SJerome Glisse spll->pll_out_max = RBIOS32(pll_info + 0x22); 834771fe6b9SJerome Glisse 835771fe6b9SJerome Glisse if (rev > 10) { 836771fe6b9SJerome Glisse spll->pll_in_min = RBIOS32(pll_info + 0x48); 837771fe6b9SJerome Glisse spll->pll_in_max = RBIOS32(pll_info + 0x4c); 838771fe6b9SJerome Glisse } else { 839771fe6b9SJerome Glisse /* ??? */ 840771fe6b9SJerome Glisse spll->pll_in_min = 40; 841771fe6b9SJerome Glisse spll->pll_in_max = 500; 842771fe6b9SJerome Glisse } 843771fe6b9SJerome Glisse 844771fe6b9SJerome Glisse /* memory clock */ 845771fe6b9SJerome Glisse mpll->reference_freq = RBIOS16(pll_info + 0x26); 846771fe6b9SJerome Glisse mpll->reference_div = RBIOS16(pll_info + 0x28); 847771fe6b9SJerome Glisse mpll->pll_out_min = RBIOS32(pll_info + 0x2a); 848771fe6b9SJerome Glisse mpll->pll_out_max = RBIOS32(pll_info + 0x2e); 849771fe6b9SJerome Glisse 850771fe6b9SJerome Glisse if (rev > 10) { 851771fe6b9SJerome Glisse mpll->pll_in_min = RBIOS32(pll_info + 0x5a); 852771fe6b9SJerome Glisse mpll->pll_in_max = RBIOS32(pll_info + 0x5e); 853771fe6b9SJerome Glisse } else { 854771fe6b9SJerome Glisse /* ??? */ 855771fe6b9SJerome Glisse mpll->pll_in_min = 40; 856771fe6b9SJerome Glisse mpll->pll_in_max = 500; 857771fe6b9SJerome Glisse } 858771fe6b9SJerome Glisse 859771fe6b9SJerome Glisse /* default sclk/mclk */ 860771fe6b9SJerome Glisse sclk = RBIOS16(pll_info + 0xa); 861771fe6b9SJerome Glisse mclk = RBIOS16(pll_info + 0x8); 862771fe6b9SJerome Glisse if (sclk == 0) 863771fe6b9SJerome Glisse sclk = 200 * 100; 864771fe6b9SJerome Glisse if (mclk == 0) 865771fe6b9SJerome Glisse mclk = 200 * 100; 866771fe6b9SJerome Glisse 867771fe6b9SJerome Glisse rdev->clock.default_sclk = sclk; 868771fe6b9SJerome Glisse rdev->clock.default_mclk = mclk; 869771fe6b9SJerome Glisse 870b20f9befSAlex Deucher if (RBIOS32(pll_info + 0x16)) 871b20f9befSAlex Deucher rdev->clock.max_pixel_clock = RBIOS32(pll_info + 0x16); 872b20f9befSAlex Deucher else 873b20f9befSAlex Deucher rdev->clock.max_pixel_clock = 35000; /* might need something asic specific */ 874b20f9befSAlex Deucher 875771fe6b9SJerome Glisse return true; 876771fe6b9SJerome Glisse } 877771fe6b9SJerome Glisse return false; 878771fe6b9SJerome Glisse } 879771fe6b9SJerome Glisse 88006b6476dSAlex Deucher bool radeon_combios_sideport_present(struct radeon_device *rdev) 88106b6476dSAlex Deucher { 88206b6476dSAlex Deucher struct drm_device *dev = rdev->ddev; 88306b6476dSAlex Deucher u16 igp_info; 88406b6476dSAlex Deucher 8854c70b2eaSAlex Deucher /* sideport is AMD only */ 8864c70b2eaSAlex Deucher if (rdev->family == CHIP_RS400) 8874c70b2eaSAlex Deucher return false; 8884c70b2eaSAlex Deucher 88906b6476dSAlex Deucher igp_info = combios_get_table_offset(dev, COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE); 89006b6476dSAlex Deucher 89106b6476dSAlex Deucher if (igp_info) { 89206b6476dSAlex Deucher if (RBIOS16(igp_info + 0x4)) 89306b6476dSAlex Deucher return true; 89406b6476dSAlex Deucher } 89506b6476dSAlex Deucher return false; 89606b6476dSAlex Deucher } 89706b6476dSAlex Deucher 898246263ccSAlex Deucher static const uint32_t default_primarydac_adj[CHIP_LAST] = { 899246263ccSAlex Deucher 0x00000808, /* r100 */ 900246263ccSAlex Deucher 0x00000808, /* rv100 */ 901246263ccSAlex Deucher 0x00000808, /* rs100 */ 902246263ccSAlex Deucher 0x00000808, /* rv200 */ 903246263ccSAlex Deucher 0x00000808, /* rs200 */ 904246263ccSAlex Deucher 0x00000808, /* r200 */ 905246263ccSAlex Deucher 0x00000808, /* rv250 */ 906246263ccSAlex Deucher 0x00000000, /* rs300 */ 907246263ccSAlex Deucher 0x00000808, /* rv280 */ 908246263ccSAlex Deucher 0x00000808, /* r300 */ 909246263ccSAlex Deucher 0x00000808, /* r350 */ 910246263ccSAlex Deucher 0x00000808, /* rv350 */ 911246263ccSAlex Deucher 0x00000808, /* rv380 */ 912246263ccSAlex Deucher 0x00000808, /* r420 */ 913246263ccSAlex Deucher 0x00000808, /* r423 */ 914246263ccSAlex Deucher 0x00000808, /* rv410 */ 915246263ccSAlex Deucher 0x00000000, /* rs400 */ 916246263ccSAlex Deucher 0x00000000, /* rs480 */ 917246263ccSAlex Deucher }; 918246263ccSAlex Deucher 919246263ccSAlex Deucher static void radeon_legacy_get_primary_dac_info_from_table(struct radeon_device *rdev, 920246263ccSAlex Deucher struct radeon_encoder_primary_dac *p_dac) 921246263ccSAlex Deucher { 922246263ccSAlex Deucher p_dac->ps2_pdac_adj = default_primarydac_adj[rdev->family]; 923246263ccSAlex Deucher return; 924246263ccSAlex Deucher } 925246263ccSAlex Deucher 926771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct 927771fe6b9SJerome Glisse radeon_encoder 928771fe6b9SJerome Glisse *encoder) 929771fe6b9SJerome Glisse { 930771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 931771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 932771fe6b9SJerome Glisse uint16_t dac_info; 933771fe6b9SJerome Glisse uint8_t rev, bg, dac; 934771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *p_dac = NULL; 935246263ccSAlex Deucher int found = 0; 936771fe6b9SJerome Glisse 937246263ccSAlex Deucher p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), 938771fe6b9SJerome Glisse GFP_KERNEL); 939771fe6b9SJerome Glisse 940771fe6b9SJerome Glisse if (!p_dac) 941771fe6b9SJerome Glisse return NULL; 942771fe6b9SJerome Glisse 943246263ccSAlex Deucher /* check CRT table */ 944246263ccSAlex Deucher dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 945246263ccSAlex Deucher if (dac_info) { 946771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 947771fe6b9SJerome Glisse if (rev < 2) { 948771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 949771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf; 950771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 951771fe6b9SJerome Glisse } else { 952771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 953771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x3) & 0xf; 954771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 955771fe6b9SJerome Glisse } 9563a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 9573a89b4a9SAlex Deucher if (p_dac->ps2_pdac_adj) 958246263ccSAlex Deucher found = 1; 959771fe6b9SJerome Glisse } 960771fe6b9SJerome Glisse 961246263ccSAlex Deucher if (!found) /* fallback to defaults */ 962246263ccSAlex Deucher radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac); 963246263ccSAlex Deucher 964771fe6b9SJerome Glisse return p_dac; 965771fe6b9SJerome Glisse } 966771fe6b9SJerome Glisse 967d79766faSAlex Deucher enum radeon_tv_std 968d79766faSAlex Deucher radeon_combios_get_tv_info(struct radeon_device *rdev) 969771fe6b9SJerome Glisse { 970d79766faSAlex Deucher struct drm_device *dev = rdev->ddev; 971771fe6b9SJerome Glisse uint16_t tv_info; 972771fe6b9SJerome Glisse enum radeon_tv_std tv_std = TV_STD_NTSC; 973771fe6b9SJerome Glisse 974771fe6b9SJerome Glisse tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 975771fe6b9SJerome Glisse if (tv_info) { 976771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 977771fe6b9SJerome Glisse switch (RBIOS8(tv_info + 7) & 0xf) { 978771fe6b9SJerome Glisse case 1: 979771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 98040f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: NTSC\n"); 981771fe6b9SJerome Glisse break; 982771fe6b9SJerome Glisse case 2: 983771fe6b9SJerome Glisse tv_std = TV_STD_PAL; 98440f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL\n"); 985771fe6b9SJerome Glisse break; 986771fe6b9SJerome Glisse case 3: 987771fe6b9SJerome Glisse tv_std = TV_STD_PAL_M; 98840f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL-M\n"); 989771fe6b9SJerome Glisse break; 990771fe6b9SJerome Glisse case 4: 991771fe6b9SJerome Glisse tv_std = TV_STD_PAL_60; 99240f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL-60\n"); 993771fe6b9SJerome Glisse break; 994771fe6b9SJerome Glisse case 5: 995771fe6b9SJerome Glisse tv_std = TV_STD_NTSC_J; 99640f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: NTSC-J\n"); 997771fe6b9SJerome Glisse break; 998771fe6b9SJerome Glisse case 6: 999771fe6b9SJerome Glisse tv_std = TV_STD_SCART_PAL; 100040f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: SCART-PAL\n"); 1001771fe6b9SJerome Glisse break; 1002771fe6b9SJerome Glisse default: 1003771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 100440f76d81SAlex Deucher DRM_DEBUG_KMS 1005771fe6b9SJerome Glisse ("Unknown TV standard; defaulting to NTSC\n"); 1006771fe6b9SJerome Glisse break; 1007771fe6b9SJerome Glisse } 1008771fe6b9SJerome Glisse 1009771fe6b9SJerome Glisse switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) { 1010771fe6b9SJerome Glisse case 0: 101140f76d81SAlex Deucher DRM_DEBUG_KMS("29.498928713 MHz TV ref clk\n"); 1012771fe6b9SJerome Glisse break; 1013771fe6b9SJerome Glisse case 1: 101440f76d81SAlex Deucher DRM_DEBUG_KMS("28.636360000 MHz TV ref clk\n"); 1015771fe6b9SJerome Glisse break; 1016771fe6b9SJerome Glisse case 2: 101740f76d81SAlex Deucher DRM_DEBUG_KMS("14.318180000 MHz TV ref clk\n"); 1018771fe6b9SJerome Glisse break; 1019771fe6b9SJerome Glisse case 3: 102040f76d81SAlex Deucher DRM_DEBUG_KMS("27.000000000 MHz TV ref clk\n"); 1021771fe6b9SJerome Glisse break; 1022771fe6b9SJerome Glisse default: 1023771fe6b9SJerome Glisse break; 1024771fe6b9SJerome Glisse } 1025771fe6b9SJerome Glisse } 1026771fe6b9SJerome Glisse } 1027771fe6b9SJerome Glisse return tv_std; 1028771fe6b9SJerome Glisse } 1029771fe6b9SJerome Glisse 1030771fe6b9SJerome Glisse static const uint32_t default_tvdac_adj[CHIP_LAST] = { 1031771fe6b9SJerome Glisse 0x00000000, /* r100 */ 1032771fe6b9SJerome Glisse 0x00280000, /* rv100 */ 1033771fe6b9SJerome Glisse 0x00000000, /* rs100 */ 1034771fe6b9SJerome Glisse 0x00880000, /* rv200 */ 1035771fe6b9SJerome Glisse 0x00000000, /* rs200 */ 1036771fe6b9SJerome Glisse 0x00000000, /* r200 */ 1037771fe6b9SJerome Glisse 0x00770000, /* rv250 */ 1038771fe6b9SJerome Glisse 0x00290000, /* rs300 */ 1039771fe6b9SJerome Glisse 0x00560000, /* rv280 */ 1040771fe6b9SJerome Glisse 0x00780000, /* r300 */ 1041771fe6b9SJerome Glisse 0x00770000, /* r350 */ 1042771fe6b9SJerome Glisse 0x00780000, /* rv350 */ 1043771fe6b9SJerome Glisse 0x00780000, /* rv380 */ 1044771fe6b9SJerome Glisse 0x01080000, /* r420 */ 1045771fe6b9SJerome Glisse 0x01080000, /* r423 */ 1046771fe6b9SJerome Glisse 0x01080000, /* rv410 */ 1047771fe6b9SJerome Glisse 0x00780000, /* rs400 */ 1048771fe6b9SJerome Glisse 0x00780000, /* rs480 */ 1049771fe6b9SJerome Glisse }; 1050771fe6b9SJerome Glisse 10516a719e05SDave Airlie static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev, 10526a719e05SDave Airlie struct radeon_encoder_tv_dac *tv_dac) 1053771fe6b9SJerome Glisse { 1054771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; 1055771fe6b9SJerome Glisse if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) 1056771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 0x00880000; 1057771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1058771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10596a719e05SDave Airlie return; 1060771fe6b9SJerome Glisse } 1061771fe6b9SJerome Glisse 1062771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct 1063771fe6b9SJerome Glisse radeon_encoder 1064771fe6b9SJerome Glisse *encoder) 1065771fe6b9SJerome Glisse { 1066771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1067771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1068771fe6b9SJerome Glisse uint16_t dac_info; 1069771fe6b9SJerome Glisse uint8_t rev, bg, dac; 1070771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *tv_dac = NULL; 10716a719e05SDave Airlie int found = 0; 10726a719e05SDave Airlie 10736a719e05SDave Airlie tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); 10746a719e05SDave Airlie if (!tv_dac) 10756a719e05SDave Airlie return NULL; 1076771fe6b9SJerome Glisse 1077771fe6b9SJerome Glisse /* first check TV table */ 1078771fe6b9SJerome Glisse dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 1079771fe6b9SJerome Glisse if (dac_info) { 1080771fe6b9SJerome Glisse rev = RBIOS8(dac_info + 0x3); 1081771fe6b9SJerome Glisse if (rev > 4) { 1082771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 1083771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xd) & 0xf; 1084771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 1085771fe6b9SJerome Glisse 1086771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 1087771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xf) & 0xf; 1088771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 1089771fe6b9SJerome Glisse 1090771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x10) & 0xf; 1091771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x11) & 0xf; 1092771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 10933a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10943a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10956a719e05SDave Airlie found = 1; 1096771fe6b9SJerome Glisse } else if (rev > 1) { 1097771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 1098771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; 1099771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 1100771fe6b9SJerome Glisse 1101771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xd) & 0xf; 1102771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf; 1103771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 1104771fe6b9SJerome Glisse 1105771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 1106771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; 1107771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 11083a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 11093a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 11106a719e05SDave Airlie found = 1; 1111771fe6b9SJerome Glisse } 1112d79766faSAlex Deucher tv_dac->tv_std = radeon_combios_get_tv_info(rdev); 11136a719e05SDave Airlie } 11146a719e05SDave Airlie if (!found) { 1115771fe6b9SJerome Glisse /* then check CRT table */ 1116771fe6b9SJerome Glisse dac_info = 1117771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 1118771fe6b9SJerome Glisse if (dac_info) { 1119771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 1120771fe6b9SJerome Glisse if (rev < 2) { 1121771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x3) & 0xf; 1122771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf; 1123771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 1124771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 1125771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1126771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 11273a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 11283a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 11296a719e05SDave Airlie found = 1; 1130771fe6b9SJerome Glisse } else { 1131771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x4) & 0xf; 1132771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x5) & 0xf; 1133771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 1134771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 1135771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1136771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 11373a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 11383a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 11396a719e05SDave Airlie found = 1; 1140771fe6b9SJerome Glisse } 11416fe7ac3fSAlex Deucher } else { 11426fe7ac3fSAlex Deucher DRM_INFO("No TV DAC info found in BIOS\n"); 1143771fe6b9SJerome Glisse } 1144771fe6b9SJerome Glisse } 1145771fe6b9SJerome Glisse 11466a719e05SDave Airlie if (!found) /* fallback to defaults */ 11476a719e05SDave Airlie radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac); 11486a719e05SDave Airlie 1149771fe6b9SJerome Glisse return tv_dac; 1150771fe6b9SJerome Glisse } 1151771fe6b9SJerome Glisse 1152771fe6b9SJerome Glisse static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct 1153771fe6b9SJerome Glisse radeon_device 1154771fe6b9SJerome Glisse *rdev) 1155771fe6b9SJerome Glisse { 1156771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 1157771fe6b9SJerome Glisse uint32_t fp_vert_stretch, fp_horz_stretch; 1158771fe6b9SJerome Glisse uint32_t ppll_div_sel, ppll_val; 11598b5c7444SMichel Dänzer uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL); 1160771fe6b9SJerome Glisse 1161771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 1162771fe6b9SJerome Glisse 1163771fe6b9SJerome Glisse if (!lvds) 1164771fe6b9SJerome Glisse return NULL; 1165771fe6b9SJerome Glisse 1166771fe6b9SJerome Glisse fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH); 1167771fe6b9SJerome Glisse fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH); 1168771fe6b9SJerome Glisse 11698b5c7444SMichel Dänzer /* These should be fail-safe defaults, fingers crossed */ 11708b5c7444SMichel Dänzer lvds->panel_pwr_delay = 200; 11718b5c7444SMichel Dänzer lvds->panel_vcc_delay = 2000; 11728b5c7444SMichel Dänzer 11738b5c7444SMichel Dänzer lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL); 11748b5c7444SMichel Dänzer lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf; 11758b5c7444SMichel Dänzer lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf; 11768b5c7444SMichel Dänzer 1177771fe6b9SJerome Glisse if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE) 1178de2103e4SAlex Deucher lvds->native_mode.vdisplay = 1179771fe6b9SJerome Glisse ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >> 1180771fe6b9SJerome Glisse RADEON_VERT_PANEL_SHIFT) + 1; 1181771fe6b9SJerome Glisse else 1182de2103e4SAlex Deucher lvds->native_mode.vdisplay = 1183771fe6b9SJerome Glisse (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1; 1184771fe6b9SJerome Glisse 1185771fe6b9SJerome Glisse if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE) 1186de2103e4SAlex Deucher lvds->native_mode.hdisplay = 1187771fe6b9SJerome Glisse (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >> 1188771fe6b9SJerome Glisse RADEON_HORZ_PANEL_SHIFT) + 1) * 8; 1189771fe6b9SJerome Glisse else 1190de2103e4SAlex Deucher lvds->native_mode.hdisplay = 1191771fe6b9SJerome Glisse ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8; 1192771fe6b9SJerome Glisse 1193de2103e4SAlex Deucher if ((lvds->native_mode.hdisplay < 640) || 1194de2103e4SAlex Deucher (lvds->native_mode.vdisplay < 480)) { 1195de2103e4SAlex Deucher lvds->native_mode.hdisplay = 640; 1196de2103e4SAlex Deucher lvds->native_mode.vdisplay = 480; 1197771fe6b9SJerome Glisse } 1198771fe6b9SJerome Glisse 1199771fe6b9SJerome Glisse ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3; 1200771fe6b9SJerome Glisse ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel); 1201771fe6b9SJerome Glisse if ((ppll_val & 0x000707ff) == 0x1bb) 1202771fe6b9SJerome Glisse lvds->use_bios_dividers = false; 1203771fe6b9SJerome Glisse else { 1204771fe6b9SJerome Glisse lvds->panel_ref_divider = 1205771fe6b9SJerome Glisse RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff; 1206771fe6b9SJerome Glisse lvds->panel_post_divider = (ppll_val >> 16) & 0x7; 1207771fe6b9SJerome Glisse lvds->panel_fb_divider = ppll_val & 0x7ff; 1208771fe6b9SJerome Glisse 1209771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1210771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1211771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1212771fe6b9SJerome Glisse } 1213771fe6b9SJerome Glisse lvds->panel_vcc_delay = 200; 1214771fe6b9SJerome Glisse 1215771fe6b9SJerome Glisse DRM_INFO("Panel info derived from registers\n"); 1216de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1217de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1218771fe6b9SJerome Glisse 1219771fe6b9SJerome Glisse return lvds; 1220771fe6b9SJerome Glisse } 1221771fe6b9SJerome Glisse 1222771fe6b9SJerome Glisse struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder 1223771fe6b9SJerome Glisse *encoder) 1224771fe6b9SJerome Glisse { 1225771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1226771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1227771fe6b9SJerome Glisse uint16_t lcd_info; 1228771fe6b9SJerome Glisse uint32_t panel_setup; 1229771fe6b9SJerome Glisse char stmp[30]; 1230771fe6b9SJerome Glisse int tmp, i; 1231771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 1232771fe6b9SJerome Glisse 1233771fe6b9SJerome Glisse lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 1234771fe6b9SJerome Glisse 1235771fe6b9SJerome Glisse if (lcd_info) { 1236771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 1237771fe6b9SJerome Glisse 1238771fe6b9SJerome Glisse if (!lvds) 1239771fe6b9SJerome Glisse return NULL; 1240771fe6b9SJerome Glisse 1241771fe6b9SJerome Glisse for (i = 0; i < 24; i++) 1242771fe6b9SJerome Glisse stmp[i] = RBIOS8(lcd_info + i + 1); 1243771fe6b9SJerome Glisse stmp[24] = 0; 1244771fe6b9SJerome Glisse 1245771fe6b9SJerome Glisse DRM_INFO("Panel ID String: %s\n", stmp); 1246771fe6b9SJerome Glisse 1247de2103e4SAlex Deucher lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19); 1248de2103e4SAlex Deucher lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b); 1249771fe6b9SJerome Glisse 1250de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1251de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1252771fe6b9SJerome Glisse 1253771fe6b9SJerome Glisse lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c); 125494cf6434SAndrew Morton lvds->panel_vcc_delay = min_t(u16, lvds->panel_vcc_delay, 2000); 1255771fe6b9SJerome Glisse 1256771fe6b9SJerome Glisse lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24); 1257771fe6b9SJerome Glisse lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf; 1258771fe6b9SJerome Glisse lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf; 1259771fe6b9SJerome Glisse 1260771fe6b9SJerome Glisse lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e); 1261771fe6b9SJerome Glisse lvds->panel_post_divider = RBIOS8(lcd_info + 0x30); 1262771fe6b9SJerome Glisse lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31); 1263771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1264771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1265771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1266771fe6b9SJerome Glisse 1267771fe6b9SJerome Glisse panel_setup = RBIOS32(lcd_info + 0x39); 1268771fe6b9SJerome Glisse lvds->lvds_gen_cntl = 0xff00; 1269771fe6b9SJerome Glisse if (panel_setup & 0x1) 1270771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT; 1271771fe6b9SJerome Glisse 1272771fe6b9SJerome Glisse if ((panel_setup >> 4) & 0x1) 1273771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE; 1274771fe6b9SJerome Glisse 1275771fe6b9SJerome Glisse switch ((panel_setup >> 8) & 0x7) { 1276771fe6b9SJerome Glisse case 0: 1277771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM; 1278771fe6b9SJerome Glisse break; 1279771fe6b9SJerome Glisse case 1: 1280771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY; 1281771fe6b9SJerome Glisse break; 1282771fe6b9SJerome Glisse case 2: 1283771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY; 1284771fe6b9SJerome Glisse break; 1285771fe6b9SJerome Glisse default: 1286771fe6b9SJerome Glisse break; 1287771fe6b9SJerome Glisse } 1288771fe6b9SJerome Glisse 1289771fe6b9SJerome Glisse if ((panel_setup >> 16) & 0x1) 1290771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW; 1291771fe6b9SJerome Glisse 1292771fe6b9SJerome Glisse if ((panel_setup >> 17) & 0x1) 1293771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW; 1294771fe6b9SJerome Glisse 1295771fe6b9SJerome Glisse if ((panel_setup >> 18) & 0x1) 1296771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW; 1297771fe6b9SJerome Glisse 1298771fe6b9SJerome Glisse if ((panel_setup >> 23) & 0x1) 1299771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL; 1300771fe6b9SJerome Glisse 1301771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000); 1302771fe6b9SJerome Glisse 1303771fe6b9SJerome Glisse for (i = 0; i < 32; i++) { 1304771fe6b9SJerome Glisse tmp = RBIOS16(lcd_info + 64 + i * 2); 1305771fe6b9SJerome Glisse if (tmp == 0) 1306771fe6b9SJerome Glisse break; 1307771fe6b9SJerome Glisse 1308de2103e4SAlex Deucher if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) && 130968b61a7fSAlex Deucher (RBIOS16(tmp + 2) == lvds->native_mode.vdisplay)) { 131068b61a7fSAlex Deucher lvds->native_mode.htotal = lvds->native_mode.hdisplay + 131168b61a7fSAlex Deucher (RBIOS16(tmp + 17) - RBIOS16(tmp + 19)) * 8; 131268b61a7fSAlex Deucher lvds->native_mode.hsync_start = lvds->native_mode.hdisplay + 131368b61a7fSAlex Deucher (RBIOS16(tmp + 21) - RBIOS16(tmp + 19) - 1) * 8; 131468b61a7fSAlex Deucher lvds->native_mode.hsync_end = lvds->native_mode.hsync_start + 131568b61a7fSAlex Deucher (RBIOS8(tmp + 23) * 8); 1316771fe6b9SJerome Glisse 131768b61a7fSAlex Deucher lvds->native_mode.vtotal = lvds->native_mode.vdisplay + 131868b61a7fSAlex Deucher (RBIOS16(tmp + 24) - RBIOS16(tmp + 26)); 131968b61a7fSAlex Deucher lvds->native_mode.vsync_start = lvds->native_mode.vdisplay + 132068b61a7fSAlex Deucher ((RBIOS16(tmp + 28) & 0x7ff) - RBIOS16(tmp + 26)); 132168b61a7fSAlex Deucher lvds->native_mode.vsync_end = lvds->native_mode.vsync_start + 132268b61a7fSAlex Deucher ((RBIOS16(tmp + 28) & 0xf800) >> 11); 1323de2103e4SAlex Deucher 1324de2103e4SAlex Deucher lvds->native_mode.clock = RBIOS16(tmp + 9) * 10; 1325771fe6b9SJerome Glisse lvds->native_mode.flags = 0; 1326de2103e4SAlex Deucher /* set crtc values */ 1327de2103e4SAlex Deucher drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V); 1328de2103e4SAlex Deucher 1329771fe6b9SJerome Glisse } 1330771fe6b9SJerome Glisse } 13316fe7ac3fSAlex Deucher } else { 1332771fe6b9SJerome Glisse DRM_INFO("No panel info found in BIOS\n"); 13338dfaa8a7SMichel Dänzer lvds = radeon_legacy_get_lvds_info_from_regs(rdev); 13346fe7ac3fSAlex Deucher } 133503047cdfSMichel Dänzer 13368dfaa8a7SMichel Dänzer if (lvds) 13378dfaa8a7SMichel Dänzer encoder->native_mode = lvds->native_mode; 1338771fe6b9SJerome Glisse return lvds; 1339771fe6b9SJerome Glisse } 1340771fe6b9SJerome Glisse 1341771fe6b9SJerome Glisse static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = { 1342771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */ 1343771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */ 1344771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */ 1345771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */ 1346771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */ 1347771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */ 1348771fe6b9SJerome Glisse {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */ 1349771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */ 1350771fe6b9SJerome Glisse {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */ 1351771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */ 1352771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */ 1353771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */ 1354771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */ 1355771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */ 1356771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */ 1357771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */ 1358fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */ 1359fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */ 1360771fe6b9SJerome Glisse }; 1361771fe6b9SJerome Glisse 1362445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder, 1363445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1364771fe6b9SJerome Glisse { 1365445282dbSDave Airlie struct drm_device *dev = encoder->base.dev; 1366445282dbSDave Airlie struct radeon_device *rdev = dev->dev_private; 1367771fe6b9SJerome Glisse int i; 1368771fe6b9SJerome Glisse 1369771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 1370771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1371771fe6b9SJerome Glisse default_tmds_pll[rdev->family][i].value; 1372771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq; 1373771fe6b9SJerome Glisse } 1374771fe6b9SJerome Glisse 1375445282dbSDave Airlie return true; 1376771fe6b9SJerome Glisse } 1377771fe6b9SJerome Glisse 1378445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder, 1379445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1380771fe6b9SJerome Glisse { 1381771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1382771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1383771fe6b9SJerome Glisse uint16_t tmds_info; 1384771fe6b9SJerome Glisse int i, n; 1385771fe6b9SJerome Glisse uint8_t ver; 1386771fe6b9SJerome Glisse 1387771fe6b9SJerome Glisse tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 1388771fe6b9SJerome Glisse 1389771fe6b9SJerome Glisse if (tmds_info) { 1390771fe6b9SJerome Glisse ver = RBIOS8(tmds_info); 139140f76d81SAlex Deucher DRM_DEBUG_KMS("DFP table revision: %d\n", ver); 1392771fe6b9SJerome Glisse if (ver == 3) { 1393771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1394771fe6b9SJerome Glisse if (n > 4) 1395771fe6b9SJerome Glisse n = 4; 1396771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1397771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1398771fe6b9SJerome Glisse RBIOS32(tmds_info + i * 10 + 0x08); 1399771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1400771fe6b9SJerome Glisse RBIOS16(tmds_info + i * 10 + 0x10); 1401d9fdaafbSDave Airlie DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", 1402771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1403771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1404771fe6b9SJerome Glisse } 1405771fe6b9SJerome Glisse } else if (ver == 4) { 1406771fe6b9SJerome Glisse int stride = 0; 1407771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1408771fe6b9SJerome Glisse if (n > 4) 1409771fe6b9SJerome Glisse n = 4; 1410771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1411771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1412771fe6b9SJerome Glisse RBIOS32(tmds_info + stride + 0x08); 1413771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1414771fe6b9SJerome Glisse RBIOS16(tmds_info + stride + 0x10); 1415771fe6b9SJerome Glisse if (i == 0) 1416771fe6b9SJerome Glisse stride += 10; 1417771fe6b9SJerome Glisse else 1418771fe6b9SJerome Glisse stride += 6; 1419d9fdaafbSDave Airlie DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", 1420771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1421771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1422771fe6b9SJerome Glisse } 1423771fe6b9SJerome Glisse } 1424fcec570bSAlex Deucher } else { 1425771fe6b9SJerome Glisse DRM_INFO("No TMDS info found in BIOS\n"); 1426fcec570bSAlex Deucher return false; 1427fcec570bSAlex Deucher } 1428445282dbSDave Airlie return true; 1429445282dbSDave Airlie } 1430445282dbSDave Airlie 1431fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder, 1432fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1433771fe6b9SJerome Glisse { 1434771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1435771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1436fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1437fcec570bSAlex Deucher 1438fcec570bSAlex Deucher /* default for macs */ 1439179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1440f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1441fcec570bSAlex Deucher 1442fcec570bSAlex Deucher /* XXX some macs have duallink chips */ 1443fcec570bSAlex Deucher switch (rdev->mode_info.connector_table) { 1444fcec570bSAlex Deucher case CT_POWERBOOK_EXTERNAL: 1445fcec570bSAlex Deucher case CT_MINI_EXTERNAL: 1446fcec570bSAlex Deucher default: 1447fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1448fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1449fcec570bSAlex Deucher break; 1450fcec570bSAlex Deucher } 1451fcec570bSAlex Deucher 1452fcec570bSAlex Deucher return true; 1453fcec570bSAlex Deucher } 1454fcec570bSAlex Deucher 1455fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder, 1456fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1457fcec570bSAlex Deucher { 1458fcec570bSAlex Deucher struct drm_device *dev = encoder->base.dev; 1459fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 1460fcec570bSAlex Deucher uint16_t offset; 1461179e8078SAlex Deucher uint8_t ver; 1462fcec570bSAlex Deucher enum radeon_combios_ddc gpio; 1463fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1464771fe6b9SJerome Glisse 1465fcec570bSAlex Deucher tmds->i2c_bus = NULL; 1466fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 1467179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1468f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1469fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1470fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1471fcec570bSAlex Deucher } else { 1472fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 1473fcec570bSAlex Deucher if (offset) { 1474fcec570bSAlex Deucher ver = RBIOS8(offset); 147540f76d81SAlex Deucher DRM_DEBUG_KMS("External TMDS Table revision: %d\n", ver); 1476fcec570bSAlex Deucher tmds->slave_addr = RBIOS8(offset + 4 + 2); 1477fcec570bSAlex Deucher tmds->slave_addr >>= 1; /* 7 bit addressing */ 1478fcec570bSAlex Deucher gpio = RBIOS8(offset + 4 + 3); 1479179e8078SAlex Deucher if (gpio == DDC_LCD) { 1480179e8078SAlex Deucher /* MM i2c */ 148140bacf16SAlex Deucher i2c_bus.valid = true; 148240bacf16SAlex Deucher i2c_bus.hw_capable = true; 148340bacf16SAlex Deucher i2c_bus.mm_i2c = true; 1484179e8078SAlex Deucher i2c_bus.i2c_id = 0xa0; 1485179e8078SAlex Deucher } else 1486179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0); 1487f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1488fcec570bSAlex Deucher } 1489fcec570bSAlex Deucher } 1490fcec570bSAlex Deucher 1491fcec570bSAlex Deucher if (!tmds->i2c_bus) { 1492fcec570bSAlex Deucher DRM_INFO("No valid Ext TMDS info found in BIOS\n"); 1493fcec570bSAlex Deucher return false; 1494fcec570bSAlex Deucher } 1495fcec570bSAlex Deucher 1496fcec570bSAlex Deucher return true; 1497fcec570bSAlex Deucher } 1498771fe6b9SJerome Glisse 1499771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) 1500771fe6b9SJerome Glisse { 1501771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1502771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 1503eed45b30SAlex Deucher struct radeon_hpd hpd; 1504771fe6b9SJerome Glisse 1505771fe6b9SJerome Glisse rdev->mode_info.connector_table = radeon_connector_table; 1506771fe6b9SJerome Glisse if (rdev->mode_info.connector_table == CT_NONE) { 1507771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 150871a157e8SGrant Likely if (of_machine_is_compatible("PowerBook3,3")) { 1509771fe6b9SJerome Glisse /* powerbook with VGA */ 1510771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_VGA; 151171a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook3,4") || 151271a157e8SGrant Likely of_machine_is_compatible("PowerBook3,5")) { 1513771fe6b9SJerome Glisse /* powerbook with internal tmds */ 1514771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; 151571a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,1") || 151671a157e8SGrant Likely of_machine_is_compatible("PowerBook5,2") || 151771a157e8SGrant Likely of_machine_is_compatible("PowerBook5,3") || 151871a157e8SGrant Likely of_machine_is_compatible("PowerBook5,4") || 151971a157e8SGrant Likely of_machine_is_compatible("PowerBook5,5")) { 1520771fe6b9SJerome Glisse /* powerbook with external single link tmds (sil164) */ 1521771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 152271a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,6")) { 1523771fe6b9SJerome Glisse /* powerbook with external dual or single link tmds */ 1524771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 152571a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,7") || 152671a157e8SGrant Likely of_machine_is_compatible("PowerBook5,8") || 152771a157e8SGrant Likely of_machine_is_compatible("PowerBook5,9")) { 1528771fe6b9SJerome Glisse /* PowerBook6,2 ? */ 1529771fe6b9SJerome Glisse /* powerbook with external dual link tmds (sil1178?) */ 1530771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 153171a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook4,1") || 153271a157e8SGrant Likely of_machine_is_compatible("PowerBook4,2") || 153371a157e8SGrant Likely of_machine_is_compatible("PowerBook4,3") || 153471a157e8SGrant Likely of_machine_is_compatible("PowerBook6,3") || 153571a157e8SGrant Likely of_machine_is_compatible("PowerBook6,5") || 153671a157e8SGrant Likely of_machine_is_compatible("PowerBook6,7")) { 1537771fe6b9SJerome Glisse /* ibook */ 1538771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IBOOK; 153971a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac4,4")) { 1540771fe6b9SJerome Glisse /* emac */ 1541771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_EMAC; 154271a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac10,1")) { 1543771fe6b9SJerome Glisse /* mini with internal tmds */ 1544771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_INTERNAL; 154571a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac10,2")) { 1546771fe6b9SJerome Glisse /* mini with external tmds */ 1547771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_EXTERNAL; 154871a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac12,1")) { 1549771fe6b9SJerome Glisse /* PowerMac8,1 ? */ 1550771fe6b9SJerome Glisse /* imac g5 isight */ 1551771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; 1552aa74fbb4SAlex Deucher } else if ((rdev->pdev->device == 0x4a48) && 1553aa74fbb4SAlex Deucher (rdev->pdev->subsystem_vendor == 0x1002) && 1554aa74fbb4SAlex Deucher (rdev->pdev->subsystem_device == 0x4a48)) { 1555aa74fbb4SAlex Deucher /* Mac X800 */ 1556aa74fbb4SAlex Deucher rdev->mode_info.connector_table = CT_MAC_X800; 15577c88d2b8SAlex Deucher } else if ((of_machine_is_compatible("PowerMac7,2") || 15587c88d2b8SAlex Deucher of_machine_is_compatible("PowerMac7,3")) && 15597c88d2b8SAlex Deucher (rdev->pdev->device == 0x4150) && 15607c88d2b8SAlex Deucher (rdev->pdev->subsystem_vendor == 0x1002) && 15617c88d2b8SAlex Deucher (rdev->pdev->subsystem_device == 0x4150)) { 15627c88d2b8SAlex Deucher /* Mac G5 tower 9600 */ 15639fad321aSAlex Deucher rdev->mode_info.connector_table = CT_MAC_G5_9600; 1564771fe6b9SJerome Glisse } else 1565771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 156676a7142aSDave Airlie #ifdef CONFIG_PPC64 156776a7142aSDave Airlie if (ASIC_IS_RN50(rdev)) 156876a7142aSDave Airlie rdev->mode_info.connector_table = CT_RN50_POWER; 156976a7142aSDave Airlie else 157076a7142aSDave Airlie #endif 1571771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_GENERIC; 1572771fe6b9SJerome Glisse } 1573771fe6b9SJerome Glisse 1574771fe6b9SJerome Glisse switch (rdev->mode_info.connector_table) { 1575771fe6b9SJerome Glisse case CT_GENERIC: 1576771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (generic)\n", 1577771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1578771fe6b9SJerome Glisse /* these are the most common settings */ 1579771fe6b9SJerome Glisse if (rdev->flags & RADEON_SINGLE_CRTC) { 1580771fe6b9SJerome Glisse /* VGA - primary dac */ 1581179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1582eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1583771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15845137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1585771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1586771fe6b9SJerome Glisse 1), 1587771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1588771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1589771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1590771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1591b75fad06SAlex Deucher &ddc_i2c, 1592eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1593eed45b30SAlex Deucher &hpd); 1594771fe6b9SJerome Glisse } else if (rdev->flags & RADEON_IS_MOBILITY) { 1595771fe6b9SJerome Glisse /* LVDS */ 1596179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_NONE_DETECTED, 0, 0); 1597eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1598771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15995137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1600771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1601771fe6b9SJerome Glisse 0), 1602771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1603771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1604771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1605771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 1606b75fad06SAlex Deucher &ddc_i2c, 1607eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1608eed45b30SAlex Deucher &hpd); 1609771fe6b9SJerome Glisse 1610771fe6b9SJerome Glisse /* VGA - primary dac */ 1611179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1612eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1613771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16145137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1615771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1616771fe6b9SJerome Glisse 1), 1617771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1618771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1619771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1620771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1621b75fad06SAlex Deucher &ddc_i2c, 1622eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1623eed45b30SAlex Deucher &hpd); 1624771fe6b9SJerome Glisse } else { 1625771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1626179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1627eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 1628771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16295137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1630771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1631771fe6b9SJerome Glisse 0), 1632771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1633771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16345137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1635771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1636771fe6b9SJerome Glisse 2), 1637771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1638771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1639771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1640771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1641771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 1642b75fad06SAlex Deucher &ddc_i2c, 1643eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1644eed45b30SAlex Deucher &hpd); 1645771fe6b9SJerome Glisse 1646771fe6b9SJerome Glisse /* VGA - primary dac */ 1647179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1648eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1649771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16505137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1651771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1652771fe6b9SJerome Glisse 1), 1653771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1654771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1655771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1656771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1657b75fad06SAlex Deucher &ddc_i2c, 1658eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1659eed45b30SAlex Deucher &hpd); 1660771fe6b9SJerome Glisse } 1661771fe6b9SJerome Glisse 1662771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 1663771fe6b9SJerome Glisse /* TV - tv dac */ 1664eed45b30SAlex Deucher ddc_i2c.valid = false; 1665eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1666771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16675137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1668771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1669771fe6b9SJerome Glisse 2), 1670771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1671771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, 1672771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1673771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1674b75fad06SAlex Deucher &ddc_i2c, 1675eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1676eed45b30SAlex Deucher &hpd); 1677771fe6b9SJerome Glisse } 1678771fe6b9SJerome Glisse break; 1679771fe6b9SJerome Glisse case CT_IBOOK: 1680771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (ibook)\n", 1681771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1682771fe6b9SJerome Glisse /* LVDS */ 1683179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1684eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1685771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16865137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1687771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1688771fe6b9SJerome Glisse 0), 1689771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1690771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1691b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1692eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1693eed45b30SAlex Deucher &hpd); 1694771fe6b9SJerome Glisse /* VGA - TV DAC */ 1695179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1696eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1697771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16985137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1699771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1700771fe6b9SJerome Glisse 2), 1701771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1702771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1703b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1704eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1705eed45b30SAlex Deucher &hpd); 1706771fe6b9SJerome Glisse /* TV - TV DAC */ 1707eed45b30SAlex Deucher ddc_i2c.valid = false; 1708eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1709771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17105137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1711771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1712771fe6b9SJerome Glisse 2), 1713771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1714771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1715771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1716b75fad06SAlex Deucher &ddc_i2c, 1717eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1718eed45b30SAlex Deucher &hpd); 1719771fe6b9SJerome Glisse break; 1720771fe6b9SJerome Glisse case CT_POWERBOOK_EXTERNAL: 1721771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook external tmds)\n", 1722771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1723771fe6b9SJerome Glisse /* LVDS */ 1724179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1725eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1726771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17275137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1728771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1729771fe6b9SJerome Glisse 0), 1730771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1731771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1732b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1733eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1734eed45b30SAlex Deucher &hpd); 1735771fe6b9SJerome Glisse /* DVI-I - primary dac, ext tmds */ 1736179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1737eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1738771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17395137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1740771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1741771fe6b9SJerome Glisse 0), 1742771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1743771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17445137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1745771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1746771fe6b9SJerome Glisse 1), 1747771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1748b75fad06SAlex Deucher /* XXX some are SL */ 1749771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1750771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1751771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1752b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1753eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 1754eed45b30SAlex Deucher &hpd); 1755771fe6b9SJerome Glisse /* TV - TV DAC */ 1756eed45b30SAlex Deucher ddc_i2c.valid = false; 1757eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1758771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17595137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1760771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1761771fe6b9SJerome Glisse 2), 1762771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1763771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1764771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1765b75fad06SAlex Deucher &ddc_i2c, 1766eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1767eed45b30SAlex Deucher &hpd); 1768771fe6b9SJerome Glisse break; 1769771fe6b9SJerome Glisse case CT_POWERBOOK_INTERNAL: 1770771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook internal tmds)\n", 1771771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1772771fe6b9SJerome Glisse /* LVDS */ 1773179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1774eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1775771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17765137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1777771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1778771fe6b9SJerome Glisse 0), 1779771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1780771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1781b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1782eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1783eed45b30SAlex Deucher &hpd); 1784771fe6b9SJerome Glisse /* DVI-I - primary dac, int tmds */ 1785179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1786eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1787771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17885137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1789771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1790771fe6b9SJerome Glisse 0), 1791771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1792771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17935137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1794771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1795771fe6b9SJerome Glisse 1), 1796771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1797771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1798771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1799771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1800b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1801eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1802eed45b30SAlex Deucher &hpd); 1803771fe6b9SJerome Glisse /* TV - TV DAC */ 1804eed45b30SAlex Deucher ddc_i2c.valid = false; 1805eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1806771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18075137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1808771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1809771fe6b9SJerome Glisse 2), 1810771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1811771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1812771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1813b75fad06SAlex Deucher &ddc_i2c, 1814eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1815eed45b30SAlex Deucher &hpd); 1816771fe6b9SJerome Glisse break; 1817771fe6b9SJerome Glisse case CT_POWERBOOK_VGA: 1818771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook vga)\n", 1819771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1820771fe6b9SJerome Glisse /* LVDS */ 1821179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1822eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1823771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18245137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1825771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1826771fe6b9SJerome Glisse 0), 1827771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1828771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1829b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1830eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1831eed45b30SAlex Deucher &hpd); 1832771fe6b9SJerome Glisse /* VGA - primary dac */ 1833179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1834eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1835771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18365137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1837771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1838771fe6b9SJerome Glisse 1), 1839771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1840771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT, 1841b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1842eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1843eed45b30SAlex Deucher &hpd); 1844771fe6b9SJerome Glisse /* TV - TV DAC */ 1845eed45b30SAlex Deucher ddc_i2c.valid = false; 1846eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1847771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18485137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1849771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1850771fe6b9SJerome Glisse 2), 1851771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1852771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1853771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1854b75fad06SAlex Deucher &ddc_i2c, 1855eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1856eed45b30SAlex Deucher &hpd); 1857771fe6b9SJerome Glisse break; 1858771fe6b9SJerome Glisse case CT_MINI_EXTERNAL: 1859771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini external tmds)\n", 1860771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1861771fe6b9SJerome Glisse /* DVI-I - tv dac, ext tmds */ 1862179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1863eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1864771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18655137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1866771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1867771fe6b9SJerome Glisse 0), 1868771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1869771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18705137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1871771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1872771fe6b9SJerome Glisse 2), 1873771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1874b75fad06SAlex Deucher /* XXX are any DL? */ 1875771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1876771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1877771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1878b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1879eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1880eed45b30SAlex Deucher &hpd); 1881771fe6b9SJerome Glisse /* TV - TV DAC */ 1882eed45b30SAlex Deucher ddc_i2c.valid = false; 1883eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1884771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18855137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1886771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1887771fe6b9SJerome Glisse 2), 1888771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1889771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1890771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1891b75fad06SAlex Deucher &ddc_i2c, 1892eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1893eed45b30SAlex Deucher &hpd); 1894771fe6b9SJerome Glisse break; 1895771fe6b9SJerome Glisse case CT_MINI_INTERNAL: 1896771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini internal tmds)\n", 1897771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1898771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1899179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1900eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1901771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19025137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1903771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1904771fe6b9SJerome Glisse 0), 1905771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1906771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19075137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1908771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1909771fe6b9SJerome Glisse 2), 1910771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1911771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1912771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1913771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1914b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1915eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1916eed45b30SAlex Deucher &hpd); 1917771fe6b9SJerome Glisse /* TV - TV DAC */ 1918eed45b30SAlex Deucher ddc_i2c.valid = false; 1919eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1920771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19215137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1922771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1923771fe6b9SJerome Glisse 2), 1924771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1925771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1926771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1927b75fad06SAlex Deucher &ddc_i2c, 1928eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1929eed45b30SAlex Deucher &hpd); 1930771fe6b9SJerome Glisse break; 1931771fe6b9SJerome Glisse case CT_IMAC_G5_ISIGHT: 1932771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (imac g5 isight)\n", 1933771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1934771fe6b9SJerome Glisse /* DVI-D - int tmds */ 1935179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1936eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1937771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19385137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1939771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1940771fe6b9SJerome Glisse 0), 1941771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1942771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT, 1943b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVID, &ddc_i2c, 1944eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 1945eed45b30SAlex Deucher &hpd); 1946771fe6b9SJerome Glisse /* VGA - tv dac */ 1947179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1948eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1949771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19505137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1951771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1952771fe6b9SJerome Glisse 2), 1953771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1954771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1955b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1956eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1957eed45b30SAlex Deucher &hpd); 1958771fe6b9SJerome Glisse /* TV - TV DAC */ 1959eed45b30SAlex Deucher ddc_i2c.valid = false; 1960eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1961771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19625137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1963771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1964771fe6b9SJerome Glisse 2), 1965771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1966771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1967771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1968b75fad06SAlex Deucher &ddc_i2c, 1969eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1970eed45b30SAlex Deucher &hpd); 1971771fe6b9SJerome Glisse break; 1972771fe6b9SJerome Glisse case CT_EMAC: 1973771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (emac)\n", 1974771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1975771fe6b9SJerome Glisse /* VGA - primary dac */ 1976179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1977eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1978771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19795137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1980771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1981771fe6b9SJerome Glisse 1), 1982771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1983771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 1984b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1985eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1986eed45b30SAlex Deucher &hpd); 1987771fe6b9SJerome Glisse /* VGA - tv dac */ 1988179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1989eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1990771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19915137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1992771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1993771fe6b9SJerome Glisse 2), 1994771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1995771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1996b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1997eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1998eed45b30SAlex Deucher &hpd); 1999771fe6b9SJerome Glisse /* TV - TV DAC */ 2000eed45b30SAlex Deucher ddc_i2c.valid = false; 2001eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2002771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 20035137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2004771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2005771fe6b9SJerome Glisse 2), 2006771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2007771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 2008771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 2009b75fad06SAlex Deucher &ddc_i2c, 2010eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2011eed45b30SAlex Deucher &hpd); 2012771fe6b9SJerome Glisse break; 201376a7142aSDave Airlie case CT_RN50_POWER: 201476a7142aSDave Airlie DRM_INFO("Connector Table: %d (rn50-power)\n", 201576a7142aSDave Airlie rdev->mode_info.connector_table); 201676a7142aSDave Airlie /* VGA - primary dac */ 2017179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 201876a7142aSDave Airlie hpd.hpd = RADEON_HPD_NONE; 201976a7142aSDave Airlie radeon_add_legacy_encoder(dev, 20205137ee94SAlex Deucher radeon_get_encoder_enum(dev, 202176a7142aSDave Airlie ATOM_DEVICE_CRT1_SUPPORT, 202276a7142aSDave Airlie 1), 202376a7142aSDave Airlie ATOM_DEVICE_CRT1_SUPPORT); 202476a7142aSDave Airlie radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 202576a7142aSDave Airlie DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 202676a7142aSDave Airlie CONNECTOR_OBJECT_ID_VGA, 202776a7142aSDave Airlie &hpd); 2028179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 202976a7142aSDave Airlie hpd.hpd = RADEON_HPD_NONE; 203076a7142aSDave Airlie radeon_add_legacy_encoder(dev, 20315137ee94SAlex Deucher radeon_get_encoder_enum(dev, 203276a7142aSDave Airlie ATOM_DEVICE_CRT2_SUPPORT, 203376a7142aSDave Airlie 2), 203476a7142aSDave Airlie ATOM_DEVICE_CRT2_SUPPORT); 203576a7142aSDave Airlie radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 203676a7142aSDave Airlie DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 203776a7142aSDave Airlie CONNECTOR_OBJECT_ID_VGA, 203876a7142aSDave Airlie &hpd); 203976a7142aSDave Airlie break; 2040aa74fbb4SAlex Deucher case CT_MAC_X800: 2041aa74fbb4SAlex Deucher DRM_INFO("Connector Table: %d (mac x800)\n", 2042aa74fbb4SAlex Deucher rdev->mode_info.connector_table); 2043aa74fbb4SAlex Deucher /* DVI - primary dac, internal tmds */ 2044aa74fbb4SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 2045aa74fbb4SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 2046aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2047aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2048aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 2049aa74fbb4SAlex Deucher 0), 2050aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 2051aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2052aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2053aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2054aa74fbb4SAlex Deucher 1), 2055aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 2056aa74fbb4SAlex Deucher radeon_add_legacy_connector(dev, 0, 2057aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 2058aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2059aa74fbb4SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 2060aa74fbb4SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2061aa74fbb4SAlex Deucher &hpd); 2062aa74fbb4SAlex Deucher /* DVI - tv dac, dvo */ 2063aa74fbb4SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 2064aa74fbb4SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 2065aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2066aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2067aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT, 2068aa74fbb4SAlex Deucher 0), 2069aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT); 2070aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2071aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2072aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2073aa74fbb4SAlex Deucher 2), 2074aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 2075aa74fbb4SAlex Deucher radeon_add_legacy_connector(dev, 1, 2076aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT | 2077aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2078aa74fbb4SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 2079aa74fbb4SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 2080aa74fbb4SAlex Deucher &hpd); 2081aa74fbb4SAlex Deucher break; 20829fad321aSAlex Deucher case CT_MAC_G5_9600: 20839fad321aSAlex Deucher DRM_INFO("Connector Table: %d (mac g5 9600)\n", 20849fad321aSAlex Deucher rdev->mode_info.connector_table); 20859fad321aSAlex Deucher /* DVI - tv dac, dvo */ 20869fad321aSAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 20879fad321aSAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 20889fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20899fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20909fad321aSAlex Deucher ATOM_DEVICE_DFP2_SUPPORT, 20919fad321aSAlex Deucher 0), 20929fad321aSAlex Deucher ATOM_DEVICE_DFP2_SUPPORT); 20939fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20949fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20959fad321aSAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 20969fad321aSAlex Deucher 2), 20979fad321aSAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 20989fad321aSAlex Deucher radeon_add_legacy_connector(dev, 0, 20999fad321aSAlex Deucher ATOM_DEVICE_DFP2_SUPPORT | 21009fad321aSAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 21019fad321aSAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 21029fad321aSAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 21039fad321aSAlex Deucher &hpd); 21049fad321aSAlex Deucher /* ADC - primary dac, internal tmds */ 21059fad321aSAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 21069fad321aSAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 21079fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 21089fad321aSAlex Deucher radeon_get_encoder_enum(dev, 21099fad321aSAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 21109fad321aSAlex Deucher 0), 21119fad321aSAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 21129fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 21139fad321aSAlex Deucher radeon_get_encoder_enum(dev, 21149fad321aSAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 21159fad321aSAlex Deucher 1), 21169fad321aSAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 21179fad321aSAlex Deucher radeon_add_legacy_connector(dev, 1, 21189fad321aSAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 21199fad321aSAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 21209fad321aSAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 21219fad321aSAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 21229fad321aSAlex Deucher &hpd); 2123beb47274SAlex Deucher /* TV - TV DAC */ 2124beb47274SAlex Deucher ddc_i2c.valid = false; 2125beb47274SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2126beb47274SAlex Deucher radeon_add_legacy_encoder(dev, 2127beb47274SAlex Deucher radeon_get_encoder_enum(dev, 2128beb47274SAlex Deucher ATOM_DEVICE_TV1_SUPPORT, 2129beb47274SAlex Deucher 2), 2130beb47274SAlex Deucher ATOM_DEVICE_TV1_SUPPORT); 2131beb47274SAlex Deucher radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 2132beb47274SAlex Deucher DRM_MODE_CONNECTOR_SVIDEO, 2133beb47274SAlex Deucher &ddc_i2c, 2134beb47274SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2135beb47274SAlex Deucher &hpd); 21369fad321aSAlex Deucher break; 2137771fe6b9SJerome Glisse default: 2138771fe6b9SJerome Glisse DRM_INFO("Connector table: %d (invalid)\n", 2139771fe6b9SJerome Glisse rdev->mode_info.connector_table); 2140771fe6b9SJerome Glisse return false; 2141771fe6b9SJerome Glisse } 2142771fe6b9SJerome Glisse 2143771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2144771fe6b9SJerome Glisse 2145771fe6b9SJerome Glisse return true; 2146771fe6b9SJerome Glisse } 2147771fe6b9SJerome Glisse 2148771fe6b9SJerome Glisse static bool radeon_apply_legacy_quirks(struct drm_device *dev, 2149771fe6b9SJerome Glisse int bios_index, 2150771fe6b9SJerome Glisse enum radeon_combios_connector 2151771fe6b9SJerome Glisse *legacy_connector, 2152eed45b30SAlex Deucher struct radeon_i2c_bus_rec *ddc_i2c, 2153eed45b30SAlex Deucher struct radeon_hpd *hpd) 2154771fe6b9SJerome Glisse { 2155fcec570bSAlex Deucher 2156771fe6b9SJerome Glisse /* Certain IBM chipset RN50s have a BIOS reporting two VGAs, 2157771fe6b9SJerome Glisse one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */ 2158771fe6b9SJerome Glisse if (dev->pdev->device == 0x515e && 2159771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x1014) { 2160771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_CRT_LEGACY && 2161771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 2162771fe6b9SJerome Glisse return false; 2163771fe6b9SJerome Glisse } 2164771fe6b9SJerome Glisse 2165771fe6b9SJerome Glisse /* X300 card with extra non-existent DVI port */ 2166771fe6b9SJerome Glisse if (dev->pdev->device == 0x5B60 && 2167771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x17af && 2168771fe6b9SJerome Glisse dev->pdev->subsystem_device == 0x201e && bios_index == 2) { 2169771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_DVI_I_LEGACY) 2170771fe6b9SJerome Glisse return false; 2171771fe6b9SJerome Glisse } 2172771fe6b9SJerome Glisse 2173771fe6b9SJerome Glisse return true; 2174771fe6b9SJerome Glisse } 2175771fe6b9SJerome Glisse 2176790cfb34SAlex Deucher static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev) 2177790cfb34SAlex Deucher { 2178790cfb34SAlex Deucher /* Acer 5102 has non-existent TV port */ 2179790cfb34SAlex Deucher if (dev->pdev->device == 0x5975 && 2180790cfb34SAlex Deucher dev->pdev->subsystem_vendor == 0x1025 && 2181790cfb34SAlex Deucher dev->pdev->subsystem_device == 0x009f) 2182790cfb34SAlex Deucher return false; 2183790cfb34SAlex Deucher 2184fc7f7119SAlex Deucher /* HP dc5750 has non-existent TV port */ 2185fc7f7119SAlex Deucher if (dev->pdev->device == 0x5974 && 2186fc7f7119SAlex Deucher dev->pdev->subsystem_vendor == 0x103c && 2187fc7f7119SAlex Deucher dev->pdev->subsystem_device == 0x280a) 2188fc7f7119SAlex Deucher return false; 2189fc7f7119SAlex Deucher 2190fd874ad0SAlex Deucher /* MSI S270 has non-existent TV port */ 2191fd874ad0SAlex Deucher if (dev->pdev->device == 0x5955 && 2192fd874ad0SAlex Deucher dev->pdev->subsystem_vendor == 0x1462 && 2193fd874ad0SAlex Deucher dev->pdev->subsystem_device == 0x0131) 2194fd874ad0SAlex Deucher return false; 2195fd874ad0SAlex Deucher 2196790cfb34SAlex Deucher return true; 2197790cfb34SAlex Deucher } 2198790cfb34SAlex Deucher 2199b75fad06SAlex Deucher static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d) 2200b75fad06SAlex Deucher { 2201b75fad06SAlex Deucher struct radeon_device *rdev = dev->dev_private; 2202b75fad06SAlex Deucher uint32_t ext_tmds_info; 2203b75fad06SAlex Deucher 2204b75fad06SAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2205b75fad06SAlex Deucher if (is_dvi_d) 2206b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 2207b75fad06SAlex Deucher else 2208b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2209b75fad06SAlex Deucher } 2210b75fad06SAlex Deucher ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2211b75fad06SAlex Deucher if (ext_tmds_info) { 2212b75fad06SAlex Deucher uint8_t rev = RBIOS8(ext_tmds_info); 2213b75fad06SAlex Deucher uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5); 2214b75fad06SAlex Deucher if (rev >= 3) { 2215b75fad06SAlex Deucher if (is_dvi_d) 2216b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 2217b75fad06SAlex Deucher else 2218b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 2219b75fad06SAlex Deucher } else { 2220b75fad06SAlex Deucher if (flags & 1) { 2221b75fad06SAlex Deucher if (is_dvi_d) 2222b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 2223b75fad06SAlex Deucher else 2224b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 2225b75fad06SAlex Deucher } 2226b75fad06SAlex Deucher } 2227b75fad06SAlex Deucher } 2228b75fad06SAlex Deucher if (is_dvi_d) 2229b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 2230b75fad06SAlex Deucher else 2231b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2232b75fad06SAlex Deucher } 2233b75fad06SAlex Deucher 2234771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) 2235771fe6b9SJerome Glisse { 2236771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2237771fe6b9SJerome Glisse uint32_t conn_info, entry, devices; 2238b75fad06SAlex Deucher uint16_t tmp, connector_object_id; 2239771fe6b9SJerome Glisse enum radeon_combios_ddc ddc_type; 2240771fe6b9SJerome Glisse enum radeon_combios_connector connector; 2241771fe6b9SJerome Glisse int i = 0; 2242771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 2243eed45b30SAlex Deucher struct radeon_hpd hpd; 2244771fe6b9SJerome Glisse 2245771fe6b9SJerome Glisse conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE); 2246771fe6b9SJerome Glisse if (conn_info) { 2247771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 2248771fe6b9SJerome Glisse entry = conn_info + 2 + i * 2; 2249771fe6b9SJerome Glisse 2250771fe6b9SJerome Glisse if (!RBIOS16(entry)) 2251771fe6b9SJerome Glisse break; 2252771fe6b9SJerome Glisse 2253771fe6b9SJerome Glisse tmp = RBIOS16(entry); 2254771fe6b9SJerome Glisse 2255771fe6b9SJerome Glisse connector = (tmp >> 12) & 0xf; 2256771fe6b9SJerome Glisse 2257771fe6b9SJerome Glisse ddc_type = (tmp >> 8) & 0xf; 2258179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, ddc_type, 0, 0); 2259771fe6b9SJerome Glisse 2260eed45b30SAlex Deucher switch (connector) { 2261eed45b30SAlex Deucher case CONNECTOR_PROPRIETARY_LEGACY: 2262eed45b30SAlex Deucher case CONNECTOR_DVI_I_LEGACY: 2263eed45b30SAlex Deucher case CONNECTOR_DVI_D_LEGACY: 2264eed45b30SAlex Deucher if ((tmp >> 4) & 0x1) 2265eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; 2266eed45b30SAlex Deucher else 2267eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 2268eed45b30SAlex Deucher break; 2269eed45b30SAlex Deucher default: 2270eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2271eed45b30SAlex Deucher break; 2272eed45b30SAlex Deucher } 2273eed45b30SAlex Deucher 22742d152c6bSAlex Deucher if (!radeon_apply_legacy_quirks(dev, i, &connector, 2275eed45b30SAlex Deucher &ddc_i2c, &hpd)) 22762d152c6bSAlex Deucher continue; 2277771fe6b9SJerome Glisse 2278771fe6b9SJerome Glisse switch (connector) { 2279771fe6b9SJerome Glisse case CONNECTOR_PROPRIETARY_LEGACY: 2280771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) 2281771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2282771fe6b9SJerome Glisse else 2283771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2284771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22855137ee94SAlex Deucher radeon_get_encoder_enum 2286771fe6b9SJerome Glisse (dev, devices, 0), 2287771fe6b9SJerome Glisse devices); 2288771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2289771fe6b9SJerome Glisse legacy_connector_convert 2290771fe6b9SJerome Glisse [connector], 2291b75fad06SAlex Deucher &ddc_i2c, 2292eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 2293eed45b30SAlex Deucher &hpd); 2294771fe6b9SJerome Glisse break; 2295771fe6b9SJerome Glisse case CONNECTOR_CRT_LEGACY: 2296771fe6b9SJerome Glisse if (tmp & 0x1) { 2297771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT2_SUPPORT; 2298771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22995137ee94SAlex Deucher radeon_get_encoder_enum 2300771fe6b9SJerome Glisse (dev, 2301771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2302771fe6b9SJerome Glisse 2), 2303771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2304771fe6b9SJerome Glisse } else { 2305771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT1_SUPPORT; 2306771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23075137ee94SAlex Deucher radeon_get_encoder_enum 2308771fe6b9SJerome Glisse (dev, 2309771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2310771fe6b9SJerome Glisse 1), 2311771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2312771fe6b9SJerome Glisse } 2313771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2314771fe6b9SJerome Glisse i, 2315771fe6b9SJerome Glisse devices, 2316771fe6b9SJerome Glisse legacy_connector_convert 2317771fe6b9SJerome Glisse [connector], 2318b75fad06SAlex Deucher &ddc_i2c, 2319eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2320eed45b30SAlex Deucher &hpd); 2321771fe6b9SJerome Glisse break; 2322771fe6b9SJerome Glisse case CONNECTOR_DVI_I_LEGACY: 2323771fe6b9SJerome Glisse devices = 0; 2324771fe6b9SJerome Glisse if (tmp & 0x1) { 2325771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT2_SUPPORT; 2326771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23275137ee94SAlex Deucher radeon_get_encoder_enum 2328771fe6b9SJerome Glisse (dev, 2329771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2330771fe6b9SJerome Glisse 2), 2331771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2332771fe6b9SJerome Glisse } else { 2333771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT1_SUPPORT; 2334771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23355137ee94SAlex Deucher radeon_get_encoder_enum 2336771fe6b9SJerome Glisse (dev, 2337771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2338771fe6b9SJerome Glisse 1), 2339771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2340771fe6b9SJerome Glisse } 2341771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) { 2342771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP2_SUPPORT; 2343771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23445137ee94SAlex Deucher radeon_get_encoder_enum 2345771fe6b9SJerome Glisse (dev, 2346771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 2347771fe6b9SJerome Glisse 0), 2348771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 2349b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 0); 2350771fe6b9SJerome Glisse } else { 2351771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP1_SUPPORT; 2352771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23535137ee94SAlex Deucher radeon_get_encoder_enum 2354771fe6b9SJerome Glisse (dev, 2355771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2356771fe6b9SJerome Glisse 0), 2357771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2358b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2359771fe6b9SJerome Glisse } 2360771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2361771fe6b9SJerome Glisse i, 2362771fe6b9SJerome Glisse devices, 2363771fe6b9SJerome Glisse legacy_connector_convert 2364771fe6b9SJerome Glisse [connector], 2365b75fad06SAlex Deucher &ddc_i2c, 2366eed45b30SAlex Deucher connector_object_id, 2367eed45b30SAlex Deucher &hpd); 2368771fe6b9SJerome Glisse break; 2369771fe6b9SJerome Glisse case CONNECTOR_DVI_D_LEGACY: 2370b75fad06SAlex Deucher if ((tmp >> 4) & 0x1) { 2371771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2372b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 1); 2373b75fad06SAlex Deucher } else { 2374771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2375b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2376b75fad06SAlex Deucher } 2377771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23785137ee94SAlex Deucher radeon_get_encoder_enum 2379771fe6b9SJerome Glisse (dev, devices, 0), 2380771fe6b9SJerome Glisse devices); 2381771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2382771fe6b9SJerome Glisse legacy_connector_convert 2383771fe6b9SJerome Glisse [connector], 2384b75fad06SAlex Deucher &ddc_i2c, 2385eed45b30SAlex Deucher connector_object_id, 2386eed45b30SAlex Deucher &hpd); 2387771fe6b9SJerome Glisse break; 2388771fe6b9SJerome Glisse case CONNECTOR_CTV_LEGACY: 2389771fe6b9SJerome Glisse case CONNECTOR_STV_LEGACY: 2390771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23915137ee94SAlex Deucher radeon_get_encoder_enum 2392771fe6b9SJerome Glisse (dev, 2393771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2394771fe6b9SJerome Glisse 2), 2395771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2396771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, 2397771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2398771fe6b9SJerome Glisse legacy_connector_convert 2399771fe6b9SJerome Glisse [connector], 2400b75fad06SAlex Deucher &ddc_i2c, 2401eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2402eed45b30SAlex Deucher &hpd); 2403771fe6b9SJerome Glisse break; 2404771fe6b9SJerome Glisse default: 2405771fe6b9SJerome Glisse DRM_ERROR("Unknown connector type: %d\n", 2406771fe6b9SJerome Glisse connector); 2407771fe6b9SJerome Glisse continue; 2408771fe6b9SJerome Glisse } 2409771fe6b9SJerome Glisse 2410771fe6b9SJerome Glisse } 2411771fe6b9SJerome Glisse } else { 2412771fe6b9SJerome Glisse uint16_t tmds_info = 2413771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 2414771fe6b9SJerome Glisse if (tmds_info) { 2415d9fdaafbSDave Airlie DRM_DEBUG_KMS("Found DFP table, assuming DVI connector\n"); 2416771fe6b9SJerome Glisse 2417771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24185137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2419771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2420771fe6b9SJerome Glisse 1), 2421771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2422771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24235137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2424771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2425771fe6b9SJerome Glisse 0), 2426771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2427771fe6b9SJerome Glisse 2428179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 24298e36ed00SAlex Deucher hpd.hpd = RADEON_HPD_1; 2430771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2431771fe6b9SJerome Glisse 0, 2432771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT | 2433771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2434771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 2435b75fad06SAlex Deucher &ddc_i2c, 2436eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2437eed45b30SAlex Deucher &hpd); 2438771fe6b9SJerome Glisse } else { 2439d0c403e9SAlex Deucher uint16_t crt_info = 2440d0c403e9SAlex Deucher combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 2441d9fdaafbSDave Airlie DRM_DEBUG_KMS("Found CRT table, assuming VGA connector\n"); 2442d0c403e9SAlex Deucher if (crt_info) { 2443d0c403e9SAlex Deucher radeon_add_legacy_encoder(dev, 24445137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2445d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2446d0c403e9SAlex Deucher 1), 2447d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 2448179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 2449eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2450d0c403e9SAlex Deucher radeon_add_legacy_connector(dev, 2451d0c403e9SAlex Deucher 0, 2452d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2453d0c403e9SAlex Deucher DRM_MODE_CONNECTOR_VGA, 2454b75fad06SAlex Deucher &ddc_i2c, 2455eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2456eed45b30SAlex Deucher &hpd); 2457d0c403e9SAlex Deucher } else { 2458d9fdaafbSDave Airlie DRM_DEBUG_KMS("No connector info found\n"); 2459771fe6b9SJerome Glisse return false; 2460771fe6b9SJerome Glisse } 2461771fe6b9SJerome Glisse } 2462d0c403e9SAlex Deucher } 2463771fe6b9SJerome Glisse 2464771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) { 2465771fe6b9SJerome Glisse uint16_t lcd_info = 2466771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 2467771fe6b9SJerome Glisse if (lcd_info) { 2468771fe6b9SJerome Glisse uint16_t lcd_ddc_info = 2469771fe6b9SJerome Glisse combios_get_table_offset(dev, 2470771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE); 2471771fe6b9SJerome Glisse 2472771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24735137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2474771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2475771fe6b9SJerome Glisse 0), 2476771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 2477771fe6b9SJerome Glisse 2478771fe6b9SJerome Glisse if (lcd_ddc_info) { 2479771fe6b9SJerome Glisse ddc_type = RBIOS8(lcd_ddc_info + 2); 2480771fe6b9SJerome Glisse switch (ddc_type) { 2481771fe6b9SJerome Glisse case DDC_LCD: 2482771fe6b9SJerome Glisse ddc_i2c = 2483179e8078SAlex Deucher combios_setup_i2c_bus(rdev, 2484179e8078SAlex Deucher DDC_LCD, 2485179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 3), 2486179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 7)); 2487f376b94fSAlex Deucher radeon_i2c_add(rdev, &ddc_i2c, "LCD"); 2488771fe6b9SJerome Glisse break; 2489771fe6b9SJerome Glisse case DDC_GPIO: 2490771fe6b9SJerome Glisse ddc_i2c = 2491179e8078SAlex Deucher combios_setup_i2c_bus(rdev, 2492179e8078SAlex Deucher DDC_GPIO, 2493179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 3), 2494179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 7)); 2495f376b94fSAlex Deucher radeon_i2c_add(rdev, &ddc_i2c, "LCD"); 2496771fe6b9SJerome Glisse break; 2497771fe6b9SJerome Glisse default: 2498179e8078SAlex Deucher ddc_i2c = 2499179e8078SAlex Deucher combios_setup_i2c_bus(rdev, ddc_type, 0, 0); 2500771fe6b9SJerome Glisse break; 2501771fe6b9SJerome Glisse } 2502d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD DDC Info Table found!\n"); 2503771fe6b9SJerome Glisse } else 2504771fe6b9SJerome Glisse ddc_i2c.valid = false; 2505771fe6b9SJerome Glisse 2506eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2507771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2508771fe6b9SJerome Glisse 5, 2509771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2510771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 2511b75fad06SAlex Deucher &ddc_i2c, 2512eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 2513eed45b30SAlex Deucher &hpd); 2514771fe6b9SJerome Glisse } 2515771fe6b9SJerome Glisse } 2516771fe6b9SJerome Glisse 2517771fe6b9SJerome Glisse /* check TV table */ 2518771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 2519771fe6b9SJerome Glisse uint32_t tv_info = 2520771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 2521771fe6b9SJerome Glisse if (tv_info) { 2522771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 2523790cfb34SAlex Deucher if (radeon_apply_legacy_tv_quirks(dev)) { 2524eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2525d294ed69SDave Airlie ddc_i2c.valid = false; 2526771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 25275137ee94SAlex Deucher radeon_get_encoder_enum 2528771fe6b9SJerome Glisse (dev, 2529771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2530771fe6b9SJerome Glisse 2), 2531771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2532771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 6, 2533771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2534771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 2535b75fad06SAlex Deucher &ddc_i2c, 2536eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2537eed45b30SAlex Deucher &hpd); 2538771fe6b9SJerome Glisse } 2539771fe6b9SJerome Glisse } 2540771fe6b9SJerome Glisse } 2541790cfb34SAlex Deucher } 2542771fe6b9SJerome Glisse 2543771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2544771fe6b9SJerome Glisse 2545771fe6b9SJerome Glisse return true; 2546771fe6b9SJerome Glisse } 2547771fe6b9SJerome Glisse 254863f7d982SAlex Deucher static const char *thermal_controller_names[] = { 254963f7d982SAlex Deucher "NONE", 255063f7d982SAlex Deucher "lm63", 255163f7d982SAlex Deucher "adm1032", 255263f7d982SAlex Deucher }; 255363f7d982SAlex Deucher 255456278a8eSAlex Deucher void radeon_combios_get_power_modes(struct radeon_device *rdev) 255556278a8eSAlex Deucher { 255656278a8eSAlex Deucher struct drm_device *dev = rdev->ddev; 255756278a8eSAlex Deucher u16 offset, misc, misc2 = 0; 255856278a8eSAlex Deucher u8 rev, blocks, tmp; 255956278a8eSAlex Deucher int state_index = 0; 2560c41b9ee9SAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 256156278a8eSAlex Deucher 2562a48b9b4eSAlex Deucher rdev->pm.default_power_state_index = -1; 256356278a8eSAlex Deucher 25640975b162SAlex Deucher /* allocate 2 power states */ 25650975b162SAlex Deucher rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * 2, GFP_KERNEL); 25660975b162SAlex Deucher if (!rdev->pm.power_state) { 25670975b162SAlex Deucher rdev->pm.default_power_state_index = state_index; 25680975b162SAlex Deucher rdev->pm.num_power_states = 0; 25690975b162SAlex Deucher 25700975b162SAlex Deucher rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; 25710975b162SAlex Deucher rdev->pm.current_clock_mode_index = 0; 25720975b162SAlex Deucher return; 25730975b162SAlex Deucher } 25740975b162SAlex Deucher 257563f7d982SAlex Deucher /* check for a thermal chip */ 257663f7d982SAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_OVERDRIVE_INFO_TABLE); 257763f7d982SAlex Deucher if (offset) { 257863f7d982SAlex Deucher u8 thermal_controller = 0, gpio = 0, i2c_addr = 0, clk_bit = 0, data_bit = 0; 257963f7d982SAlex Deucher 258063f7d982SAlex Deucher rev = RBIOS8(offset); 258163f7d982SAlex Deucher 258263f7d982SAlex Deucher if (rev == 0) { 258363f7d982SAlex Deucher thermal_controller = RBIOS8(offset + 3); 258463f7d982SAlex Deucher gpio = RBIOS8(offset + 4) & 0x3f; 258563f7d982SAlex Deucher i2c_addr = RBIOS8(offset + 5); 258663f7d982SAlex Deucher } else if (rev == 1) { 258763f7d982SAlex Deucher thermal_controller = RBIOS8(offset + 4); 258863f7d982SAlex Deucher gpio = RBIOS8(offset + 5) & 0x3f; 258963f7d982SAlex Deucher i2c_addr = RBIOS8(offset + 6); 259063f7d982SAlex Deucher } else if (rev == 2) { 259163f7d982SAlex Deucher thermal_controller = RBIOS8(offset + 4); 259263f7d982SAlex Deucher gpio = RBIOS8(offset + 5) & 0x3f; 259363f7d982SAlex Deucher i2c_addr = RBIOS8(offset + 6); 259463f7d982SAlex Deucher clk_bit = RBIOS8(offset + 0xa); 259563f7d982SAlex Deucher data_bit = RBIOS8(offset + 0xb); 259663f7d982SAlex Deucher } 259763f7d982SAlex Deucher if ((thermal_controller > 0) && (thermal_controller < 3)) { 259863f7d982SAlex Deucher DRM_INFO("Possible %s thermal controller at 0x%02x\n", 259963f7d982SAlex Deucher thermal_controller_names[thermal_controller], 260063f7d982SAlex Deucher i2c_addr >> 1); 260163f7d982SAlex Deucher if (gpio == DDC_LCD) { 260263f7d982SAlex Deucher /* MM i2c */ 260363f7d982SAlex Deucher i2c_bus.valid = true; 260463f7d982SAlex Deucher i2c_bus.hw_capable = true; 260563f7d982SAlex Deucher i2c_bus.mm_i2c = true; 260663f7d982SAlex Deucher i2c_bus.i2c_id = 0xa0; 260763f7d982SAlex Deucher } else if (gpio == DDC_GPIO) 260863f7d982SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 1 << clk_bit, 1 << data_bit); 260963f7d982SAlex Deucher else 261063f7d982SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0); 261163f7d982SAlex Deucher rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 261263f7d982SAlex Deucher if (rdev->pm.i2c_bus) { 261363f7d982SAlex Deucher struct i2c_board_info info = { }; 261463f7d982SAlex Deucher const char *name = thermal_controller_names[thermal_controller]; 261563f7d982SAlex Deucher info.addr = i2c_addr >> 1; 261663f7d982SAlex Deucher strlcpy(info.type, name, sizeof(info.type)); 261763f7d982SAlex Deucher i2c_new_device(&rdev->pm.i2c_bus->adapter, &info); 261863f7d982SAlex Deucher } 261963f7d982SAlex Deucher } 2620c41b9ee9SAlex Deucher } else { 2621c41b9ee9SAlex Deucher /* boards with a thermal chip, but no overdrive table */ 2622c41b9ee9SAlex Deucher 2623c41b9ee9SAlex Deucher /* Asus 9600xt has an f75375 on the monid bus */ 2624c41b9ee9SAlex Deucher if ((dev->pdev->device == 0x4152) && 2625c41b9ee9SAlex Deucher (dev->pdev->subsystem_vendor == 0x1043) && 2626c41b9ee9SAlex Deucher (dev->pdev->subsystem_device == 0xc002)) { 2627c41b9ee9SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 2628c41b9ee9SAlex Deucher rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 2629c41b9ee9SAlex Deucher if (rdev->pm.i2c_bus) { 2630c41b9ee9SAlex Deucher struct i2c_board_info info = { }; 2631c41b9ee9SAlex Deucher const char *name = "f75375"; 2632c41b9ee9SAlex Deucher info.addr = 0x28; 2633c41b9ee9SAlex Deucher strlcpy(info.type, name, sizeof(info.type)); 2634c41b9ee9SAlex Deucher i2c_new_device(&rdev->pm.i2c_bus->adapter, &info); 2635c41b9ee9SAlex Deucher DRM_INFO("Possible %s thermal controller at 0x%02x\n", 2636c41b9ee9SAlex Deucher name, info.addr); 2637c41b9ee9SAlex Deucher } 2638c41b9ee9SAlex Deucher } 263963f7d982SAlex Deucher } 264063f7d982SAlex Deucher 264156278a8eSAlex Deucher if (rdev->flags & RADEON_IS_MOBILITY) { 264256278a8eSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE); 264356278a8eSAlex Deucher if (offset) { 264456278a8eSAlex Deucher rev = RBIOS8(offset); 264556278a8eSAlex Deucher blocks = RBIOS8(offset + 0x2); 264656278a8eSAlex Deucher /* power mode 0 tends to be the only valid one */ 264756278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 264856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = RBIOS32(offset + 0x5 + 0x2); 264956278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = RBIOS32(offset + 0x5 + 0x6); 265056278a8eSAlex Deucher if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) || 265156278a8eSAlex Deucher (rdev->pm.power_state[state_index].clock_info[0].sclk == 0)) 265256278a8eSAlex Deucher goto default_mode; 26530ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 26540ec0e74fSAlex Deucher POWER_STATE_TYPE_BATTERY; 265556278a8eSAlex Deucher misc = RBIOS16(offset + 0x5 + 0x0); 265656278a8eSAlex Deucher if (rev > 4) 265756278a8eSAlex Deucher misc2 = RBIOS16(offset + 0x5 + 0xe); 265879daedc9SAlex Deucher rdev->pm.power_state[state_index].misc = misc; 265979daedc9SAlex Deucher rdev->pm.power_state[state_index].misc2 = misc2; 266056278a8eSAlex Deucher if (misc & 0x4) { 266156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_GPIO; 266256278a8eSAlex Deucher if (misc & 0x8) 266356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 266456278a8eSAlex Deucher true; 266556278a8eSAlex Deucher else 266656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 266756278a8eSAlex Deucher false; 266856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = true; 266956278a8eSAlex Deucher if (rev < 6) { 267056278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 267156278a8eSAlex Deucher RBIOS16(offset + 0x5 + 0xb) * 4; 267256278a8eSAlex Deucher tmp = RBIOS8(offset + 0x5 + 0xd); 267356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 267456278a8eSAlex Deucher } else { 267556278a8eSAlex Deucher u8 entries = RBIOS8(offset + 0x5 + 0xb); 267656278a8eSAlex Deucher u16 voltage_table_offset = RBIOS16(offset + 0x5 + 0xc); 267756278a8eSAlex Deucher if (entries && voltage_table_offset) { 267856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 267956278a8eSAlex Deucher RBIOS16(voltage_table_offset) * 4; 268056278a8eSAlex Deucher tmp = RBIOS8(voltage_table_offset + 0x2); 268156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 268256278a8eSAlex Deucher } else 268356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = false; 268456278a8eSAlex Deucher } 268556278a8eSAlex Deucher switch ((misc2 & 0x700) >> 8) { 268656278a8eSAlex Deucher case 0: 268756278a8eSAlex Deucher default: 268856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 0; 268956278a8eSAlex Deucher break; 269056278a8eSAlex Deucher case 1: 269156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 33; 269256278a8eSAlex Deucher break; 269356278a8eSAlex Deucher case 2: 269456278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 66; 269556278a8eSAlex Deucher break; 269656278a8eSAlex Deucher case 3: 269756278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 99; 269856278a8eSAlex Deucher break; 269956278a8eSAlex Deucher case 4: 270056278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 132; 270156278a8eSAlex Deucher break; 270256278a8eSAlex Deucher } 270356278a8eSAlex Deucher } else 270456278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 270556278a8eSAlex Deucher if (rev > 6) 270679daedc9SAlex Deucher rdev->pm.power_state[state_index].pcie_lanes = 270756278a8eSAlex Deucher RBIOS8(offset + 0x5 + 0x10); 2708d7311171SAlex Deucher rdev->pm.power_state[state_index].flags = RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; 270956278a8eSAlex Deucher state_index++; 271056278a8eSAlex Deucher } else { 271156278a8eSAlex Deucher /* XXX figure out some good default low power mode for mobility cards w/out power tables */ 271256278a8eSAlex Deucher } 271356278a8eSAlex Deucher } else { 271456278a8eSAlex Deucher /* XXX figure out some good default low power mode for desktop cards */ 271556278a8eSAlex Deucher } 271656278a8eSAlex Deucher 271756278a8eSAlex Deucher default_mode: 271856278a8eSAlex Deucher /* add the default mode */ 27190ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 27200ec0e74fSAlex Deucher POWER_STATE_TYPE_DEFAULT; 272156278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 272256278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk; 272356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk; 272456278a8eSAlex Deucher rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0]; 272584d88f4cSAlex Deucher if ((state_index > 0) && 27268de016e2SAlex Deucher (rdev->pm.power_state[0].clock_info[0].voltage.type == VOLTAGE_GPIO)) 272784d88f4cSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage = 272884d88f4cSAlex Deucher rdev->pm.power_state[0].clock_info[0].voltage; 272984d88f4cSAlex Deucher else 273056278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 273179daedc9SAlex Deucher rdev->pm.power_state[state_index].pcie_lanes = 16; 2732a48b9b4eSAlex Deucher rdev->pm.power_state[state_index].flags = 0; 2733a48b9b4eSAlex Deucher rdev->pm.default_power_state_index = state_index; 273456278a8eSAlex Deucher rdev->pm.num_power_states = state_index + 1; 27359038dfdfSRafał Miłecki 2736a48b9b4eSAlex Deucher rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; 2737a48b9b4eSAlex Deucher rdev->pm.current_clock_mode_index = 0; 273856278a8eSAlex Deucher } 273956278a8eSAlex Deucher 2740fcec570bSAlex Deucher void radeon_external_tmds_setup(struct drm_encoder *encoder) 2741fcec570bSAlex Deucher { 2742fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2743fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2744fcec570bSAlex Deucher 2745fcec570bSAlex Deucher if (!tmds) 2746fcec570bSAlex Deucher return; 2747fcec570bSAlex Deucher 2748fcec570bSAlex Deucher switch (tmds->dvo_chip) { 2749fcec570bSAlex Deucher case DVO_SIL164: 2750fcec570bSAlex Deucher /* sil 164 */ 27515a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2752fcec570bSAlex Deucher tmds->slave_addr, 2753fcec570bSAlex Deucher 0x08, 0x30); 27545a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2755fcec570bSAlex Deucher tmds->slave_addr, 2756fcec570bSAlex Deucher 0x09, 0x00); 27575a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2758fcec570bSAlex Deucher tmds->slave_addr, 2759fcec570bSAlex Deucher 0x0a, 0x90); 27605a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2761fcec570bSAlex Deucher tmds->slave_addr, 2762fcec570bSAlex Deucher 0x0c, 0x89); 27635a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2764fcec570bSAlex Deucher tmds->slave_addr, 2765fcec570bSAlex Deucher 0x08, 0x3b); 2766fcec570bSAlex Deucher break; 2767fcec570bSAlex Deucher case DVO_SIL1178: 2768fcec570bSAlex Deucher /* sil 1178 - untested */ 2769fcec570bSAlex Deucher /* 2770fcec570bSAlex Deucher * 0x0f, 0x44 2771fcec570bSAlex Deucher * 0x0f, 0x4c 2772fcec570bSAlex Deucher * 0x0e, 0x01 2773fcec570bSAlex Deucher * 0x0a, 0x80 2774fcec570bSAlex Deucher * 0x09, 0x30 2775fcec570bSAlex Deucher * 0x0c, 0xc9 2776fcec570bSAlex Deucher * 0x0d, 0x70 2777fcec570bSAlex Deucher * 0x08, 0x32 2778fcec570bSAlex Deucher * 0x08, 0x33 2779fcec570bSAlex Deucher */ 2780fcec570bSAlex Deucher break; 2781fcec570bSAlex Deucher default: 2782fcec570bSAlex Deucher break; 2783fcec570bSAlex Deucher } 2784fcec570bSAlex Deucher 2785fcec570bSAlex Deucher } 2786fcec570bSAlex Deucher 2787fcec570bSAlex Deucher bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder) 2788fcec570bSAlex Deucher { 2789fcec570bSAlex Deucher struct drm_device *dev = encoder->dev; 2790fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 2791fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2792fcec570bSAlex Deucher uint16_t offset; 2793fcec570bSAlex Deucher uint8_t blocks, slave_addr, rev; 2794fcec570bSAlex Deucher uint32_t index, id; 2795fcec570bSAlex Deucher uint32_t reg, val, and_mask, or_mask; 2796fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2797fcec570bSAlex Deucher 2798fcec570bSAlex Deucher if (!tmds) 2799fcec570bSAlex Deucher return false; 2800fcec570bSAlex Deucher 2801fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2802fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE); 2803fcec570bSAlex Deucher rev = RBIOS8(offset); 2804fcec570bSAlex Deucher if (offset) { 2805fcec570bSAlex Deucher rev = RBIOS8(offset); 2806fcec570bSAlex Deucher if (rev > 1) { 2807fcec570bSAlex Deucher blocks = RBIOS8(offset + 3); 2808fcec570bSAlex Deucher index = offset + 4; 2809fcec570bSAlex Deucher while (blocks > 0) { 2810fcec570bSAlex Deucher id = RBIOS16(index); 2811fcec570bSAlex Deucher index += 2; 2812fcec570bSAlex Deucher switch (id >> 13) { 2813fcec570bSAlex Deucher case 0: 2814fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2815fcec570bSAlex Deucher val = RBIOS32(index); 2816fcec570bSAlex Deucher index += 4; 2817fcec570bSAlex Deucher WREG32(reg, val); 2818fcec570bSAlex Deucher break; 2819fcec570bSAlex Deucher case 2: 2820fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2821fcec570bSAlex Deucher and_mask = RBIOS32(index); 2822fcec570bSAlex Deucher index += 4; 2823fcec570bSAlex Deucher or_mask = RBIOS32(index); 2824fcec570bSAlex Deucher index += 4; 2825fcec570bSAlex Deucher val = RREG32(reg); 2826fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2827fcec570bSAlex Deucher WREG32(reg, val); 2828fcec570bSAlex Deucher break; 2829fcec570bSAlex Deucher case 3: 2830fcec570bSAlex Deucher val = RBIOS16(index); 2831fcec570bSAlex Deucher index += 2; 2832fcec570bSAlex Deucher udelay(val); 2833fcec570bSAlex Deucher break; 2834fcec570bSAlex Deucher case 4: 2835fcec570bSAlex Deucher val = RBIOS16(index); 2836fcec570bSAlex Deucher index += 2; 2837fcec570bSAlex Deucher udelay(val * 1000); 2838fcec570bSAlex Deucher break; 2839fcec570bSAlex Deucher case 6: 2840fcec570bSAlex Deucher slave_addr = id & 0xff; 2841fcec570bSAlex Deucher slave_addr >>= 1; /* 7 bit addressing */ 2842fcec570bSAlex Deucher index++; 2843fcec570bSAlex Deucher reg = RBIOS8(index); 2844fcec570bSAlex Deucher index++; 2845fcec570bSAlex Deucher val = RBIOS8(index); 2846fcec570bSAlex Deucher index++; 28475a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2848fcec570bSAlex Deucher slave_addr, 2849fcec570bSAlex Deucher reg, val); 2850fcec570bSAlex Deucher break; 2851fcec570bSAlex Deucher default: 2852fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2853fcec570bSAlex Deucher break; 2854fcec570bSAlex Deucher } 2855fcec570bSAlex Deucher blocks--; 2856fcec570bSAlex Deucher } 2857fcec570bSAlex Deucher return true; 2858fcec570bSAlex Deucher } 2859fcec570bSAlex Deucher } 2860fcec570bSAlex Deucher } else { 2861fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2862fcec570bSAlex Deucher if (offset) { 2863fcec570bSAlex Deucher index = offset + 10; 2864fcec570bSAlex Deucher id = RBIOS16(index); 2865fcec570bSAlex Deucher while (id != 0xffff) { 2866fcec570bSAlex Deucher index += 2; 2867fcec570bSAlex Deucher switch (id >> 13) { 2868fcec570bSAlex Deucher case 0: 2869fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2870fcec570bSAlex Deucher val = RBIOS32(index); 2871fcec570bSAlex Deucher WREG32(reg, val); 2872fcec570bSAlex Deucher break; 2873fcec570bSAlex Deucher case 2: 2874fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2875fcec570bSAlex Deucher and_mask = RBIOS32(index); 2876fcec570bSAlex Deucher index += 4; 2877fcec570bSAlex Deucher or_mask = RBIOS32(index); 2878fcec570bSAlex Deucher index += 4; 2879fcec570bSAlex Deucher val = RREG32(reg); 2880fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2881fcec570bSAlex Deucher WREG32(reg, val); 2882fcec570bSAlex Deucher break; 2883fcec570bSAlex Deucher case 4: 2884fcec570bSAlex Deucher val = RBIOS16(index); 2885fcec570bSAlex Deucher index += 2; 2886fcec570bSAlex Deucher udelay(val); 2887fcec570bSAlex Deucher break; 2888fcec570bSAlex Deucher case 5: 2889fcec570bSAlex Deucher reg = id & 0x1fff; 2890fcec570bSAlex Deucher and_mask = RBIOS32(index); 2891fcec570bSAlex Deucher index += 4; 2892fcec570bSAlex Deucher or_mask = RBIOS32(index); 2893fcec570bSAlex Deucher index += 4; 2894fcec570bSAlex Deucher val = RREG32_PLL(reg); 2895fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2896fcec570bSAlex Deucher WREG32_PLL(reg, val); 2897fcec570bSAlex Deucher break; 2898fcec570bSAlex Deucher case 6: 2899fcec570bSAlex Deucher reg = id & 0x1fff; 2900fcec570bSAlex Deucher val = RBIOS8(index); 2901fcec570bSAlex Deucher index += 1; 29025a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2903fcec570bSAlex Deucher tmds->slave_addr, 2904fcec570bSAlex Deucher reg, val); 2905fcec570bSAlex Deucher break; 2906fcec570bSAlex Deucher default: 2907fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2908fcec570bSAlex Deucher break; 2909fcec570bSAlex Deucher } 2910fcec570bSAlex Deucher id = RBIOS16(index); 2911fcec570bSAlex Deucher } 2912fcec570bSAlex Deucher return true; 2913fcec570bSAlex Deucher } 2914fcec570bSAlex Deucher } 2915fcec570bSAlex Deucher return false; 2916fcec570bSAlex Deucher } 2917fcec570bSAlex Deucher 2918771fe6b9SJerome Glisse static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset) 2919771fe6b9SJerome Glisse { 2920771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2921771fe6b9SJerome Glisse 2922771fe6b9SJerome Glisse if (offset) { 2923771fe6b9SJerome Glisse while (RBIOS16(offset)) { 2924771fe6b9SJerome Glisse uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13); 2925771fe6b9SJerome Glisse uint32_t addr = (RBIOS16(offset) & 0x1fff); 2926771fe6b9SJerome Glisse uint32_t val, and_mask, or_mask; 2927771fe6b9SJerome Glisse uint32_t tmp; 2928771fe6b9SJerome Glisse 2929771fe6b9SJerome Glisse offset += 2; 2930771fe6b9SJerome Glisse switch (cmd) { 2931771fe6b9SJerome Glisse case 0: 2932771fe6b9SJerome Glisse val = RBIOS32(offset); 2933771fe6b9SJerome Glisse offset += 4; 2934771fe6b9SJerome Glisse WREG32(addr, val); 2935771fe6b9SJerome Glisse break; 2936771fe6b9SJerome Glisse case 1: 2937771fe6b9SJerome Glisse val = RBIOS32(offset); 2938771fe6b9SJerome Glisse offset += 4; 2939771fe6b9SJerome Glisse WREG32(addr, val); 2940771fe6b9SJerome Glisse break; 2941771fe6b9SJerome Glisse case 2: 2942771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2943771fe6b9SJerome Glisse offset += 4; 2944771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2945771fe6b9SJerome Glisse offset += 4; 2946771fe6b9SJerome Glisse tmp = RREG32(addr); 2947771fe6b9SJerome Glisse tmp &= and_mask; 2948771fe6b9SJerome Glisse tmp |= or_mask; 2949771fe6b9SJerome Glisse WREG32(addr, tmp); 2950771fe6b9SJerome Glisse break; 2951771fe6b9SJerome Glisse case 3: 2952771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2953771fe6b9SJerome Glisse offset += 4; 2954771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2955771fe6b9SJerome Glisse offset += 4; 2956771fe6b9SJerome Glisse tmp = RREG32(addr); 2957771fe6b9SJerome Glisse tmp &= and_mask; 2958771fe6b9SJerome Glisse tmp |= or_mask; 2959771fe6b9SJerome Glisse WREG32(addr, tmp); 2960771fe6b9SJerome Glisse break; 2961771fe6b9SJerome Glisse case 4: 2962771fe6b9SJerome Glisse val = RBIOS16(offset); 2963771fe6b9SJerome Glisse offset += 2; 2964771fe6b9SJerome Glisse udelay(val); 2965771fe6b9SJerome Glisse break; 2966771fe6b9SJerome Glisse case 5: 2967771fe6b9SJerome Glisse val = RBIOS16(offset); 2968771fe6b9SJerome Glisse offset += 2; 2969771fe6b9SJerome Glisse switch (addr) { 2970771fe6b9SJerome Glisse case 8: 2971771fe6b9SJerome Glisse while (val--) { 2972771fe6b9SJerome Glisse if (! 2973771fe6b9SJerome Glisse (RREG32_PLL 2974771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2975771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2976771fe6b9SJerome Glisse break; 2977771fe6b9SJerome Glisse } 2978771fe6b9SJerome Glisse break; 2979771fe6b9SJerome Glisse case 9: 2980771fe6b9SJerome Glisse while (val--) { 2981771fe6b9SJerome Glisse if ((RREG32(RADEON_MC_STATUS) & 2982771fe6b9SJerome Glisse RADEON_MC_IDLE)) 2983771fe6b9SJerome Glisse break; 2984771fe6b9SJerome Glisse } 2985771fe6b9SJerome Glisse break; 2986771fe6b9SJerome Glisse default: 2987771fe6b9SJerome Glisse break; 2988771fe6b9SJerome Glisse } 2989771fe6b9SJerome Glisse break; 2990771fe6b9SJerome Glisse default: 2991771fe6b9SJerome Glisse break; 2992771fe6b9SJerome Glisse } 2993771fe6b9SJerome Glisse } 2994771fe6b9SJerome Glisse } 2995771fe6b9SJerome Glisse } 2996771fe6b9SJerome Glisse 2997771fe6b9SJerome Glisse static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset) 2998771fe6b9SJerome Glisse { 2999771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3000771fe6b9SJerome Glisse 3001771fe6b9SJerome Glisse if (offset) { 3002771fe6b9SJerome Glisse while (RBIOS8(offset)) { 3003771fe6b9SJerome Glisse uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6); 3004771fe6b9SJerome Glisse uint8_t addr = (RBIOS8(offset) & 0x3f); 3005771fe6b9SJerome Glisse uint32_t val, shift, tmp; 3006771fe6b9SJerome Glisse uint32_t and_mask, or_mask; 3007771fe6b9SJerome Glisse 3008771fe6b9SJerome Glisse offset++; 3009771fe6b9SJerome Glisse switch (cmd) { 3010771fe6b9SJerome Glisse case 0: 3011771fe6b9SJerome Glisse val = RBIOS32(offset); 3012771fe6b9SJerome Glisse offset += 4; 3013771fe6b9SJerome Glisse WREG32_PLL(addr, val); 3014771fe6b9SJerome Glisse break; 3015771fe6b9SJerome Glisse case 1: 3016771fe6b9SJerome Glisse shift = RBIOS8(offset) * 8; 3017771fe6b9SJerome Glisse offset++; 3018771fe6b9SJerome Glisse and_mask = RBIOS8(offset) << shift; 3019771fe6b9SJerome Glisse and_mask |= ~(0xff << shift); 3020771fe6b9SJerome Glisse offset++; 3021771fe6b9SJerome Glisse or_mask = RBIOS8(offset) << shift; 3022771fe6b9SJerome Glisse offset++; 3023771fe6b9SJerome Glisse tmp = RREG32_PLL(addr); 3024771fe6b9SJerome Glisse tmp &= and_mask; 3025771fe6b9SJerome Glisse tmp |= or_mask; 3026771fe6b9SJerome Glisse WREG32_PLL(addr, tmp); 3027771fe6b9SJerome Glisse break; 3028771fe6b9SJerome Glisse case 2: 3029771fe6b9SJerome Glisse case 3: 3030771fe6b9SJerome Glisse tmp = 1000; 3031771fe6b9SJerome Glisse switch (addr) { 3032771fe6b9SJerome Glisse case 1: 3033771fe6b9SJerome Glisse udelay(150); 3034771fe6b9SJerome Glisse break; 3035771fe6b9SJerome Glisse case 2: 3036771fe6b9SJerome Glisse udelay(1000); 3037771fe6b9SJerome Glisse break; 3038771fe6b9SJerome Glisse case 3: 3039771fe6b9SJerome Glisse while (tmp--) { 3040771fe6b9SJerome Glisse if (! 3041771fe6b9SJerome Glisse (RREG32_PLL 3042771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 3043771fe6b9SJerome Glisse RADEON_MC_BUSY)) 3044771fe6b9SJerome Glisse break; 3045771fe6b9SJerome Glisse } 3046771fe6b9SJerome Glisse break; 3047771fe6b9SJerome Glisse case 4: 3048771fe6b9SJerome Glisse while (tmp--) { 3049771fe6b9SJerome Glisse if (RREG32_PLL 3050771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 3051771fe6b9SJerome Glisse RADEON_DLL_READY) 3052771fe6b9SJerome Glisse break; 3053771fe6b9SJerome Glisse } 3054771fe6b9SJerome Glisse break; 3055771fe6b9SJerome Glisse case 5: 3056771fe6b9SJerome Glisse tmp = 3057771fe6b9SJerome Glisse RREG32_PLL(RADEON_CLK_PWRMGT_CNTL); 3058771fe6b9SJerome Glisse if (tmp & RADEON_CG_NO1_DEBUG_0) { 3059771fe6b9SJerome Glisse #if 0 3060771fe6b9SJerome Glisse uint32_t mclk_cntl = 3061771fe6b9SJerome Glisse RREG32_PLL 3062771fe6b9SJerome Glisse (RADEON_MCLK_CNTL); 3063771fe6b9SJerome Glisse mclk_cntl &= 0xffff0000; 3064771fe6b9SJerome Glisse /*mclk_cntl |= 0x00001111;*//* ??? */ 3065771fe6b9SJerome Glisse WREG32_PLL(RADEON_MCLK_CNTL, 3066771fe6b9SJerome Glisse mclk_cntl); 3067771fe6b9SJerome Glisse udelay(10000); 3068771fe6b9SJerome Glisse #endif 3069771fe6b9SJerome Glisse WREG32_PLL 3070771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL, 3071771fe6b9SJerome Glisse tmp & 3072771fe6b9SJerome Glisse ~RADEON_CG_NO1_DEBUG_0); 3073771fe6b9SJerome Glisse udelay(10000); 3074771fe6b9SJerome Glisse } 3075771fe6b9SJerome Glisse break; 3076771fe6b9SJerome Glisse default: 3077771fe6b9SJerome Glisse break; 3078771fe6b9SJerome Glisse } 3079771fe6b9SJerome Glisse break; 3080771fe6b9SJerome Glisse default: 3081771fe6b9SJerome Glisse break; 3082771fe6b9SJerome Glisse } 3083771fe6b9SJerome Glisse } 3084771fe6b9SJerome Glisse } 3085771fe6b9SJerome Glisse } 3086771fe6b9SJerome Glisse 3087771fe6b9SJerome Glisse static void combios_parse_ram_reset_table(struct drm_device *dev, 3088771fe6b9SJerome Glisse uint16_t offset) 3089771fe6b9SJerome Glisse { 3090771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3091771fe6b9SJerome Glisse uint32_t tmp; 3092771fe6b9SJerome Glisse 3093771fe6b9SJerome Glisse if (offset) { 3094771fe6b9SJerome Glisse uint8_t val = RBIOS8(offset); 3095771fe6b9SJerome Glisse while (val != 0xff) { 3096771fe6b9SJerome Glisse offset++; 3097771fe6b9SJerome Glisse 3098771fe6b9SJerome Glisse if (val == 0x0f) { 3099771fe6b9SJerome Glisse uint32_t channel_complete_mask; 3100771fe6b9SJerome Glisse 3101771fe6b9SJerome Glisse if (ASIC_IS_R300(rdev)) 3102771fe6b9SJerome Glisse channel_complete_mask = 3103771fe6b9SJerome Glisse R300_MEM_PWRUP_COMPLETE; 3104771fe6b9SJerome Glisse else 3105771fe6b9SJerome Glisse channel_complete_mask = 3106771fe6b9SJerome Glisse RADEON_MEM_PWRUP_COMPLETE; 3107771fe6b9SJerome Glisse tmp = 20000; 3108771fe6b9SJerome Glisse while (tmp--) { 3109771fe6b9SJerome Glisse if ((RREG32(RADEON_MEM_STR_CNTL) & 3110771fe6b9SJerome Glisse channel_complete_mask) == 3111771fe6b9SJerome Glisse channel_complete_mask) 3112771fe6b9SJerome Glisse break; 3113771fe6b9SJerome Glisse } 3114771fe6b9SJerome Glisse } else { 3115771fe6b9SJerome Glisse uint32_t or_mask = RBIOS16(offset); 3116771fe6b9SJerome Glisse offset += 2; 3117771fe6b9SJerome Glisse 3118771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 3119771fe6b9SJerome Glisse tmp &= RADEON_SDRAM_MODE_MASK; 3120771fe6b9SJerome Glisse tmp |= or_mask; 3121771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 3122771fe6b9SJerome Glisse 3123771fe6b9SJerome Glisse or_mask = val << 24; 3124771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 3125771fe6b9SJerome Glisse tmp &= RADEON_B3MEM_RESET_MASK; 3126771fe6b9SJerome Glisse tmp |= or_mask; 3127771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 3128771fe6b9SJerome Glisse } 3129771fe6b9SJerome Glisse val = RBIOS8(offset); 3130771fe6b9SJerome Glisse } 3131771fe6b9SJerome Glisse } 3132771fe6b9SJerome Glisse } 3133771fe6b9SJerome Glisse 3134771fe6b9SJerome Glisse static uint32_t combios_detect_ram(struct drm_device *dev, int ram, 3135771fe6b9SJerome Glisse int mem_addr_mapping) 3136771fe6b9SJerome Glisse { 3137771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3138771fe6b9SJerome Glisse uint32_t mem_cntl; 3139771fe6b9SJerome Glisse uint32_t mem_size; 3140771fe6b9SJerome Glisse uint32_t addr = 0; 3141771fe6b9SJerome Glisse 3142771fe6b9SJerome Glisse mem_cntl = RREG32(RADEON_MEM_CNTL); 3143771fe6b9SJerome Glisse if (mem_cntl & RV100_HALF_MODE) 3144771fe6b9SJerome Glisse ram /= 2; 3145771fe6b9SJerome Glisse mem_size = ram; 3146771fe6b9SJerome Glisse mem_cntl &= ~(0xff << 8); 3147771fe6b9SJerome Glisse mem_cntl |= (mem_addr_mapping & 0xff) << 8; 3148771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 3149771fe6b9SJerome Glisse RREG32(RADEON_MEM_CNTL); 3150771fe6b9SJerome Glisse 3151771fe6b9SJerome Glisse /* sdram reset ? */ 3152771fe6b9SJerome Glisse 3153771fe6b9SJerome Glisse /* something like this???? */ 3154771fe6b9SJerome Glisse while (ram--) { 3155771fe6b9SJerome Glisse addr = ram * 1024 * 1024; 3156771fe6b9SJerome Glisse /* write to each page */ 3157771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 3158771fe6b9SJerome Glisse WREG32(RADEON_MM_DATA, 0xdeadbeef); 3159771fe6b9SJerome Glisse /* read back and verify */ 3160771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 3161771fe6b9SJerome Glisse if (RREG32(RADEON_MM_DATA) != 0xdeadbeef) 3162771fe6b9SJerome Glisse return 0; 3163771fe6b9SJerome Glisse } 3164771fe6b9SJerome Glisse 3165771fe6b9SJerome Glisse return mem_size; 3166771fe6b9SJerome Glisse } 3167771fe6b9SJerome Glisse 3168771fe6b9SJerome Glisse static void combios_write_ram_size(struct drm_device *dev) 3169771fe6b9SJerome Glisse { 3170771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3171771fe6b9SJerome Glisse uint8_t rev; 3172771fe6b9SJerome Glisse uint16_t offset; 3173771fe6b9SJerome Glisse uint32_t mem_size = 0; 3174771fe6b9SJerome Glisse uint32_t mem_cntl = 0; 3175771fe6b9SJerome Glisse 3176771fe6b9SJerome Glisse /* should do something smarter here I guess... */ 3177771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_IGP) 3178771fe6b9SJerome Glisse return; 3179771fe6b9SJerome Glisse 3180771fe6b9SJerome Glisse /* first check detected mem table */ 3181771fe6b9SJerome Glisse offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE); 3182771fe6b9SJerome Glisse if (offset) { 3183771fe6b9SJerome Glisse rev = RBIOS8(offset); 3184771fe6b9SJerome Glisse if (rev < 3) { 3185771fe6b9SJerome Glisse mem_cntl = RBIOS32(offset + 1); 3186771fe6b9SJerome Glisse mem_size = RBIOS16(offset + 5); 31874ce9198eSAlex Deucher if ((rdev->family < CHIP_R200) && 31884ce9198eSAlex Deucher !ASIC_IS_RN50(rdev)) 3189771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 3190771fe6b9SJerome Glisse } 3191771fe6b9SJerome Glisse } 3192771fe6b9SJerome Glisse 3193771fe6b9SJerome Glisse if (!mem_size) { 3194771fe6b9SJerome Glisse offset = 3195771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 3196771fe6b9SJerome Glisse if (offset) { 3197771fe6b9SJerome Glisse rev = RBIOS8(offset - 1); 3198771fe6b9SJerome Glisse if (rev < 1) { 31994ce9198eSAlex Deucher if ((rdev->family < CHIP_R200) 32004ce9198eSAlex Deucher && !ASIC_IS_RN50(rdev)) { 3201771fe6b9SJerome Glisse int ram = 0; 3202771fe6b9SJerome Glisse int mem_addr_mapping = 0; 3203771fe6b9SJerome Glisse 3204771fe6b9SJerome Glisse while (RBIOS8(offset)) { 3205771fe6b9SJerome Glisse ram = RBIOS8(offset); 3206771fe6b9SJerome Glisse mem_addr_mapping = 3207771fe6b9SJerome Glisse RBIOS8(offset + 1); 3208771fe6b9SJerome Glisse if (mem_addr_mapping != 0x25) 3209771fe6b9SJerome Glisse ram *= 2; 3210771fe6b9SJerome Glisse mem_size = 3211771fe6b9SJerome Glisse combios_detect_ram(dev, ram, 3212771fe6b9SJerome Glisse mem_addr_mapping); 3213771fe6b9SJerome Glisse if (mem_size) 3214771fe6b9SJerome Glisse break; 3215771fe6b9SJerome Glisse offset += 2; 3216771fe6b9SJerome Glisse } 3217771fe6b9SJerome Glisse } else 3218771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 3219771fe6b9SJerome Glisse } else { 3220771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 3221771fe6b9SJerome Glisse mem_size *= 2; /* convert to MB */ 3222771fe6b9SJerome Glisse } 3223771fe6b9SJerome Glisse } 3224771fe6b9SJerome Glisse } 3225771fe6b9SJerome Glisse 3226771fe6b9SJerome Glisse mem_size *= (1024 * 1024); /* convert to bytes */ 3227771fe6b9SJerome Glisse WREG32(RADEON_CONFIG_MEMSIZE, mem_size); 3228771fe6b9SJerome Glisse } 3229771fe6b9SJerome Glisse 3230771fe6b9SJerome Glisse void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable) 3231771fe6b9SJerome Glisse { 3232771fe6b9SJerome Glisse uint16_t dyn_clk_info = 3233771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 3234771fe6b9SJerome Glisse 3235771fe6b9SJerome Glisse if (dyn_clk_info) 3236771fe6b9SJerome Glisse combios_parse_pll_table(dev, dyn_clk_info); 3237771fe6b9SJerome Glisse } 3238771fe6b9SJerome Glisse 3239771fe6b9SJerome Glisse void radeon_combios_asic_init(struct drm_device *dev) 3240771fe6b9SJerome Glisse { 3241771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3242771fe6b9SJerome Glisse uint16_t table; 3243771fe6b9SJerome Glisse 3244771fe6b9SJerome Glisse /* port hardcoded mac stuff from radeonfb */ 3245771fe6b9SJerome Glisse if (rdev->bios == NULL) 3246771fe6b9SJerome Glisse return; 3247771fe6b9SJerome Glisse 3248771fe6b9SJerome Glisse /* ASIC INIT 1 */ 3249771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE); 3250771fe6b9SJerome Glisse if (table) 3251771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3252771fe6b9SJerome Glisse 3253771fe6b9SJerome Glisse /* PLL INIT */ 3254771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE); 3255771fe6b9SJerome Glisse if (table) 3256771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 3257771fe6b9SJerome Glisse 3258771fe6b9SJerome Glisse /* ASIC INIT 2 */ 3259771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE); 3260771fe6b9SJerome Glisse if (table) 3261771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3262771fe6b9SJerome Glisse 3263771fe6b9SJerome Glisse if (!(rdev->flags & RADEON_IS_IGP)) { 3264771fe6b9SJerome Glisse /* ASIC INIT 4 */ 3265771fe6b9SJerome Glisse table = 3266771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE); 3267771fe6b9SJerome Glisse if (table) 3268771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3269771fe6b9SJerome Glisse 3270771fe6b9SJerome Glisse /* RAM RESET */ 3271771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE); 3272771fe6b9SJerome Glisse if (table) 3273771fe6b9SJerome Glisse combios_parse_ram_reset_table(dev, table); 3274771fe6b9SJerome Glisse 3275771fe6b9SJerome Glisse /* ASIC INIT 3 */ 3276771fe6b9SJerome Glisse table = 3277771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE); 3278771fe6b9SJerome Glisse if (table) 3279771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3280771fe6b9SJerome Glisse 3281771fe6b9SJerome Glisse /* write CONFIG_MEMSIZE */ 3282771fe6b9SJerome Glisse combios_write_ram_size(dev); 3283771fe6b9SJerome Glisse } 3284771fe6b9SJerome Glisse 3285580b4fffSDave Airlie /* quirk for rs4xx HP nx6125 laptop to make it resume 3286580b4fffSDave Airlie * - it hangs on resume inside the dynclk 1 table. 3287580b4fffSDave Airlie */ 3288580b4fffSDave Airlie if (rdev->family == CHIP_RS480 && 3289580b4fffSDave Airlie rdev->pdev->subsystem_vendor == 0x103c && 3290580b4fffSDave Airlie rdev->pdev->subsystem_device == 0x308b) 3291580b4fffSDave Airlie return; 3292580b4fffSDave Airlie 329352fa2bbcSAlex Deucher /* quirk for rs4xx HP dv5000 laptop to make it resume 329452fa2bbcSAlex Deucher * - it hangs on resume inside the dynclk 1 table. 329552fa2bbcSAlex Deucher */ 329652fa2bbcSAlex Deucher if (rdev->family == CHIP_RS480 && 329752fa2bbcSAlex Deucher rdev->pdev->subsystem_vendor == 0x103c && 329852fa2bbcSAlex Deucher rdev->pdev->subsystem_device == 0x30a4) 329952fa2bbcSAlex Deucher return; 330052fa2bbcSAlex Deucher 3301302a8e8bSAlex Deucher /* quirk for rs4xx Compaq Presario V5245EU laptop to make it resume 3302302a8e8bSAlex Deucher * - it hangs on resume inside the dynclk 1 table. 3303302a8e8bSAlex Deucher */ 3304302a8e8bSAlex Deucher if (rdev->family == CHIP_RS480 && 3305302a8e8bSAlex Deucher rdev->pdev->subsystem_vendor == 0x103c && 3306302a8e8bSAlex Deucher rdev->pdev->subsystem_device == 0x30ae) 3307302a8e8bSAlex Deucher return; 3308302a8e8bSAlex Deucher 3309771fe6b9SJerome Glisse /* DYN CLK 1 */ 3310771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 3311771fe6b9SJerome Glisse if (table) 3312771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 3313771fe6b9SJerome Glisse 3314771fe6b9SJerome Glisse } 3315771fe6b9SJerome Glisse 3316771fe6b9SJerome Glisse void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev) 3317771fe6b9SJerome Glisse { 3318771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3319771fe6b9SJerome Glisse uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch; 3320771fe6b9SJerome Glisse 3321771fe6b9SJerome Glisse bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); 3322771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3323771fe6b9SJerome Glisse bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH); 3324771fe6b9SJerome Glisse 3325771fe6b9SJerome Glisse /* let the bios control the backlight */ 3326771fe6b9SJerome Glisse bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN; 3327771fe6b9SJerome Glisse 3328771fe6b9SJerome Glisse /* tell the bios not to handle mode switching */ 3329771fe6b9SJerome Glisse bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS | 3330771fe6b9SJerome Glisse RADEON_ACC_MODE_CHANGE); 3331771fe6b9SJerome Glisse 3332771fe6b9SJerome Glisse /* tell the bios a driver is loaded */ 3333771fe6b9SJerome Glisse bios_7_scratch |= RADEON_DRV_LOADED; 3334771fe6b9SJerome Glisse 3335771fe6b9SJerome Glisse WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch); 3336771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3337771fe6b9SJerome Glisse WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch); 3338771fe6b9SJerome Glisse } 3339771fe6b9SJerome Glisse 3340771fe6b9SJerome Glisse void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock) 3341771fe6b9SJerome Glisse { 3342771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3343771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3344771fe6b9SJerome Glisse uint32_t bios_6_scratch; 3345771fe6b9SJerome Glisse 3346771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3347771fe6b9SJerome Glisse 3348771fe6b9SJerome Glisse if (lock) 3349771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DRIVER_CRITICAL; 3350771fe6b9SJerome Glisse else 3351771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DRIVER_CRITICAL; 3352771fe6b9SJerome Glisse 3353771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3354771fe6b9SJerome Glisse } 3355771fe6b9SJerome Glisse 3356771fe6b9SJerome Glisse void 3357771fe6b9SJerome Glisse radeon_combios_connected_scratch_regs(struct drm_connector *connector, 3358771fe6b9SJerome Glisse struct drm_encoder *encoder, 3359771fe6b9SJerome Glisse bool connected) 3360771fe6b9SJerome Glisse { 3361771fe6b9SJerome Glisse struct drm_device *dev = connector->dev; 3362771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3363771fe6b9SJerome Glisse struct radeon_connector *radeon_connector = 3364771fe6b9SJerome Glisse to_radeon_connector(connector); 3365771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3366771fe6b9SJerome Glisse uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH); 3367771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3368771fe6b9SJerome Glisse 3369771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) && 3370771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) { 3371771fe6b9SJerome Glisse if (connected) { 3372d9fdaafbSDave Airlie DRM_DEBUG_KMS("TV1 connected\n"); 3373771fe6b9SJerome Glisse /* fix me */ 3374771fe6b9SJerome Glisse bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO; 3375771fe6b9SJerome Glisse /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */ 3376771fe6b9SJerome Glisse bios_5_scratch |= RADEON_TV1_ON; 3377771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_TV1; 3378771fe6b9SJerome Glisse } else { 3379d9fdaafbSDave Airlie DRM_DEBUG_KMS("TV1 disconnected\n"); 3380771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK; 3381771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_ON; 3382771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_TV1; 3383771fe6b9SJerome Glisse } 3384771fe6b9SJerome Glisse } 3385771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) && 3386771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) { 3387771fe6b9SJerome Glisse if (connected) { 3388d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD1 connected\n"); 3389771fe6b9SJerome Glisse bios_4_scratch |= RADEON_LCD1_ATTACHED; 3390771fe6b9SJerome Glisse bios_5_scratch |= RADEON_LCD1_ON; 3391771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_LCD1; 3392771fe6b9SJerome Glisse } else { 3393d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD1 disconnected\n"); 3394771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_LCD1_ATTACHED; 3395771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_ON; 3396771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_LCD1; 3397771fe6b9SJerome Glisse } 3398771fe6b9SJerome Glisse } 3399771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) && 3400771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) { 3401771fe6b9SJerome Glisse if (connected) { 3402d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT1 connected\n"); 3403771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR; 3404771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT1_ON; 3405771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT1; 3406771fe6b9SJerome Glisse } else { 3407d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT1 disconnected\n"); 3408771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK; 3409771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_ON; 3410771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT1; 3411771fe6b9SJerome Glisse } 3412771fe6b9SJerome Glisse } 3413771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) && 3414771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) { 3415771fe6b9SJerome Glisse if (connected) { 3416d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT2 connected\n"); 3417771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR; 3418771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT2_ON; 3419771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT2; 3420771fe6b9SJerome Glisse } else { 3421d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT2 disconnected\n"); 3422771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK; 3423771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_ON; 3424771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT2; 3425771fe6b9SJerome Glisse } 3426771fe6b9SJerome Glisse } 3427771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) && 3428771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) { 3429771fe6b9SJerome Glisse if (connected) { 3430d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP1 connected\n"); 3431771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP1_ATTACHED; 3432771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP1_ON; 3433771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP1; 3434771fe6b9SJerome Glisse } else { 3435d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP1 disconnected\n"); 3436771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP1_ATTACHED; 3437771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_ON; 3438771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP1; 3439771fe6b9SJerome Glisse } 3440771fe6b9SJerome Glisse } 3441771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) && 3442771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) { 3443771fe6b9SJerome Glisse if (connected) { 3444d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP2 connected\n"); 3445771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP2_ATTACHED; 3446771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP2_ON; 3447771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP2; 3448771fe6b9SJerome Glisse } else { 3449d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP2 disconnected\n"); 3450771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP2_ATTACHED; 3451771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_ON; 3452771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP2; 3453771fe6b9SJerome Glisse } 3454771fe6b9SJerome Glisse } 3455771fe6b9SJerome Glisse WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch); 3456771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3457771fe6b9SJerome Glisse } 3458771fe6b9SJerome Glisse 3459771fe6b9SJerome Glisse void 3460771fe6b9SJerome Glisse radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc) 3461771fe6b9SJerome Glisse { 3462771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3463771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3464771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3465771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3466771fe6b9SJerome Glisse 3467771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { 3468771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_CRTC_MASK; 3469771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT); 3470771fe6b9SJerome Glisse } 3471771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { 3472771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK; 3473771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT); 3474771fe6b9SJerome Glisse } 3475771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { 3476771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK; 3477771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT); 3478771fe6b9SJerome Glisse } 3479771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { 3480771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK; 3481771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT); 3482771fe6b9SJerome Glisse } 3483771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { 3484771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK; 3485771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT); 3486771fe6b9SJerome Glisse } 3487771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { 3488771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK; 3489771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT); 3490771fe6b9SJerome Glisse } 3491771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3492771fe6b9SJerome Glisse } 3493771fe6b9SJerome Glisse 3494771fe6b9SJerome Glisse void 3495771fe6b9SJerome Glisse radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on) 3496771fe6b9SJerome Glisse { 3497771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3498771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3499771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3500771fe6b9SJerome Glisse uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3501771fe6b9SJerome Glisse 3502771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { 3503771fe6b9SJerome Glisse if (on) 3504771fe6b9SJerome Glisse bios_6_scratch |= RADEON_TV_DPMS_ON; 3505771fe6b9SJerome Glisse else 3506771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_TV_DPMS_ON; 3507771fe6b9SJerome Glisse } 3508771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) { 3509771fe6b9SJerome Glisse if (on) 3510771fe6b9SJerome Glisse bios_6_scratch |= RADEON_CRT_DPMS_ON; 3511771fe6b9SJerome Glisse else 3512771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_CRT_DPMS_ON; 3513771fe6b9SJerome Glisse } 3514771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 3515771fe6b9SJerome Glisse if (on) 3516771fe6b9SJerome Glisse bios_6_scratch |= RADEON_LCD_DPMS_ON; 3517771fe6b9SJerome Glisse else 3518771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_LCD_DPMS_ON; 3519771fe6b9SJerome Glisse } 3520771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 3521771fe6b9SJerome Glisse if (on) 3522771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DFP_DPMS_ON; 3523771fe6b9SJerome Glisse else 3524771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DFP_DPMS_ON; 3525771fe6b9SJerome Glisse } 3526771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3527771fe6b9SJerome Glisse } 3528