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 || 547*776f2b7cSAlex Deucher rdev->family == CHIP_R350) { 548508c8d60SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 549*776f2b7cSAlex Deucher ddc = DDC_DVI; 550*776f2b7cSAlex 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 || 556*776f2b7cSAlex Deucher rdev->family == CHIP_R350) { 557179e8078SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 558*776f2b7cSAlex Deucher ddc = DDC_DVI; 559*776f2b7cSAlex Deucher } else if (rdev->family == CHIP_RS300 || 560*776f2b7cSAlex Deucher rdev->family == CHIP_RS400 || 561*776f2b7cSAlex Deucher rdev->family == CHIP_RS480) 562508c8d60SAlex Deucher ddc_line = RADEON_GPIO_MONID; 563*776f2b7cSAlex Deucher else if (rdev->family >= CHIP_RV350) { 564*776f2b7cSAlex Deucher ddc_line = RADEON_GPIO_MONID; 565*776f2b7cSAlex Deucher ddc = DDC_MONID; 566*776f2b7cSAlex 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 */ 623179e8078SAlex Deucher i2c.mask_clk_mask = RADEON_GPIO_EN_1; 624179e8078SAlex Deucher i2c.mask_data_mask = RADEON_GPIO_EN_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 } 782508c8d60SAlex Deucher } else if (rdev->family >= CHIP_R200) { 783508c8d60SAlex Deucher /* 0x68 */ 784179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 785179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 786179e8078SAlex Deucher } else { 787508c8d60SAlex Deucher /* 0x68 */ 788179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 789179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 790508c8d60SAlex Deucher /* 0x6c */ 791179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 792179e8078SAlex Deucher rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "CRT2_DDC"); 793179e8078SAlex Deucher } 794f376b94fSAlex Deucher } 795f376b94fSAlex Deucher 796771fe6b9SJerome Glisse bool radeon_combios_get_clock_info(struct drm_device *dev) 797771fe6b9SJerome Glisse { 798771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 799771fe6b9SJerome Glisse uint16_t pll_info; 800771fe6b9SJerome Glisse struct radeon_pll *p1pll = &rdev->clock.p1pll; 801771fe6b9SJerome Glisse struct radeon_pll *p2pll = &rdev->clock.p2pll; 802771fe6b9SJerome Glisse struct radeon_pll *spll = &rdev->clock.spll; 803771fe6b9SJerome Glisse struct radeon_pll *mpll = &rdev->clock.mpll; 804771fe6b9SJerome Glisse int8_t rev; 805771fe6b9SJerome Glisse uint16_t sclk, mclk; 806771fe6b9SJerome Glisse 807771fe6b9SJerome Glisse pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE); 808771fe6b9SJerome Glisse if (pll_info) { 809771fe6b9SJerome Glisse rev = RBIOS8(pll_info); 810771fe6b9SJerome Glisse 811771fe6b9SJerome Glisse /* pixel clocks */ 812771fe6b9SJerome Glisse p1pll->reference_freq = RBIOS16(pll_info + 0xe); 813771fe6b9SJerome Glisse p1pll->reference_div = RBIOS16(pll_info + 0x10); 814771fe6b9SJerome Glisse p1pll->pll_out_min = RBIOS32(pll_info + 0x12); 815771fe6b9SJerome Glisse p1pll->pll_out_max = RBIOS32(pll_info + 0x16); 81686cb2bbfSAlex Deucher p1pll->lcd_pll_out_min = p1pll->pll_out_min; 81786cb2bbfSAlex Deucher p1pll->lcd_pll_out_max = p1pll->pll_out_max; 818771fe6b9SJerome Glisse 819771fe6b9SJerome Glisse if (rev > 9) { 820771fe6b9SJerome Glisse p1pll->pll_in_min = RBIOS32(pll_info + 0x36); 821771fe6b9SJerome Glisse p1pll->pll_in_max = RBIOS32(pll_info + 0x3a); 822771fe6b9SJerome Glisse } else { 823771fe6b9SJerome Glisse p1pll->pll_in_min = 40; 824771fe6b9SJerome Glisse p1pll->pll_in_max = 500; 825771fe6b9SJerome Glisse } 826771fe6b9SJerome Glisse *p2pll = *p1pll; 827771fe6b9SJerome Glisse 828771fe6b9SJerome Glisse /* system clock */ 829771fe6b9SJerome Glisse spll->reference_freq = RBIOS16(pll_info + 0x1a); 830771fe6b9SJerome Glisse spll->reference_div = RBIOS16(pll_info + 0x1c); 831771fe6b9SJerome Glisse spll->pll_out_min = RBIOS32(pll_info + 0x1e); 832771fe6b9SJerome Glisse spll->pll_out_max = RBIOS32(pll_info + 0x22); 833771fe6b9SJerome Glisse 834771fe6b9SJerome Glisse if (rev > 10) { 835771fe6b9SJerome Glisse spll->pll_in_min = RBIOS32(pll_info + 0x48); 836771fe6b9SJerome Glisse spll->pll_in_max = RBIOS32(pll_info + 0x4c); 837771fe6b9SJerome Glisse } else { 838771fe6b9SJerome Glisse /* ??? */ 839771fe6b9SJerome Glisse spll->pll_in_min = 40; 840771fe6b9SJerome Glisse spll->pll_in_max = 500; 841771fe6b9SJerome Glisse } 842771fe6b9SJerome Glisse 843771fe6b9SJerome Glisse /* memory clock */ 844771fe6b9SJerome Glisse mpll->reference_freq = RBIOS16(pll_info + 0x26); 845771fe6b9SJerome Glisse mpll->reference_div = RBIOS16(pll_info + 0x28); 846771fe6b9SJerome Glisse mpll->pll_out_min = RBIOS32(pll_info + 0x2a); 847771fe6b9SJerome Glisse mpll->pll_out_max = RBIOS32(pll_info + 0x2e); 848771fe6b9SJerome Glisse 849771fe6b9SJerome Glisse if (rev > 10) { 850771fe6b9SJerome Glisse mpll->pll_in_min = RBIOS32(pll_info + 0x5a); 851771fe6b9SJerome Glisse mpll->pll_in_max = RBIOS32(pll_info + 0x5e); 852771fe6b9SJerome Glisse } else { 853771fe6b9SJerome Glisse /* ??? */ 854771fe6b9SJerome Glisse mpll->pll_in_min = 40; 855771fe6b9SJerome Glisse mpll->pll_in_max = 500; 856771fe6b9SJerome Glisse } 857771fe6b9SJerome Glisse 858771fe6b9SJerome Glisse /* default sclk/mclk */ 859771fe6b9SJerome Glisse sclk = RBIOS16(pll_info + 0xa); 860771fe6b9SJerome Glisse mclk = RBIOS16(pll_info + 0x8); 861771fe6b9SJerome Glisse if (sclk == 0) 862771fe6b9SJerome Glisse sclk = 200 * 100; 863771fe6b9SJerome Glisse if (mclk == 0) 864771fe6b9SJerome Glisse mclk = 200 * 100; 865771fe6b9SJerome Glisse 866771fe6b9SJerome Glisse rdev->clock.default_sclk = sclk; 867771fe6b9SJerome Glisse rdev->clock.default_mclk = mclk; 868771fe6b9SJerome Glisse 869771fe6b9SJerome Glisse return true; 870771fe6b9SJerome Glisse } 871771fe6b9SJerome Glisse return false; 872771fe6b9SJerome Glisse } 873771fe6b9SJerome Glisse 87406b6476dSAlex Deucher bool radeon_combios_sideport_present(struct radeon_device *rdev) 87506b6476dSAlex Deucher { 87606b6476dSAlex Deucher struct drm_device *dev = rdev->ddev; 87706b6476dSAlex Deucher u16 igp_info; 87806b6476dSAlex Deucher 8794c70b2eaSAlex Deucher /* sideport is AMD only */ 8804c70b2eaSAlex Deucher if (rdev->family == CHIP_RS400) 8814c70b2eaSAlex Deucher return false; 8824c70b2eaSAlex Deucher 88306b6476dSAlex Deucher igp_info = combios_get_table_offset(dev, COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE); 88406b6476dSAlex Deucher 88506b6476dSAlex Deucher if (igp_info) { 88606b6476dSAlex Deucher if (RBIOS16(igp_info + 0x4)) 88706b6476dSAlex Deucher return true; 88806b6476dSAlex Deucher } 88906b6476dSAlex Deucher return false; 89006b6476dSAlex Deucher } 89106b6476dSAlex Deucher 892246263ccSAlex Deucher static const uint32_t default_primarydac_adj[CHIP_LAST] = { 893246263ccSAlex Deucher 0x00000808, /* r100 */ 894246263ccSAlex Deucher 0x00000808, /* rv100 */ 895246263ccSAlex Deucher 0x00000808, /* rs100 */ 896246263ccSAlex Deucher 0x00000808, /* rv200 */ 897246263ccSAlex Deucher 0x00000808, /* rs200 */ 898246263ccSAlex Deucher 0x00000808, /* r200 */ 899246263ccSAlex Deucher 0x00000808, /* rv250 */ 900246263ccSAlex Deucher 0x00000000, /* rs300 */ 901246263ccSAlex Deucher 0x00000808, /* rv280 */ 902246263ccSAlex Deucher 0x00000808, /* r300 */ 903246263ccSAlex Deucher 0x00000808, /* r350 */ 904246263ccSAlex Deucher 0x00000808, /* rv350 */ 905246263ccSAlex Deucher 0x00000808, /* rv380 */ 906246263ccSAlex Deucher 0x00000808, /* r420 */ 907246263ccSAlex Deucher 0x00000808, /* r423 */ 908246263ccSAlex Deucher 0x00000808, /* rv410 */ 909246263ccSAlex Deucher 0x00000000, /* rs400 */ 910246263ccSAlex Deucher 0x00000000, /* rs480 */ 911246263ccSAlex Deucher }; 912246263ccSAlex Deucher 913246263ccSAlex Deucher static void radeon_legacy_get_primary_dac_info_from_table(struct radeon_device *rdev, 914246263ccSAlex Deucher struct radeon_encoder_primary_dac *p_dac) 915246263ccSAlex Deucher { 916246263ccSAlex Deucher p_dac->ps2_pdac_adj = default_primarydac_adj[rdev->family]; 917246263ccSAlex Deucher return; 918246263ccSAlex Deucher } 919246263ccSAlex Deucher 920771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct 921771fe6b9SJerome Glisse radeon_encoder 922771fe6b9SJerome Glisse *encoder) 923771fe6b9SJerome Glisse { 924771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 925771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 926771fe6b9SJerome Glisse uint16_t dac_info; 927771fe6b9SJerome Glisse uint8_t rev, bg, dac; 928771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *p_dac = NULL; 929246263ccSAlex Deucher int found = 0; 930771fe6b9SJerome Glisse 931246263ccSAlex Deucher p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), 932771fe6b9SJerome Glisse GFP_KERNEL); 933771fe6b9SJerome Glisse 934771fe6b9SJerome Glisse if (!p_dac) 935771fe6b9SJerome Glisse return NULL; 936771fe6b9SJerome Glisse 937246263ccSAlex Deucher /* check CRT table */ 938246263ccSAlex Deucher dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 939246263ccSAlex Deucher if (dac_info) { 940771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 941771fe6b9SJerome Glisse if (rev < 2) { 942771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 943771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf; 944771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 945771fe6b9SJerome Glisse } else { 946771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 947771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x3) & 0xf; 948771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 949771fe6b9SJerome Glisse } 9503a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 9513a89b4a9SAlex Deucher if (p_dac->ps2_pdac_adj) 952246263ccSAlex Deucher found = 1; 953771fe6b9SJerome Glisse } 954771fe6b9SJerome Glisse 955246263ccSAlex Deucher if (!found) /* fallback to defaults */ 956246263ccSAlex Deucher radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac); 957246263ccSAlex Deucher 958771fe6b9SJerome Glisse return p_dac; 959771fe6b9SJerome Glisse } 960771fe6b9SJerome Glisse 961d79766faSAlex Deucher enum radeon_tv_std 962d79766faSAlex Deucher radeon_combios_get_tv_info(struct radeon_device *rdev) 963771fe6b9SJerome Glisse { 964d79766faSAlex Deucher struct drm_device *dev = rdev->ddev; 965771fe6b9SJerome Glisse uint16_t tv_info; 966771fe6b9SJerome Glisse enum radeon_tv_std tv_std = TV_STD_NTSC; 967771fe6b9SJerome Glisse 968771fe6b9SJerome Glisse tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 969771fe6b9SJerome Glisse if (tv_info) { 970771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 971771fe6b9SJerome Glisse switch (RBIOS8(tv_info + 7) & 0xf) { 972771fe6b9SJerome Glisse case 1: 973771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 97440f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: NTSC\n"); 975771fe6b9SJerome Glisse break; 976771fe6b9SJerome Glisse case 2: 977771fe6b9SJerome Glisse tv_std = TV_STD_PAL; 97840f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL\n"); 979771fe6b9SJerome Glisse break; 980771fe6b9SJerome Glisse case 3: 981771fe6b9SJerome Glisse tv_std = TV_STD_PAL_M; 98240f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL-M\n"); 983771fe6b9SJerome Glisse break; 984771fe6b9SJerome Glisse case 4: 985771fe6b9SJerome Glisse tv_std = TV_STD_PAL_60; 98640f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL-60\n"); 987771fe6b9SJerome Glisse break; 988771fe6b9SJerome Glisse case 5: 989771fe6b9SJerome Glisse tv_std = TV_STD_NTSC_J; 99040f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: NTSC-J\n"); 991771fe6b9SJerome Glisse break; 992771fe6b9SJerome Glisse case 6: 993771fe6b9SJerome Glisse tv_std = TV_STD_SCART_PAL; 99440f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: SCART-PAL\n"); 995771fe6b9SJerome Glisse break; 996771fe6b9SJerome Glisse default: 997771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 99840f76d81SAlex Deucher DRM_DEBUG_KMS 999771fe6b9SJerome Glisse ("Unknown TV standard; defaulting to NTSC\n"); 1000771fe6b9SJerome Glisse break; 1001771fe6b9SJerome Glisse } 1002771fe6b9SJerome Glisse 1003771fe6b9SJerome Glisse switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) { 1004771fe6b9SJerome Glisse case 0: 100540f76d81SAlex Deucher DRM_DEBUG_KMS("29.498928713 MHz TV ref clk\n"); 1006771fe6b9SJerome Glisse break; 1007771fe6b9SJerome Glisse case 1: 100840f76d81SAlex Deucher DRM_DEBUG_KMS("28.636360000 MHz TV ref clk\n"); 1009771fe6b9SJerome Glisse break; 1010771fe6b9SJerome Glisse case 2: 101140f76d81SAlex Deucher DRM_DEBUG_KMS("14.318180000 MHz TV ref clk\n"); 1012771fe6b9SJerome Glisse break; 1013771fe6b9SJerome Glisse case 3: 101440f76d81SAlex Deucher DRM_DEBUG_KMS("27.000000000 MHz TV ref clk\n"); 1015771fe6b9SJerome Glisse break; 1016771fe6b9SJerome Glisse default: 1017771fe6b9SJerome Glisse break; 1018771fe6b9SJerome Glisse } 1019771fe6b9SJerome Glisse } 1020771fe6b9SJerome Glisse } 1021771fe6b9SJerome Glisse return tv_std; 1022771fe6b9SJerome Glisse } 1023771fe6b9SJerome Glisse 1024771fe6b9SJerome Glisse static const uint32_t default_tvdac_adj[CHIP_LAST] = { 1025771fe6b9SJerome Glisse 0x00000000, /* r100 */ 1026771fe6b9SJerome Glisse 0x00280000, /* rv100 */ 1027771fe6b9SJerome Glisse 0x00000000, /* rs100 */ 1028771fe6b9SJerome Glisse 0x00880000, /* rv200 */ 1029771fe6b9SJerome Glisse 0x00000000, /* rs200 */ 1030771fe6b9SJerome Glisse 0x00000000, /* r200 */ 1031771fe6b9SJerome Glisse 0x00770000, /* rv250 */ 1032771fe6b9SJerome Glisse 0x00290000, /* rs300 */ 1033771fe6b9SJerome Glisse 0x00560000, /* rv280 */ 1034771fe6b9SJerome Glisse 0x00780000, /* r300 */ 1035771fe6b9SJerome Glisse 0x00770000, /* r350 */ 1036771fe6b9SJerome Glisse 0x00780000, /* rv350 */ 1037771fe6b9SJerome Glisse 0x00780000, /* rv380 */ 1038771fe6b9SJerome Glisse 0x01080000, /* r420 */ 1039771fe6b9SJerome Glisse 0x01080000, /* r423 */ 1040771fe6b9SJerome Glisse 0x01080000, /* rv410 */ 1041771fe6b9SJerome Glisse 0x00780000, /* rs400 */ 1042771fe6b9SJerome Glisse 0x00780000, /* rs480 */ 1043771fe6b9SJerome Glisse }; 1044771fe6b9SJerome Glisse 10456a719e05SDave Airlie static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev, 10466a719e05SDave Airlie struct radeon_encoder_tv_dac *tv_dac) 1047771fe6b9SJerome Glisse { 1048771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; 1049771fe6b9SJerome Glisse if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) 1050771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 0x00880000; 1051771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1052771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10536a719e05SDave Airlie return; 1054771fe6b9SJerome Glisse } 1055771fe6b9SJerome Glisse 1056771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct 1057771fe6b9SJerome Glisse radeon_encoder 1058771fe6b9SJerome Glisse *encoder) 1059771fe6b9SJerome Glisse { 1060771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1061771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1062771fe6b9SJerome Glisse uint16_t dac_info; 1063771fe6b9SJerome Glisse uint8_t rev, bg, dac; 1064771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *tv_dac = NULL; 10656a719e05SDave Airlie int found = 0; 10666a719e05SDave Airlie 10676a719e05SDave Airlie tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); 10686a719e05SDave Airlie if (!tv_dac) 10696a719e05SDave Airlie return NULL; 1070771fe6b9SJerome Glisse 1071771fe6b9SJerome Glisse /* first check TV table */ 1072771fe6b9SJerome Glisse dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 1073771fe6b9SJerome Glisse if (dac_info) { 1074771fe6b9SJerome Glisse rev = RBIOS8(dac_info + 0x3); 1075771fe6b9SJerome Glisse if (rev > 4) { 1076771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 1077771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xd) & 0xf; 1078771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 1079771fe6b9SJerome Glisse 1080771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 1081771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xf) & 0xf; 1082771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 1083771fe6b9SJerome Glisse 1084771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x10) & 0xf; 1085771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x11) & 0xf; 1086771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 10873a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10883a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10896a719e05SDave Airlie found = 1; 1090771fe6b9SJerome Glisse } else if (rev > 1) { 1091771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 1092771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; 1093771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 1094771fe6b9SJerome Glisse 1095771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xd) & 0xf; 1096771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf; 1097771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 1098771fe6b9SJerome Glisse 1099771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 1100771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; 1101771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 11023a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 11033a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 11046a719e05SDave Airlie found = 1; 1105771fe6b9SJerome Glisse } 1106d79766faSAlex Deucher tv_dac->tv_std = radeon_combios_get_tv_info(rdev); 11076a719e05SDave Airlie } 11086a719e05SDave Airlie if (!found) { 1109771fe6b9SJerome Glisse /* then check CRT table */ 1110771fe6b9SJerome Glisse dac_info = 1111771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 1112771fe6b9SJerome Glisse if (dac_info) { 1113771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 1114771fe6b9SJerome Glisse if (rev < 2) { 1115771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x3) & 0xf; 1116771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf; 1117771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 1118771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 1119771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1120771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 11213a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 11223a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 11236a719e05SDave Airlie found = 1; 1124771fe6b9SJerome Glisse } else { 1125771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x4) & 0xf; 1126771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x5) & 0xf; 1127771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 1128771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 1129771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1130771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 11313a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 11323a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 11336a719e05SDave Airlie found = 1; 1134771fe6b9SJerome Glisse } 11356fe7ac3fSAlex Deucher } else { 11366fe7ac3fSAlex Deucher DRM_INFO("No TV DAC info found in BIOS\n"); 1137771fe6b9SJerome Glisse } 1138771fe6b9SJerome Glisse } 1139771fe6b9SJerome Glisse 11406a719e05SDave Airlie if (!found) /* fallback to defaults */ 11416a719e05SDave Airlie radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac); 11426a719e05SDave Airlie 1143771fe6b9SJerome Glisse return tv_dac; 1144771fe6b9SJerome Glisse } 1145771fe6b9SJerome Glisse 1146771fe6b9SJerome Glisse static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct 1147771fe6b9SJerome Glisse radeon_device 1148771fe6b9SJerome Glisse *rdev) 1149771fe6b9SJerome Glisse { 1150771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 1151771fe6b9SJerome Glisse uint32_t fp_vert_stretch, fp_horz_stretch; 1152771fe6b9SJerome Glisse uint32_t ppll_div_sel, ppll_val; 11538b5c7444SMichel Dänzer uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL); 1154771fe6b9SJerome Glisse 1155771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 1156771fe6b9SJerome Glisse 1157771fe6b9SJerome Glisse if (!lvds) 1158771fe6b9SJerome Glisse return NULL; 1159771fe6b9SJerome Glisse 1160771fe6b9SJerome Glisse fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH); 1161771fe6b9SJerome Glisse fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH); 1162771fe6b9SJerome Glisse 11638b5c7444SMichel Dänzer /* These should be fail-safe defaults, fingers crossed */ 11648b5c7444SMichel Dänzer lvds->panel_pwr_delay = 200; 11658b5c7444SMichel Dänzer lvds->panel_vcc_delay = 2000; 11668b5c7444SMichel Dänzer 11678b5c7444SMichel Dänzer lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL); 11688b5c7444SMichel Dänzer lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf; 11698b5c7444SMichel Dänzer lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf; 11708b5c7444SMichel Dänzer 1171771fe6b9SJerome Glisse if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE) 1172de2103e4SAlex Deucher lvds->native_mode.vdisplay = 1173771fe6b9SJerome Glisse ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >> 1174771fe6b9SJerome Glisse RADEON_VERT_PANEL_SHIFT) + 1; 1175771fe6b9SJerome Glisse else 1176de2103e4SAlex Deucher lvds->native_mode.vdisplay = 1177771fe6b9SJerome Glisse (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1; 1178771fe6b9SJerome Glisse 1179771fe6b9SJerome Glisse if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE) 1180de2103e4SAlex Deucher lvds->native_mode.hdisplay = 1181771fe6b9SJerome Glisse (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >> 1182771fe6b9SJerome Glisse RADEON_HORZ_PANEL_SHIFT) + 1) * 8; 1183771fe6b9SJerome Glisse else 1184de2103e4SAlex Deucher lvds->native_mode.hdisplay = 1185771fe6b9SJerome Glisse ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8; 1186771fe6b9SJerome Glisse 1187de2103e4SAlex Deucher if ((lvds->native_mode.hdisplay < 640) || 1188de2103e4SAlex Deucher (lvds->native_mode.vdisplay < 480)) { 1189de2103e4SAlex Deucher lvds->native_mode.hdisplay = 640; 1190de2103e4SAlex Deucher lvds->native_mode.vdisplay = 480; 1191771fe6b9SJerome Glisse } 1192771fe6b9SJerome Glisse 1193771fe6b9SJerome Glisse ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3; 1194771fe6b9SJerome Glisse ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel); 1195771fe6b9SJerome Glisse if ((ppll_val & 0x000707ff) == 0x1bb) 1196771fe6b9SJerome Glisse lvds->use_bios_dividers = false; 1197771fe6b9SJerome Glisse else { 1198771fe6b9SJerome Glisse lvds->panel_ref_divider = 1199771fe6b9SJerome Glisse RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff; 1200771fe6b9SJerome Glisse lvds->panel_post_divider = (ppll_val >> 16) & 0x7; 1201771fe6b9SJerome Glisse lvds->panel_fb_divider = ppll_val & 0x7ff; 1202771fe6b9SJerome Glisse 1203771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1204771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1205771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1206771fe6b9SJerome Glisse } 1207771fe6b9SJerome Glisse lvds->panel_vcc_delay = 200; 1208771fe6b9SJerome Glisse 1209771fe6b9SJerome Glisse DRM_INFO("Panel info derived from registers\n"); 1210de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1211de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1212771fe6b9SJerome Glisse 1213771fe6b9SJerome Glisse return lvds; 1214771fe6b9SJerome Glisse } 1215771fe6b9SJerome Glisse 1216771fe6b9SJerome Glisse struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder 1217771fe6b9SJerome Glisse *encoder) 1218771fe6b9SJerome Glisse { 1219771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1220771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1221771fe6b9SJerome Glisse uint16_t lcd_info; 1222771fe6b9SJerome Glisse uint32_t panel_setup; 1223771fe6b9SJerome Glisse char stmp[30]; 1224771fe6b9SJerome Glisse int tmp, i; 1225771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 1226771fe6b9SJerome Glisse 1227771fe6b9SJerome Glisse lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 1228771fe6b9SJerome Glisse 1229771fe6b9SJerome Glisse if (lcd_info) { 1230771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 1231771fe6b9SJerome Glisse 1232771fe6b9SJerome Glisse if (!lvds) 1233771fe6b9SJerome Glisse return NULL; 1234771fe6b9SJerome Glisse 1235771fe6b9SJerome Glisse for (i = 0; i < 24; i++) 1236771fe6b9SJerome Glisse stmp[i] = RBIOS8(lcd_info + i + 1); 1237771fe6b9SJerome Glisse stmp[24] = 0; 1238771fe6b9SJerome Glisse 1239771fe6b9SJerome Glisse DRM_INFO("Panel ID String: %s\n", stmp); 1240771fe6b9SJerome Glisse 1241de2103e4SAlex Deucher lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19); 1242de2103e4SAlex Deucher lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b); 1243771fe6b9SJerome Glisse 1244de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1245de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1246771fe6b9SJerome Glisse 1247771fe6b9SJerome Glisse lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c); 124894cf6434SAndrew Morton lvds->panel_vcc_delay = min_t(u16, lvds->panel_vcc_delay, 2000); 1249771fe6b9SJerome Glisse 1250771fe6b9SJerome Glisse lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24); 1251771fe6b9SJerome Glisse lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf; 1252771fe6b9SJerome Glisse lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf; 1253771fe6b9SJerome Glisse 1254771fe6b9SJerome Glisse lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e); 1255771fe6b9SJerome Glisse lvds->panel_post_divider = RBIOS8(lcd_info + 0x30); 1256771fe6b9SJerome Glisse lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31); 1257771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1258771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1259771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1260771fe6b9SJerome Glisse 1261771fe6b9SJerome Glisse panel_setup = RBIOS32(lcd_info + 0x39); 1262771fe6b9SJerome Glisse lvds->lvds_gen_cntl = 0xff00; 1263771fe6b9SJerome Glisse if (panel_setup & 0x1) 1264771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT; 1265771fe6b9SJerome Glisse 1266771fe6b9SJerome Glisse if ((panel_setup >> 4) & 0x1) 1267771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE; 1268771fe6b9SJerome Glisse 1269771fe6b9SJerome Glisse switch ((panel_setup >> 8) & 0x7) { 1270771fe6b9SJerome Glisse case 0: 1271771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM; 1272771fe6b9SJerome Glisse break; 1273771fe6b9SJerome Glisse case 1: 1274771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY; 1275771fe6b9SJerome Glisse break; 1276771fe6b9SJerome Glisse case 2: 1277771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY; 1278771fe6b9SJerome Glisse break; 1279771fe6b9SJerome Glisse default: 1280771fe6b9SJerome Glisse break; 1281771fe6b9SJerome Glisse } 1282771fe6b9SJerome Glisse 1283771fe6b9SJerome Glisse if ((panel_setup >> 16) & 0x1) 1284771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW; 1285771fe6b9SJerome Glisse 1286771fe6b9SJerome Glisse if ((panel_setup >> 17) & 0x1) 1287771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW; 1288771fe6b9SJerome Glisse 1289771fe6b9SJerome Glisse if ((panel_setup >> 18) & 0x1) 1290771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW; 1291771fe6b9SJerome Glisse 1292771fe6b9SJerome Glisse if ((panel_setup >> 23) & 0x1) 1293771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL; 1294771fe6b9SJerome Glisse 1295771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000); 1296771fe6b9SJerome Glisse 1297771fe6b9SJerome Glisse for (i = 0; i < 32; i++) { 1298771fe6b9SJerome Glisse tmp = RBIOS16(lcd_info + 64 + i * 2); 1299771fe6b9SJerome Glisse if (tmp == 0) 1300771fe6b9SJerome Glisse break; 1301771fe6b9SJerome Glisse 1302de2103e4SAlex Deucher if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) && 130368b61a7fSAlex Deucher (RBIOS16(tmp + 2) == lvds->native_mode.vdisplay)) { 130468b61a7fSAlex Deucher lvds->native_mode.htotal = lvds->native_mode.hdisplay + 130568b61a7fSAlex Deucher (RBIOS16(tmp + 17) - RBIOS16(tmp + 19)) * 8; 130668b61a7fSAlex Deucher lvds->native_mode.hsync_start = lvds->native_mode.hdisplay + 130768b61a7fSAlex Deucher (RBIOS16(tmp + 21) - RBIOS16(tmp + 19) - 1) * 8; 130868b61a7fSAlex Deucher lvds->native_mode.hsync_end = lvds->native_mode.hsync_start + 130968b61a7fSAlex Deucher (RBIOS8(tmp + 23) * 8); 1310771fe6b9SJerome Glisse 131168b61a7fSAlex Deucher lvds->native_mode.vtotal = lvds->native_mode.vdisplay + 131268b61a7fSAlex Deucher (RBIOS16(tmp + 24) - RBIOS16(tmp + 26)); 131368b61a7fSAlex Deucher lvds->native_mode.vsync_start = lvds->native_mode.vdisplay + 131468b61a7fSAlex Deucher ((RBIOS16(tmp + 28) & 0x7ff) - RBIOS16(tmp + 26)); 131568b61a7fSAlex Deucher lvds->native_mode.vsync_end = lvds->native_mode.vsync_start + 131668b61a7fSAlex Deucher ((RBIOS16(tmp + 28) & 0xf800) >> 11); 1317de2103e4SAlex Deucher 1318de2103e4SAlex Deucher lvds->native_mode.clock = RBIOS16(tmp + 9) * 10; 1319771fe6b9SJerome Glisse lvds->native_mode.flags = 0; 1320de2103e4SAlex Deucher /* set crtc values */ 1321de2103e4SAlex Deucher drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V); 1322de2103e4SAlex Deucher 1323771fe6b9SJerome Glisse } 1324771fe6b9SJerome Glisse } 13256fe7ac3fSAlex Deucher } else { 1326771fe6b9SJerome Glisse DRM_INFO("No panel info found in BIOS\n"); 13278dfaa8a7SMichel Dänzer lvds = radeon_legacy_get_lvds_info_from_regs(rdev); 13286fe7ac3fSAlex Deucher } 132903047cdfSMichel Dänzer 13308dfaa8a7SMichel Dänzer if (lvds) 13318dfaa8a7SMichel Dänzer encoder->native_mode = lvds->native_mode; 1332771fe6b9SJerome Glisse return lvds; 1333771fe6b9SJerome Glisse } 1334771fe6b9SJerome Glisse 1335771fe6b9SJerome Glisse static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = { 1336771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */ 1337771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */ 1338771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */ 1339771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */ 1340771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */ 1341771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */ 1342771fe6b9SJerome Glisse {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */ 1343771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */ 1344771fe6b9SJerome Glisse {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */ 1345771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */ 1346771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */ 1347771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */ 1348771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */ 1349771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */ 1350771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */ 1351771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */ 1352fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */ 1353fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */ 1354771fe6b9SJerome Glisse }; 1355771fe6b9SJerome Glisse 1356445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder, 1357445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1358771fe6b9SJerome Glisse { 1359445282dbSDave Airlie struct drm_device *dev = encoder->base.dev; 1360445282dbSDave Airlie struct radeon_device *rdev = dev->dev_private; 1361771fe6b9SJerome Glisse int i; 1362771fe6b9SJerome Glisse 1363771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 1364771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1365771fe6b9SJerome Glisse default_tmds_pll[rdev->family][i].value; 1366771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq; 1367771fe6b9SJerome Glisse } 1368771fe6b9SJerome Glisse 1369445282dbSDave Airlie return true; 1370771fe6b9SJerome Glisse } 1371771fe6b9SJerome Glisse 1372445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder, 1373445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1374771fe6b9SJerome Glisse { 1375771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1376771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1377771fe6b9SJerome Glisse uint16_t tmds_info; 1378771fe6b9SJerome Glisse int i, n; 1379771fe6b9SJerome Glisse uint8_t ver; 1380771fe6b9SJerome Glisse 1381771fe6b9SJerome Glisse tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 1382771fe6b9SJerome Glisse 1383771fe6b9SJerome Glisse if (tmds_info) { 1384771fe6b9SJerome Glisse ver = RBIOS8(tmds_info); 138540f76d81SAlex Deucher DRM_DEBUG_KMS("DFP table revision: %d\n", ver); 1386771fe6b9SJerome Glisse if (ver == 3) { 1387771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1388771fe6b9SJerome Glisse if (n > 4) 1389771fe6b9SJerome Glisse n = 4; 1390771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1391771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1392771fe6b9SJerome Glisse RBIOS32(tmds_info + i * 10 + 0x08); 1393771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1394771fe6b9SJerome Glisse RBIOS16(tmds_info + i * 10 + 0x10); 1395d9fdaafbSDave Airlie DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", 1396771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1397771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1398771fe6b9SJerome Glisse } 1399771fe6b9SJerome Glisse } else if (ver == 4) { 1400771fe6b9SJerome Glisse int stride = 0; 1401771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1402771fe6b9SJerome Glisse if (n > 4) 1403771fe6b9SJerome Glisse n = 4; 1404771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1405771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1406771fe6b9SJerome Glisse RBIOS32(tmds_info + stride + 0x08); 1407771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1408771fe6b9SJerome Glisse RBIOS16(tmds_info + stride + 0x10); 1409771fe6b9SJerome Glisse if (i == 0) 1410771fe6b9SJerome Glisse stride += 10; 1411771fe6b9SJerome Glisse else 1412771fe6b9SJerome Glisse stride += 6; 1413d9fdaafbSDave Airlie DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", 1414771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1415771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1416771fe6b9SJerome Glisse } 1417771fe6b9SJerome Glisse } 1418fcec570bSAlex Deucher } else { 1419771fe6b9SJerome Glisse DRM_INFO("No TMDS info found in BIOS\n"); 1420fcec570bSAlex Deucher return false; 1421fcec570bSAlex Deucher } 1422445282dbSDave Airlie return true; 1423445282dbSDave Airlie } 1424445282dbSDave Airlie 1425fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder, 1426fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1427771fe6b9SJerome Glisse { 1428771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1429771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1430fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1431fcec570bSAlex Deucher 1432fcec570bSAlex Deucher /* default for macs */ 1433179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1434f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1435fcec570bSAlex Deucher 1436fcec570bSAlex Deucher /* XXX some macs have duallink chips */ 1437fcec570bSAlex Deucher switch (rdev->mode_info.connector_table) { 1438fcec570bSAlex Deucher case CT_POWERBOOK_EXTERNAL: 1439fcec570bSAlex Deucher case CT_MINI_EXTERNAL: 1440fcec570bSAlex Deucher default: 1441fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1442fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1443fcec570bSAlex Deucher break; 1444fcec570bSAlex Deucher } 1445fcec570bSAlex Deucher 1446fcec570bSAlex Deucher return true; 1447fcec570bSAlex Deucher } 1448fcec570bSAlex Deucher 1449fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder, 1450fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1451fcec570bSAlex Deucher { 1452fcec570bSAlex Deucher struct drm_device *dev = encoder->base.dev; 1453fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 1454fcec570bSAlex Deucher uint16_t offset; 1455179e8078SAlex Deucher uint8_t ver; 1456fcec570bSAlex Deucher enum radeon_combios_ddc gpio; 1457fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1458771fe6b9SJerome Glisse 1459fcec570bSAlex Deucher tmds->i2c_bus = NULL; 1460fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 1461179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1462f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1463fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1464fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1465fcec570bSAlex Deucher } else { 1466fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 1467fcec570bSAlex Deucher if (offset) { 1468fcec570bSAlex Deucher ver = RBIOS8(offset); 146940f76d81SAlex Deucher DRM_DEBUG_KMS("External TMDS Table revision: %d\n", ver); 1470fcec570bSAlex Deucher tmds->slave_addr = RBIOS8(offset + 4 + 2); 1471fcec570bSAlex Deucher tmds->slave_addr >>= 1; /* 7 bit addressing */ 1472fcec570bSAlex Deucher gpio = RBIOS8(offset + 4 + 3); 1473179e8078SAlex Deucher if (gpio == DDC_LCD) { 1474179e8078SAlex Deucher /* MM i2c */ 147540bacf16SAlex Deucher i2c_bus.valid = true; 147640bacf16SAlex Deucher i2c_bus.hw_capable = true; 147740bacf16SAlex Deucher i2c_bus.mm_i2c = true; 1478179e8078SAlex Deucher i2c_bus.i2c_id = 0xa0; 1479179e8078SAlex Deucher } else 1480179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0); 1481f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1482fcec570bSAlex Deucher } 1483fcec570bSAlex Deucher } 1484fcec570bSAlex Deucher 1485fcec570bSAlex Deucher if (!tmds->i2c_bus) { 1486fcec570bSAlex Deucher DRM_INFO("No valid Ext TMDS info found in BIOS\n"); 1487fcec570bSAlex Deucher return false; 1488fcec570bSAlex Deucher } 1489fcec570bSAlex Deucher 1490fcec570bSAlex Deucher return true; 1491fcec570bSAlex Deucher } 1492771fe6b9SJerome Glisse 1493771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) 1494771fe6b9SJerome Glisse { 1495771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1496771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 1497eed45b30SAlex Deucher struct radeon_hpd hpd; 1498771fe6b9SJerome Glisse 1499771fe6b9SJerome Glisse rdev->mode_info.connector_table = radeon_connector_table; 1500771fe6b9SJerome Glisse if (rdev->mode_info.connector_table == CT_NONE) { 1501771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 150271a157e8SGrant Likely if (of_machine_is_compatible("PowerBook3,3")) { 1503771fe6b9SJerome Glisse /* powerbook with VGA */ 1504771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_VGA; 150571a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook3,4") || 150671a157e8SGrant Likely of_machine_is_compatible("PowerBook3,5")) { 1507771fe6b9SJerome Glisse /* powerbook with internal tmds */ 1508771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; 150971a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,1") || 151071a157e8SGrant Likely of_machine_is_compatible("PowerBook5,2") || 151171a157e8SGrant Likely of_machine_is_compatible("PowerBook5,3") || 151271a157e8SGrant Likely of_machine_is_compatible("PowerBook5,4") || 151371a157e8SGrant Likely of_machine_is_compatible("PowerBook5,5")) { 1514771fe6b9SJerome Glisse /* powerbook with external single link tmds (sil164) */ 1515771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 151671a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,6")) { 1517771fe6b9SJerome Glisse /* powerbook with external dual or single link tmds */ 1518771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 151971a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,7") || 152071a157e8SGrant Likely of_machine_is_compatible("PowerBook5,8") || 152171a157e8SGrant Likely of_machine_is_compatible("PowerBook5,9")) { 1522771fe6b9SJerome Glisse /* PowerBook6,2 ? */ 1523771fe6b9SJerome Glisse /* powerbook with external dual link tmds (sil1178?) */ 1524771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 152571a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook4,1") || 152671a157e8SGrant Likely of_machine_is_compatible("PowerBook4,2") || 152771a157e8SGrant Likely of_machine_is_compatible("PowerBook4,3") || 152871a157e8SGrant Likely of_machine_is_compatible("PowerBook6,3") || 152971a157e8SGrant Likely of_machine_is_compatible("PowerBook6,5") || 153071a157e8SGrant Likely of_machine_is_compatible("PowerBook6,7")) { 1531771fe6b9SJerome Glisse /* ibook */ 1532771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IBOOK; 153371a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac4,4")) { 1534771fe6b9SJerome Glisse /* emac */ 1535771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_EMAC; 153671a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac10,1")) { 1537771fe6b9SJerome Glisse /* mini with internal tmds */ 1538771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_INTERNAL; 153971a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac10,2")) { 1540771fe6b9SJerome Glisse /* mini with external tmds */ 1541771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_EXTERNAL; 154271a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac12,1")) { 1543771fe6b9SJerome Glisse /* PowerMac8,1 ? */ 1544771fe6b9SJerome Glisse /* imac g5 isight */ 1545771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; 1546aa74fbb4SAlex Deucher } else if ((rdev->pdev->device == 0x4a48) && 1547aa74fbb4SAlex Deucher (rdev->pdev->subsystem_vendor == 0x1002) && 1548aa74fbb4SAlex Deucher (rdev->pdev->subsystem_device == 0x4a48)) { 1549aa74fbb4SAlex Deucher /* Mac X800 */ 1550aa74fbb4SAlex Deucher rdev->mode_info.connector_table = CT_MAC_X800; 15519fad321aSAlex Deucher } else if ((rdev->pdev->device == 0x4150) && 15529fad321aSAlex Deucher (rdev->pdev->subsystem_vendor == 0x1002) && 15539fad321aSAlex Deucher (rdev->pdev->subsystem_device == 0x4150)) { 15549fad321aSAlex Deucher /* Mac G5 9600 */ 15559fad321aSAlex Deucher rdev->mode_info.connector_table = CT_MAC_G5_9600; 1556771fe6b9SJerome Glisse } else 1557771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 155876a7142aSDave Airlie #ifdef CONFIG_PPC64 155976a7142aSDave Airlie if (ASIC_IS_RN50(rdev)) 156076a7142aSDave Airlie rdev->mode_info.connector_table = CT_RN50_POWER; 156176a7142aSDave Airlie else 156276a7142aSDave Airlie #endif 1563771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_GENERIC; 1564771fe6b9SJerome Glisse } 1565771fe6b9SJerome Glisse 1566771fe6b9SJerome Glisse switch (rdev->mode_info.connector_table) { 1567771fe6b9SJerome Glisse case CT_GENERIC: 1568771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (generic)\n", 1569771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1570771fe6b9SJerome Glisse /* these are the most common settings */ 1571771fe6b9SJerome Glisse if (rdev->flags & RADEON_SINGLE_CRTC) { 1572771fe6b9SJerome Glisse /* VGA - primary dac */ 1573179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1574eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1575771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15765137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1577771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1578771fe6b9SJerome Glisse 1), 1579771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1580771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1581771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1582771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1583b75fad06SAlex Deucher &ddc_i2c, 1584eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1585eed45b30SAlex Deucher &hpd); 1586771fe6b9SJerome Glisse } else if (rdev->flags & RADEON_IS_MOBILITY) { 1587771fe6b9SJerome Glisse /* LVDS */ 1588179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_NONE_DETECTED, 0, 0); 1589eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1590771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15915137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1592771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1593771fe6b9SJerome Glisse 0), 1594771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1595771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1596771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1597771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 1598b75fad06SAlex Deucher &ddc_i2c, 1599eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1600eed45b30SAlex Deucher &hpd); 1601771fe6b9SJerome Glisse 1602771fe6b9SJerome Glisse /* VGA - primary dac */ 1603179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1604eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1605771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16065137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1607771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1608771fe6b9SJerome Glisse 1), 1609771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1610771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1611771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1612771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1613b75fad06SAlex Deucher &ddc_i2c, 1614eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1615eed45b30SAlex Deucher &hpd); 1616771fe6b9SJerome Glisse } else { 1617771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1618179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1619eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 1620771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16215137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1622771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1623771fe6b9SJerome Glisse 0), 1624771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1625771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16265137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1627771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1628771fe6b9SJerome Glisse 2), 1629771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1630771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1631771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1632771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1633771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 1634b75fad06SAlex Deucher &ddc_i2c, 1635eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1636eed45b30SAlex Deucher &hpd); 1637771fe6b9SJerome Glisse 1638771fe6b9SJerome Glisse /* VGA - primary dac */ 1639179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1640eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1641771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16425137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1643771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1644771fe6b9SJerome Glisse 1), 1645771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1646771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1647771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1648771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1649b75fad06SAlex Deucher &ddc_i2c, 1650eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1651eed45b30SAlex Deucher &hpd); 1652771fe6b9SJerome Glisse } 1653771fe6b9SJerome Glisse 1654771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 1655771fe6b9SJerome Glisse /* TV - tv dac */ 1656eed45b30SAlex Deucher ddc_i2c.valid = false; 1657eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1658771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16595137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1660771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1661771fe6b9SJerome Glisse 2), 1662771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1663771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, 1664771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1665771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1666b75fad06SAlex Deucher &ddc_i2c, 1667eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1668eed45b30SAlex Deucher &hpd); 1669771fe6b9SJerome Glisse } 1670771fe6b9SJerome Glisse break; 1671771fe6b9SJerome Glisse case CT_IBOOK: 1672771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (ibook)\n", 1673771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1674771fe6b9SJerome Glisse /* LVDS */ 1675179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1676eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1677771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16785137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1679771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1680771fe6b9SJerome Glisse 0), 1681771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1682771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1683b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1684eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1685eed45b30SAlex Deucher &hpd); 1686771fe6b9SJerome Glisse /* VGA - TV DAC */ 1687179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1688eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1689771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16905137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1691771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1692771fe6b9SJerome Glisse 2), 1693771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1694771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1695b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1696eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1697eed45b30SAlex Deucher &hpd); 1698771fe6b9SJerome Glisse /* TV - TV DAC */ 1699eed45b30SAlex Deucher ddc_i2c.valid = false; 1700eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1701771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17025137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1703771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1704771fe6b9SJerome Glisse 2), 1705771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1706771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1707771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1708b75fad06SAlex Deucher &ddc_i2c, 1709eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1710eed45b30SAlex Deucher &hpd); 1711771fe6b9SJerome Glisse break; 1712771fe6b9SJerome Glisse case CT_POWERBOOK_EXTERNAL: 1713771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook external tmds)\n", 1714771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1715771fe6b9SJerome Glisse /* LVDS */ 1716179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1717eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1718771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17195137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1720771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1721771fe6b9SJerome Glisse 0), 1722771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1723771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1724b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1725eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1726eed45b30SAlex Deucher &hpd); 1727771fe6b9SJerome Glisse /* DVI-I - primary dac, ext tmds */ 1728179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1729eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1730771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17315137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1732771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1733771fe6b9SJerome Glisse 0), 1734771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1735771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17365137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1737771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1738771fe6b9SJerome Glisse 1), 1739771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1740b75fad06SAlex Deucher /* XXX some are SL */ 1741771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1742771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1743771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1744b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1745eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 1746eed45b30SAlex Deucher &hpd); 1747771fe6b9SJerome Glisse /* TV - TV DAC */ 1748eed45b30SAlex Deucher ddc_i2c.valid = false; 1749eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1750771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17515137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1752771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1753771fe6b9SJerome Glisse 2), 1754771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1755771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1756771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1757b75fad06SAlex Deucher &ddc_i2c, 1758eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1759eed45b30SAlex Deucher &hpd); 1760771fe6b9SJerome Glisse break; 1761771fe6b9SJerome Glisse case CT_POWERBOOK_INTERNAL: 1762771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook internal tmds)\n", 1763771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1764771fe6b9SJerome Glisse /* LVDS */ 1765179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1766eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1767771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17685137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1769771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1770771fe6b9SJerome Glisse 0), 1771771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1772771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1773b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1774eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1775eed45b30SAlex Deucher &hpd); 1776771fe6b9SJerome Glisse /* DVI-I - primary dac, int tmds */ 1777179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1778eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1779771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17805137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1781771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1782771fe6b9SJerome Glisse 0), 1783771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1784771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17855137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1786771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1787771fe6b9SJerome Glisse 1), 1788771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1789771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1790771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1791771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1792b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1793eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1794eed45b30SAlex Deucher &hpd); 1795771fe6b9SJerome Glisse /* TV - TV DAC */ 1796eed45b30SAlex Deucher ddc_i2c.valid = false; 1797eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1798771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17995137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1800771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1801771fe6b9SJerome Glisse 2), 1802771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1803771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1804771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1805b75fad06SAlex Deucher &ddc_i2c, 1806eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1807eed45b30SAlex Deucher &hpd); 1808771fe6b9SJerome Glisse break; 1809771fe6b9SJerome Glisse case CT_POWERBOOK_VGA: 1810771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook vga)\n", 1811771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1812771fe6b9SJerome Glisse /* LVDS */ 1813179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1814eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1815771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18165137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1817771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1818771fe6b9SJerome Glisse 0), 1819771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1820771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1821b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1822eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1823eed45b30SAlex Deucher &hpd); 1824771fe6b9SJerome Glisse /* VGA - primary dac */ 1825179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1826eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1827771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18285137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1829771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1830771fe6b9SJerome Glisse 1), 1831771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1832771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT, 1833b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1834eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1835eed45b30SAlex Deucher &hpd); 1836771fe6b9SJerome Glisse /* TV - TV DAC */ 1837eed45b30SAlex Deucher ddc_i2c.valid = false; 1838eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1839771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18405137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1841771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1842771fe6b9SJerome Glisse 2), 1843771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1844771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1845771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1846b75fad06SAlex Deucher &ddc_i2c, 1847eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1848eed45b30SAlex Deucher &hpd); 1849771fe6b9SJerome Glisse break; 1850771fe6b9SJerome Glisse case CT_MINI_EXTERNAL: 1851771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini external tmds)\n", 1852771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1853771fe6b9SJerome Glisse /* DVI-I - tv dac, ext tmds */ 1854179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1855eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1856771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18575137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1858771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1859771fe6b9SJerome Glisse 0), 1860771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1861771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18625137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1863771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1864771fe6b9SJerome Glisse 2), 1865771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1866b75fad06SAlex Deucher /* XXX are any DL? */ 1867771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1868771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1869771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1870b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1871eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1872eed45b30SAlex Deucher &hpd); 1873771fe6b9SJerome Glisse /* TV - TV DAC */ 1874eed45b30SAlex Deucher ddc_i2c.valid = false; 1875eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1876771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18775137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1878771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1879771fe6b9SJerome Glisse 2), 1880771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1881771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1882771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1883b75fad06SAlex Deucher &ddc_i2c, 1884eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1885eed45b30SAlex Deucher &hpd); 1886771fe6b9SJerome Glisse break; 1887771fe6b9SJerome Glisse case CT_MINI_INTERNAL: 1888771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini internal tmds)\n", 1889771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1890771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1891179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1892eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1893771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18945137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1895771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1896771fe6b9SJerome Glisse 0), 1897771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1898771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18995137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1900771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1901771fe6b9SJerome Glisse 2), 1902771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1903771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1904771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1905771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1906b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1907eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1908eed45b30SAlex Deucher &hpd); 1909771fe6b9SJerome Glisse /* TV - TV DAC */ 1910eed45b30SAlex Deucher ddc_i2c.valid = false; 1911eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1912771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19135137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1914771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1915771fe6b9SJerome Glisse 2), 1916771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1917771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1918771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1919b75fad06SAlex Deucher &ddc_i2c, 1920eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1921eed45b30SAlex Deucher &hpd); 1922771fe6b9SJerome Glisse break; 1923771fe6b9SJerome Glisse case CT_IMAC_G5_ISIGHT: 1924771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (imac g5 isight)\n", 1925771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1926771fe6b9SJerome Glisse /* DVI-D - int tmds */ 1927179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1928eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1929771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19305137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1931771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1932771fe6b9SJerome Glisse 0), 1933771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1934771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT, 1935b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVID, &ddc_i2c, 1936eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 1937eed45b30SAlex Deucher &hpd); 1938771fe6b9SJerome Glisse /* VGA - tv dac */ 1939179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1940eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1941771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19425137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1943771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1944771fe6b9SJerome Glisse 2), 1945771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1946771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1947b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1948eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1949eed45b30SAlex Deucher &hpd); 1950771fe6b9SJerome Glisse /* TV - TV DAC */ 1951eed45b30SAlex Deucher ddc_i2c.valid = false; 1952eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1953771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19545137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1955771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1956771fe6b9SJerome Glisse 2), 1957771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1958771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1959771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1960b75fad06SAlex Deucher &ddc_i2c, 1961eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1962eed45b30SAlex Deucher &hpd); 1963771fe6b9SJerome Glisse break; 1964771fe6b9SJerome Glisse case CT_EMAC: 1965771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (emac)\n", 1966771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1967771fe6b9SJerome Glisse /* VGA - primary dac */ 1968179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1969eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1970771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19715137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1972771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1973771fe6b9SJerome Glisse 1), 1974771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1975771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 1976b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1977eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1978eed45b30SAlex Deucher &hpd); 1979771fe6b9SJerome Glisse /* VGA - tv dac */ 1980179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1981eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1982771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19835137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1984771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1985771fe6b9SJerome Glisse 2), 1986771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1987771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1988b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1989eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1990eed45b30SAlex Deucher &hpd); 1991771fe6b9SJerome Glisse /* TV - TV DAC */ 1992eed45b30SAlex Deucher ddc_i2c.valid = false; 1993eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1994771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19955137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1996771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1997771fe6b9SJerome Glisse 2), 1998771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1999771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 2000771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 2001b75fad06SAlex Deucher &ddc_i2c, 2002eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2003eed45b30SAlex Deucher &hpd); 2004771fe6b9SJerome Glisse break; 200576a7142aSDave Airlie case CT_RN50_POWER: 200676a7142aSDave Airlie DRM_INFO("Connector Table: %d (rn50-power)\n", 200776a7142aSDave Airlie rdev->mode_info.connector_table); 200876a7142aSDave Airlie /* VGA - primary dac */ 2009179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 201076a7142aSDave Airlie hpd.hpd = RADEON_HPD_NONE; 201176a7142aSDave Airlie radeon_add_legacy_encoder(dev, 20125137ee94SAlex Deucher radeon_get_encoder_enum(dev, 201376a7142aSDave Airlie ATOM_DEVICE_CRT1_SUPPORT, 201476a7142aSDave Airlie 1), 201576a7142aSDave Airlie ATOM_DEVICE_CRT1_SUPPORT); 201676a7142aSDave Airlie radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 201776a7142aSDave Airlie DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 201876a7142aSDave Airlie CONNECTOR_OBJECT_ID_VGA, 201976a7142aSDave Airlie &hpd); 2020179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 202176a7142aSDave Airlie hpd.hpd = RADEON_HPD_NONE; 202276a7142aSDave Airlie radeon_add_legacy_encoder(dev, 20235137ee94SAlex Deucher radeon_get_encoder_enum(dev, 202476a7142aSDave Airlie ATOM_DEVICE_CRT2_SUPPORT, 202576a7142aSDave Airlie 2), 202676a7142aSDave Airlie ATOM_DEVICE_CRT2_SUPPORT); 202776a7142aSDave Airlie radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 202876a7142aSDave Airlie DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 202976a7142aSDave Airlie CONNECTOR_OBJECT_ID_VGA, 203076a7142aSDave Airlie &hpd); 203176a7142aSDave Airlie break; 2032aa74fbb4SAlex Deucher case CT_MAC_X800: 2033aa74fbb4SAlex Deucher DRM_INFO("Connector Table: %d (mac x800)\n", 2034aa74fbb4SAlex Deucher rdev->mode_info.connector_table); 2035aa74fbb4SAlex Deucher /* DVI - primary dac, internal tmds */ 2036aa74fbb4SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 2037aa74fbb4SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 2038aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2039aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2040aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 2041aa74fbb4SAlex Deucher 0), 2042aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 2043aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2044aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2045aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2046aa74fbb4SAlex Deucher 1), 2047aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 2048aa74fbb4SAlex Deucher radeon_add_legacy_connector(dev, 0, 2049aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 2050aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2051aa74fbb4SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 2052aa74fbb4SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2053aa74fbb4SAlex Deucher &hpd); 2054aa74fbb4SAlex Deucher /* DVI - tv dac, dvo */ 2055aa74fbb4SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 2056aa74fbb4SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 2057aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2058aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2059aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT, 2060aa74fbb4SAlex Deucher 0), 2061aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT); 2062aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2063aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2064aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2065aa74fbb4SAlex Deucher 2), 2066aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 2067aa74fbb4SAlex Deucher radeon_add_legacy_connector(dev, 1, 2068aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT | 2069aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2070aa74fbb4SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 2071aa74fbb4SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 2072aa74fbb4SAlex Deucher &hpd); 2073aa74fbb4SAlex Deucher break; 20749fad321aSAlex Deucher case CT_MAC_G5_9600: 20759fad321aSAlex Deucher DRM_INFO("Connector Table: %d (mac g5 9600)\n", 20769fad321aSAlex Deucher rdev->mode_info.connector_table); 20779fad321aSAlex Deucher /* DVI - tv dac, dvo */ 20789fad321aSAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 20799fad321aSAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 20809fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20819fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20829fad321aSAlex Deucher ATOM_DEVICE_DFP2_SUPPORT, 20839fad321aSAlex Deucher 0), 20849fad321aSAlex Deucher ATOM_DEVICE_DFP2_SUPPORT); 20859fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20869fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20879fad321aSAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 20889fad321aSAlex Deucher 2), 20899fad321aSAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 20909fad321aSAlex Deucher radeon_add_legacy_connector(dev, 0, 20919fad321aSAlex Deucher ATOM_DEVICE_DFP2_SUPPORT | 20929fad321aSAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 20939fad321aSAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 20949fad321aSAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 20959fad321aSAlex Deucher &hpd); 20969fad321aSAlex Deucher /* ADC - primary dac, internal tmds */ 20979fad321aSAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 20989fad321aSAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 20999fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 21009fad321aSAlex Deucher radeon_get_encoder_enum(dev, 21019fad321aSAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 21029fad321aSAlex Deucher 0), 21039fad321aSAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 21049fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 21059fad321aSAlex Deucher radeon_get_encoder_enum(dev, 21069fad321aSAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 21079fad321aSAlex Deucher 1), 21089fad321aSAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 21099fad321aSAlex Deucher radeon_add_legacy_connector(dev, 1, 21109fad321aSAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 21119fad321aSAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 21129fad321aSAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 21139fad321aSAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 21149fad321aSAlex Deucher &hpd); 2115beb47274SAlex Deucher /* TV - TV DAC */ 2116beb47274SAlex Deucher ddc_i2c.valid = false; 2117beb47274SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2118beb47274SAlex Deucher radeon_add_legacy_encoder(dev, 2119beb47274SAlex Deucher radeon_get_encoder_enum(dev, 2120beb47274SAlex Deucher ATOM_DEVICE_TV1_SUPPORT, 2121beb47274SAlex Deucher 2), 2122beb47274SAlex Deucher ATOM_DEVICE_TV1_SUPPORT); 2123beb47274SAlex Deucher radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 2124beb47274SAlex Deucher DRM_MODE_CONNECTOR_SVIDEO, 2125beb47274SAlex Deucher &ddc_i2c, 2126beb47274SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2127beb47274SAlex Deucher &hpd); 21289fad321aSAlex Deucher break; 2129771fe6b9SJerome Glisse default: 2130771fe6b9SJerome Glisse DRM_INFO("Connector table: %d (invalid)\n", 2131771fe6b9SJerome Glisse rdev->mode_info.connector_table); 2132771fe6b9SJerome Glisse return false; 2133771fe6b9SJerome Glisse } 2134771fe6b9SJerome Glisse 2135771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2136771fe6b9SJerome Glisse 2137771fe6b9SJerome Glisse return true; 2138771fe6b9SJerome Glisse } 2139771fe6b9SJerome Glisse 2140771fe6b9SJerome Glisse static bool radeon_apply_legacy_quirks(struct drm_device *dev, 2141771fe6b9SJerome Glisse int bios_index, 2142771fe6b9SJerome Glisse enum radeon_combios_connector 2143771fe6b9SJerome Glisse *legacy_connector, 2144eed45b30SAlex Deucher struct radeon_i2c_bus_rec *ddc_i2c, 2145eed45b30SAlex Deucher struct radeon_hpd *hpd) 2146771fe6b9SJerome Glisse { 2147fcec570bSAlex Deucher 2148771fe6b9SJerome Glisse /* Certain IBM chipset RN50s have a BIOS reporting two VGAs, 2149771fe6b9SJerome Glisse one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */ 2150771fe6b9SJerome Glisse if (dev->pdev->device == 0x515e && 2151771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x1014) { 2152771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_CRT_LEGACY && 2153771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 2154771fe6b9SJerome Glisse return false; 2155771fe6b9SJerome Glisse } 2156771fe6b9SJerome Glisse 2157771fe6b9SJerome Glisse /* X300 card with extra non-existent DVI port */ 2158771fe6b9SJerome Glisse if (dev->pdev->device == 0x5B60 && 2159771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x17af && 2160771fe6b9SJerome Glisse dev->pdev->subsystem_device == 0x201e && bios_index == 2) { 2161771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_DVI_I_LEGACY) 2162771fe6b9SJerome Glisse return false; 2163771fe6b9SJerome Glisse } 2164771fe6b9SJerome Glisse 2165771fe6b9SJerome Glisse return true; 2166771fe6b9SJerome Glisse } 2167771fe6b9SJerome Glisse 2168790cfb34SAlex Deucher static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev) 2169790cfb34SAlex Deucher { 2170790cfb34SAlex Deucher /* Acer 5102 has non-existent TV port */ 2171790cfb34SAlex Deucher if (dev->pdev->device == 0x5975 && 2172790cfb34SAlex Deucher dev->pdev->subsystem_vendor == 0x1025 && 2173790cfb34SAlex Deucher dev->pdev->subsystem_device == 0x009f) 2174790cfb34SAlex Deucher return false; 2175790cfb34SAlex Deucher 2176fc7f7119SAlex Deucher /* HP dc5750 has non-existent TV port */ 2177fc7f7119SAlex Deucher if (dev->pdev->device == 0x5974 && 2178fc7f7119SAlex Deucher dev->pdev->subsystem_vendor == 0x103c && 2179fc7f7119SAlex Deucher dev->pdev->subsystem_device == 0x280a) 2180fc7f7119SAlex Deucher return false; 2181fc7f7119SAlex Deucher 2182fd874ad0SAlex Deucher /* MSI S270 has non-existent TV port */ 2183fd874ad0SAlex Deucher if (dev->pdev->device == 0x5955 && 2184fd874ad0SAlex Deucher dev->pdev->subsystem_vendor == 0x1462 && 2185fd874ad0SAlex Deucher dev->pdev->subsystem_device == 0x0131) 2186fd874ad0SAlex Deucher return false; 2187fd874ad0SAlex Deucher 2188790cfb34SAlex Deucher return true; 2189790cfb34SAlex Deucher } 2190790cfb34SAlex Deucher 2191b75fad06SAlex Deucher static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d) 2192b75fad06SAlex Deucher { 2193b75fad06SAlex Deucher struct radeon_device *rdev = dev->dev_private; 2194b75fad06SAlex Deucher uint32_t ext_tmds_info; 2195b75fad06SAlex Deucher 2196b75fad06SAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2197b75fad06SAlex Deucher if (is_dvi_d) 2198b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 2199b75fad06SAlex Deucher else 2200b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2201b75fad06SAlex Deucher } 2202b75fad06SAlex Deucher ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2203b75fad06SAlex Deucher if (ext_tmds_info) { 2204b75fad06SAlex Deucher uint8_t rev = RBIOS8(ext_tmds_info); 2205b75fad06SAlex Deucher uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5); 2206b75fad06SAlex Deucher if (rev >= 3) { 2207b75fad06SAlex Deucher if (is_dvi_d) 2208b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 2209b75fad06SAlex Deucher else 2210b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 2211b75fad06SAlex Deucher } else { 2212b75fad06SAlex Deucher if (flags & 1) { 2213b75fad06SAlex Deucher if (is_dvi_d) 2214b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 2215b75fad06SAlex Deucher else 2216b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 2217b75fad06SAlex Deucher } 2218b75fad06SAlex Deucher } 2219b75fad06SAlex Deucher } 2220b75fad06SAlex Deucher if (is_dvi_d) 2221b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 2222b75fad06SAlex Deucher else 2223b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2224b75fad06SAlex Deucher } 2225b75fad06SAlex Deucher 2226771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) 2227771fe6b9SJerome Glisse { 2228771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2229771fe6b9SJerome Glisse uint32_t conn_info, entry, devices; 2230b75fad06SAlex Deucher uint16_t tmp, connector_object_id; 2231771fe6b9SJerome Glisse enum radeon_combios_ddc ddc_type; 2232771fe6b9SJerome Glisse enum radeon_combios_connector connector; 2233771fe6b9SJerome Glisse int i = 0; 2234771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 2235eed45b30SAlex Deucher struct radeon_hpd hpd; 2236771fe6b9SJerome Glisse 2237771fe6b9SJerome Glisse conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE); 2238771fe6b9SJerome Glisse if (conn_info) { 2239771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 2240771fe6b9SJerome Glisse entry = conn_info + 2 + i * 2; 2241771fe6b9SJerome Glisse 2242771fe6b9SJerome Glisse if (!RBIOS16(entry)) 2243771fe6b9SJerome Glisse break; 2244771fe6b9SJerome Glisse 2245771fe6b9SJerome Glisse tmp = RBIOS16(entry); 2246771fe6b9SJerome Glisse 2247771fe6b9SJerome Glisse connector = (tmp >> 12) & 0xf; 2248771fe6b9SJerome Glisse 2249771fe6b9SJerome Glisse ddc_type = (tmp >> 8) & 0xf; 2250179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, ddc_type, 0, 0); 2251771fe6b9SJerome Glisse 2252eed45b30SAlex Deucher switch (connector) { 2253eed45b30SAlex Deucher case CONNECTOR_PROPRIETARY_LEGACY: 2254eed45b30SAlex Deucher case CONNECTOR_DVI_I_LEGACY: 2255eed45b30SAlex Deucher case CONNECTOR_DVI_D_LEGACY: 2256eed45b30SAlex Deucher if ((tmp >> 4) & 0x1) 2257eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; 2258eed45b30SAlex Deucher else 2259eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 2260eed45b30SAlex Deucher break; 2261eed45b30SAlex Deucher default: 2262eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2263eed45b30SAlex Deucher break; 2264eed45b30SAlex Deucher } 2265eed45b30SAlex Deucher 22662d152c6bSAlex Deucher if (!radeon_apply_legacy_quirks(dev, i, &connector, 2267eed45b30SAlex Deucher &ddc_i2c, &hpd)) 22682d152c6bSAlex Deucher continue; 2269771fe6b9SJerome Glisse 2270771fe6b9SJerome Glisse switch (connector) { 2271771fe6b9SJerome Glisse case CONNECTOR_PROPRIETARY_LEGACY: 2272771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) 2273771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2274771fe6b9SJerome Glisse else 2275771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2276771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22775137ee94SAlex Deucher radeon_get_encoder_enum 2278771fe6b9SJerome Glisse (dev, devices, 0), 2279771fe6b9SJerome Glisse devices); 2280771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2281771fe6b9SJerome Glisse legacy_connector_convert 2282771fe6b9SJerome Glisse [connector], 2283b75fad06SAlex Deucher &ddc_i2c, 2284eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 2285eed45b30SAlex Deucher &hpd); 2286771fe6b9SJerome Glisse break; 2287771fe6b9SJerome Glisse case CONNECTOR_CRT_LEGACY: 2288771fe6b9SJerome Glisse if (tmp & 0x1) { 2289771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT2_SUPPORT; 2290771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22915137ee94SAlex Deucher radeon_get_encoder_enum 2292771fe6b9SJerome Glisse (dev, 2293771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2294771fe6b9SJerome Glisse 2), 2295771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2296771fe6b9SJerome Glisse } else { 2297771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT1_SUPPORT; 2298771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22995137ee94SAlex Deucher radeon_get_encoder_enum 2300771fe6b9SJerome Glisse (dev, 2301771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2302771fe6b9SJerome Glisse 1), 2303771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2304771fe6b9SJerome Glisse } 2305771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2306771fe6b9SJerome Glisse i, 2307771fe6b9SJerome Glisse devices, 2308771fe6b9SJerome Glisse legacy_connector_convert 2309771fe6b9SJerome Glisse [connector], 2310b75fad06SAlex Deucher &ddc_i2c, 2311eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2312eed45b30SAlex Deucher &hpd); 2313771fe6b9SJerome Glisse break; 2314771fe6b9SJerome Glisse case CONNECTOR_DVI_I_LEGACY: 2315771fe6b9SJerome Glisse devices = 0; 2316771fe6b9SJerome Glisse if (tmp & 0x1) { 2317771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT2_SUPPORT; 2318771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23195137ee94SAlex Deucher radeon_get_encoder_enum 2320771fe6b9SJerome Glisse (dev, 2321771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2322771fe6b9SJerome Glisse 2), 2323771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2324771fe6b9SJerome Glisse } else { 2325771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT1_SUPPORT; 2326771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23275137ee94SAlex Deucher radeon_get_encoder_enum 2328771fe6b9SJerome Glisse (dev, 2329771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2330771fe6b9SJerome Glisse 1), 2331771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2332771fe6b9SJerome Glisse } 2333771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) { 2334771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP2_SUPPORT; 2335771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23365137ee94SAlex Deucher radeon_get_encoder_enum 2337771fe6b9SJerome Glisse (dev, 2338771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 2339771fe6b9SJerome Glisse 0), 2340771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 2341b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 0); 2342771fe6b9SJerome Glisse } else { 2343771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP1_SUPPORT; 2344771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23455137ee94SAlex Deucher radeon_get_encoder_enum 2346771fe6b9SJerome Glisse (dev, 2347771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2348771fe6b9SJerome Glisse 0), 2349771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2350b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2351771fe6b9SJerome Glisse } 2352771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2353771fe6b9SJerome Glisse i, 2354771fe6b9SJerome Glisse devices, 2355771fe6b9SJerome Glisse legacy_connector_convert 2356771fe6b9SJerome Glisse [connector], 2357b75fad06SAlex Deucher &ddc_i2c, 2358eed45b30SAlex Deucher connector_object_id, 2359eed45b30SAlex Deucher &hpd); 2360771fe6b9SJerome Glisse break; 2361771fe6b9SJerome Glisse case CONNECTOR_DVI_D_LEGACY: 2362b75fad06SAlex Deucher if ((tmp >> 4) & 0x1) { 2363771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2364b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 1); 2365b75fad06SAlex Deucher } else { 2366771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2367b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2368b75fad06SAlex Deucher } 2369771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23705137ee94SAlex Deucher radeon_get_encoder_enum 2371771fe6b9SJerome Glisse (dev, devices, 0), 2372771fe6b9SJerome Glisse devices); 2373771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2374771fe6b9SJerome Glisse legacy_connector_convert 2375771fe6b9SJerome Glisse [connector], 2376b75fad06SAlex Deucher &ddc_i2c, 2377eed45b30SAlex Deucher connector_object_id, 2378eed45b30SAlex Deucher &hpd); 2379771fe6b9SJerome Glisse break; 2380771fe6b9SJerome Glisse case CONNECTOR_CTV_LEGACY: 2381771fe6b9SJerome Glisse case CONNECTOR_STV_LEGACY: 2382771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23835137ee94SAlex Deucher radeon_get_encoder_enum 2384771fe6b9SJerome Glisse (dev, 2385771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2386771fe6b9SJerome Glisse 2), 2387771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2388771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, 2389771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2390771fe6b9SJerome Glisse legacy_connector_convert 2391771fe6b9SJerome Glisse [connector], 2392b75fad06SAlex Deucher &ddc_i2c, 2393eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2394eed45b30SAlex Deucher &hpd); 2395771fe6b9SJerome Glisse break; 2396771fe6b9SJerome Glisse default: 2397771fe6b9SJerome Glisse DRM_ERROR("Unknown connector type: %d\n", 2398771fe6b9SJerome Glisse connector); 2399771fe6b9SJerome Glisse continue; 2400771fe6b9SJerome Glisse } 2401771fe6b9SJerome Glisse 2402771fe6b9SJerome Glisse } 2403771fe6b9SJerome Glisse } else { 2404771fe6b9SJerome Glisse uint16_t tmds_info = 2405771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 2406771fe6b9SJerome Glisse if (tmds_info) { 2407d9fdaafbSDave Airlie DRM_DEBUG_KMS("Found DFP table, assuming DVI connector\n"); 2408771fe6b9SJerome Glisse 2409771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24105137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2411771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2412771fe6b9SJerome Glisse 1), 2413771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2414771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24155137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2416771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2417771fe6b9SJerome Glisse 0), 2418771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2419771fe6b9SJerome Glisse 2420179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 24218e36ed00SAlex Deucher hpd.hpd = RADEON_HPD_1; 2422771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2423771fe6b9SJerome Glisse 0, 2424771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT | 2425771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2426771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 2427b75fad06SAlex Deucher &ddc_i2c, 2428eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2429eed45b30SAlex Deucher &hpd); 2430771fe6b9SJerome Glisse } else { 2431d0c403e9SAlex Deucher uint16_t crt_info = 2432d0c403e9SAlex Deucher combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 2433d9fdaafbSDave Airlie DRM_DEBUG_KMS("Found CRT table, assuming VGA connector\n"); 2434d0c403e9SAlex Deucher if (crt_info) { 2435d0c403e9SAlex Deucher radeon_add_legacy_encoder(dev, 24365137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2437d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2438d0c403e9SAlex Deucher 1), 2439d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 2440179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 2441eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2442d0c403e9SAlex Deucher radeon_add_legacy_connector(dev, 2443d0c403e9SAlex Deucher 0, 2444d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2445d0c403e9SAlex Deucher DRM_MODE_CONNECTOR_VGA, 2446b75fad06SAlex Deucher &ddc_i2c, 2447eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2448eed45b30SAlex Deucher &hpd); 2449d0c403e9SAlex Deucher } else { 2450d9fdaafbSDave Airlie DRM_DEBUG_KMS("No connector info found\n"); 2451771fe6b9SJerome Glisse return false; 2452771fe6b9SJerome Glisse } 2453771fe6b9SJerome Glisse } 2454d0c403e9SAlex Deucher } 2455771fe6b9SJerome Glisse 2456771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) { 2457771fe6b9SJerome Glisse uint16_t lcd_info = 2458771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 2459771fe6b9SJerome Glisse if (lcd_info) { 2460771fe6b9SJerome Glisse uint16_t lcd_ddc_info = 2461771fe6b9SJerome Glisse combios_get_table_offset(dev, 2462771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE); 2463771fe6b9SJerome Glisse 2464771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24655137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2466771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2467771fe6b9SJerome Glisse 0), 2468771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 2469771fe6b9SJerome Glisse 2470771fe6b9SJerome Glisse if (lcd_ddc_info) { 2471771fe6b9SJerome Glisse ddc_type = RBIOS8(lcd_ddc_info + 2); 2472771fe6b9SJerome Glisse switch (ddc_type) { 2473771fe6b9SJerome Glisse case DDC_LCD: 2474771fe6b9SJerome Glisse ddc_i2c = 2475179e8078SAlex Deucher combios_setup_i2c_bus(rdev, 2476179e8078SAlex Deucher DDC_LCD, 2477179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 3), 2478179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 7)); 2479f376b94fSAlex Deucher radeon_i2c_add(rdev, &ddc_i2c, "LCD"); 2480771fe6b9SJerome Glisse break; 2481771fe6b9SJerome Glisse case DDC_GPIO: 2482771fe6b9SJerome Glisse ddc_i2c = 2483179e8078SAlex Deucher combios_setup_i2c_bus(rdev, 2484179e8078SAlex Deucher DDC_GPIO, 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 default: 2490179e8078SAlex Deucher ddc_i2c = 2491179e8078SAlex Deucher combios_setup_i2c_bus(rdev, ddc_type, 0, 0); 2492771fe6b9SJerome Glisse break; 2493771fe6b9SJerome Glisse } 2494d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD DDC Info Table found!\n"); 2495771fe6b9SJerome Glisse } else 2496771fe6b9SJerome Glisse ddc_i2c.valid = false; 2497771fe6b9SJerome Glisse 2498eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2499771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2500771fe6b9SJerome Glisse 5, 2501771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2502771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 2503b75fad06SAlex Deucher &ddc_i2c, 2504eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 2505eed45b30SAlex Deucher &hpd); 2506771fe6b9SJerome Glisse } 2507771fe6b9SJerome Glisse } 2508771fe6b9SJerome Glisse 2509771fe6b9SJerome Glisse /* check TV table */ 2510771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 2511771fe6b9SJerome Glisse uint32_t tv_info = 2512771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 2513771fe6b9SJerome Glisse if (tv_info) { 2514771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 2515790cfb34SAlex Deucher if (radeon_apply_legacy_tv_quirks(dev)) { 2516eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2517d294ed69SDave Airlie ddc_i2c.valid = false; 2518771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 25195137ee94SAlex Deucher radeon_get_encoder_enum 2520771fe6b9SJerome Glisse (dev, 2521771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2522771fe6b9SJerome Glisse 2), 2523771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2524771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 6, 2525771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2526771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 2527b75fad06SAlex Deucher &ddc_i2c, 2528eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2529eed45b30SAlex Deucher &hpd); 2530771fe6b9SJerome Glisse } 2531771fe6b9SJerome Glisse } 2532771fe6b9SJerome Glisse } 2533790cfb34SAlex Deucher } 2534771fe6b9SJerome Glisse 2535771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2536771fe6b9SJerome Glisse 2537771fe6b9SJerome Glisse return true; 2538771fe6b9SJerome Glisse } 2539771fe6b9SJerome Glisse 254063f7d982SAlex Deucher static const char *thermal_controller_names[] = { 254163f7d982SAlex Deucher "NONE", 254263f7d982SAlex Deucher "lm63", 254363f7d982SAlex Deucher "adm1032", 254463f7d982SAlex Deucher }; 254563f7d982SAlex Deucher 254656278a8eSAlex Deucher void radeon_combios_get_power_modes(struct radeon_device *rdev) 254756278a8eSAlex Deucher { 254856278a8eSAlex Deucher struct drm_device *dev = rdev->ddev; 254956278a8eSAlex Deucher u16 offset, misc, misc2 = 0; 255056278a8eSAlex Deucher u8 rev, blocks, tmp; 255156278a8eSAlex Deucher int state_index = 0; 255256278a8eSAlex Deucher 2553a48b9b4eSAlex Deucher rdev->pm.default_power_state_index = -1; 255456278a8eSAlex Deucher 25550975b162SAlex Deucher /* allocate 2 power states */ 25560975b162SAlex Deucher rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * 2, GFP_KERNEL); 25570975b162SAlex Deucher if (!rdev->pm.power_state) { 25580975b162SAlex Deucher rdev->pm.default_power_state_index = state_index; 25590975b162SAlex Deucher rdev->pm.num_power_states = 0; 25600975b162SAlex Deucher 25610975b162SAlex Deucher rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; 25620975b162SAlex Deucher rdev->pm.current_clock_mode_index = 0; 25630975b162SAlex Deucher return; 25640975b162SAlex Deucher } 25650975b162SAlex Deucher 256663f7d982SAlex Deucher /* check for a thermal chip */ 256763f7d982SAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_OVERDRIVE_INFO_TABLE); 256863f7d982SAlex Deucher if (offset) { 256963f7d982SAlex Deucher u8 thermal_controller = 0, gpio = 0, i2c_addr = 0, clk_bit = 0, data_bit = 0; 257063f7d982SAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 257163f7d982SAlex Deucher 257263f7d982SAlex Deucher rev = RBIOS8(offset); 257363f7d982SAlex Deucher 257463f7d982SAlex Deucher if (rev == 0) { 257563f7d982SAlex Deucher thermal_controller = RBIOS8(offset + 3); 257663f7d982SAlex Deucher gpio = RBIOS8(offset + 4) & 0x3f; 257763f7d982SAlex Deucher i2c_addr = RBIOS8(offset + 5); 257863f7d982SAlex Deucher } else if (rev == 1) { 257963f7d982SAlex Deucher thermal_controller = RBIOS8(offset + 4); 258063f7d982SAlex Deucher gpio = RBIOS8(offset + 5) & 0x3f; 258163f7d982SAlex Deucher i2c_addr = RBIOS8(offset + 6); 258263f7d982SAlex Deucher } else if (rev == 2) { 258363f7d982SAlex Deucher thermal_controller = RBIOS8(offset + 4); 258463f7d982SAlex Deucher gpio = RBIOS8(offset + 5) & 0x3f; 258563f7d982SAlex Deucher i2c_addr = RBIOS8(offset + 6); 258663f7d982SAlex Deucher clk_bit = RBIOS8(offset + 0xa); 258763f7d982SAlex Deucher data_bit = RBIOS8(offset + 0xb); 258863f7d982SAlex Deucher } 258963f7d982SAlex Deucher if ((thermal_controller > 0) && (thermal_controller < 3)) { 259063f7d982SAlex Deucher DRM_INFO("Possible %s thermal controller at 0x%02x\n", 259163f7d982SAlex Deucher thermal_controller_names[thermal_controller], 259263f7d982SAlex Deucher i2c_addr >> 1); 259363f7d982SAlex Deucher if (gpio == DDC_LCD) { 259463f7d982SAlex Deucher /* MM i2c */ 259563f7d982SAlex Deucher i2c_bus.valid = true; 259663f7d982SAlex Deucher i2c_bus.hw_capable = true; 259763f7d982SAlex Deucher i2c_bus.mm_i2c = true; 259863f7d982SAlex Deucher i2c_bus.i2c_id = 0xa0; 259963f7d982SAlex Deucher } else if (gpio == DDC_GPIO) 260063f7d982SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 1 << clk_bit, 1 << data_bit); 260163f7d982SAlex Deucher else 260263f7d982SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0); 260363f7d982SAlex Deucher rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 260463f7d982SAlex Deucher if (rdev->pm.i2c_bus) { 260563f7d982SAlex Deucher struct i2c_board_info info = { }; 260663f7d982SAlex Deucher const char *name = thermal_controller_names[thermal_controller]; 260763f7d982SAlex Deucher info.addr = i2c_addr >> 1; 260863f7d982SAlex Deucher strlcpy(info.type, name, sizeof(info.type)); 260963f7d982SAlex Deucher i2c_new_device(&rdev->pm.i2c_bus->adapter, &info); 261063f7d982SAlex Deucher } 261163f7d982SAlex Deucher } 261263f7d982SAlex Deucher } 261363f7d982SAlex Deucher 261456278a8eSAlex Deucher if (rdev->flags & RADEON_IS_MOBILITY) { 261556278a8eSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE); 261656278a8eSAlex Deucher if (offset) { 261756278a8eSAlex Deucher rev = RBIOS8(offset); 261856278a8eSAlex Deucher blocks = RBIOS8(offset + 0x2); 261956278a8eSAlex Deucher /* power mode 0 tends to be the only valid one */ 262056278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 262156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = RBIOS32(offset + 0x5 + 0x2); 262256278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = RBIOS32(offset + 0x5 + 0x6); 262356278a8eSAlex Deucher if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) || 262456278a8eSAlex Deucher (rdev->pm.power_state[state_index].clock_info[0].sclk == 0)) 262556278a8eSAlex Deucher goto default_mode; 26260ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 26270ec0e74fSAlex Deucher POWER_STATE_TYPE_BATTERY; 262856278a8eSAlex Deucher misc = RBIOS16(offset + 0x5 + 0x0); 262956278a8eSAlex Deucher if (rev > 4) 263056278a8eSAlex Deucher misc2 = RBIOS16(offset + 0x5 + 0xe); 263179daedc9SAlex Deucher rdev->pm.power_state[state_index].misc = misc; 263279daedc9SAlex Deucher rdev->pm.power_state[state_index].misc2 = misc2; 263356278a8eSAlex Deucher if (misc & 0x4) { 263456278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_GPIO; 263556278a8eSAlex Deucher if (misc & 0x8) 263656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 263756278a8eSAlex Deucher true; 263856278a8eSAlex Deucher else 263956278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 264056278a8eSAlex Deucher false; 264156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = true; 264256278a8eSAlex Deucher if (rev < 6) { 264356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 264456278a8eSAlex Deucher RBIOS16(offset + 0x5 + 0xb) * 4; 264556278a8eSAlex Deucher tmp = RBIOS8(offset + 0x5 + 0xd); 264656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 264756278a8eSAlex Deucher } else { 264856278a8eSAlex Deucher u8 entries = RBIOS8(offset + 0x5 + 0xb); 264956278a8eSAlex Deucher u16 voltage_table_offset = RBIOS16(offset + 0x5 + 0xc); 265056278a8eSAlex Deucher if (entries && voltage_table_offset) { 265156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 265256278a8eSAlex Deucher RBIOS16(voltage_table_offset) * 4; 265356278a8eSAlex Deucher tmp = RBIOS8(voltage_table_offset + 0x2); 265456278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 265556278a8eSAlex Deucher } else 265656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = false; 265756278a8eSAlex Deucher } 265856278a8eSAlex Deucher switch ((misc2 & 0x700) >> 8) { 265956278a8eSAlex Deucher case 0: 266056278a8eSAlex Deucher default: 266156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 0; 266256278a8eSAlex Deucher break; 266356278a8eSAlex Deucher case 1: 266456278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 33; 266556278a8eSAlex Deucher break; 266656278a8eSAlex Deucher case 2: 266756278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 66; 266856278a8eSAlex Deucher break; 266956278a8eSAlex Deucher case 3: 267056278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 99; 267156278a8eSAlex Deucher break; 267256278a8eSAlex Deucher case 4: 267356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 132; 267456278a8eSAlex Deucher break; 267556278a8eSAlex Deucher } 267656278a8eSAlex Deucher } else 267756278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 267856278a8eSAlex Deucher if (rev > 6) 267979daedc9SAlex Deucher rdev->pm.power_state[state_index].pcie_lanes = 268056278a8eSAlex Deucher RBIOS8(offset + 0x5 + 0x10); 2681d7311171SAlex Deucher rdev->pm.power_state[state_index].flags = RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; 268256278a8eSAlex Deucher state_index++; 268356278a8eSAlex Deucher } else { 268456278a8eSAlex Deucher /* XXX figure out some good default low power mode for mobility cards w/out power tables */ 268556278a8eSAlex Deucher } 268656278a8eSAlex Deucher } else { 268756278a8eSAlex Deucher /* XXX figure out some good default low power mode for desktop cards */ 268856278a8eSAlex Deucher } 268956278a8eSAlex Deucher 269056278a8eSAlex Deucher default_mode: 269156278a8eSAlex Deucher /* add the default mode */ 26920ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 26930ec0e74fSAlex Deucher POWER_STATE_TYPE_DEFAULT; 269456278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 269556278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk; 269656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk; 269756278a8eSAlex Deucher rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0]; 269884d88f4cSAlex Deucher if ((state_index > 0) && 26998de016e2SAlex Deucher (rdev->pm.power_state[0].clock_info[0].voltage.type == VOLTAGE_GPIO)) 270084d88f4cSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage = 270184d88f4cSAlex Deucher rdev->pm.power_state[0].clock_info[0].voltage; 270284d88f4cSAlex Deucher else 270356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 270479daedc9SAlex Deucher rdev->pm.power_state[state_index].pcie_lanes = 16; 2705a48b9b4eSAlex Deucher rdev->pm.power_state[state_index].flags = 0; 2706a48b9b4eSAlex Deucher rdev->pm.default_power_state_index = state_index; 270756278a8eSAlex Deucher rdev->pm.num_power_states = state_index + 1; 27089038dfdfSRafał Miłecki 2709a48b9b4eSAlex Deucher rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; 2710a48b9b4eSAlex Deucher rdev->pm.current_clock_mode_index = 0; 271156278a8eSAlex Deucher } 271256278a8eSAlex Deucher 2713fcec570bSAlex Deucher void radeon_external_tmds_setup(struct drm_encoder *encoder) 2714fcec570bSAlex Deucher { 2715fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2716fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2717fcec570bSAlex Deucher 2718fcec570bSAlex Deucher if (!tmds) 2719fcec570bSAlex Deucher return; 2720fcec570bSAlex Deucher 2721fcec570bSAlex Deucher switch (tmds->dvo_chip) { 2722fcec570bSAlex Deucher case DVO_SIL164: 2723fcec570bSAlex Deucher /* sil 164 */ 27245a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2725fcec570bSAlex Deucher tmds->slave_addr, 2726fcec570bSAlex Deucher 0x08, 0x30); 27275a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2728fcec570bSAlex Deucher tmds->slave_addr, 2729fcec570bSAlex Deucher 0x09, 0x00); 27305a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2731fcec570bSAlex Deucher tmds->slave_addr, 2732fcec570bSAlex Deucher 0x0a, 0x90); 27335a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2734fcec570bSAlex Deucher tmds->slave_addr, 2735fcec570bSAlex Deucher 0x0c, 0x89); 27365a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2737fcec570bSAlex Deucher tmds->slave_addr, 2738fcec570bSAlex Deucher 0x08, 0x3b); 2739fcec570bSAlex Deucher break; 2740fcec570bSAlex Deucher case DVO_SIL1178: 2741fcec570bSAlex Deucher /* sil 1178 - untested */ 2742fcec570bSAlex Deucher /* 2743fcec570bSAlex Deucher * 0x0f, 0x44 2744fcec570bSAlex Deucher * 0x0f, 0x4c 2745fcec570bSAlex Deucher * 0x0e, 0x01 2746fcec570bSAlex Deucher * 0x0a, 0x80 2747fcec570bSAlex Deucher * 0x09, 0x30 2748fcec570bSAlex Deucher * 0x0c, 0xc9 2749fcec570bSAlex Deucher * 0x0d, 0x70 2750fcec570bSAlex Deucher * 0x08, 0x32 2751fcec570bSAlex Deucher * 0x08, 0x33 2752fcec570bSAlex Deucher */ 2753fcec570bSAlex Deucher break; 2754fcec570bSAlex Deucher default: 2755fcec570bSAlex Deucher break; 2756fcec570bSAlex Deucher } 2757fcec570bSAlex Deucher 2758fcec570bSAlex Deucher } 2759fcec570bSAlex Deucher 2760fcec570bSAlex Deucher bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder) 2761fcec570bSAlex Deucher { 2762fcec570bSAlex Deucher struct drm_device *dev = encoder->dev; 2763fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 2764fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2765fcec570bSAlex Deucher uint16_t offset; 2766fcec570bSAlex Deucher uint8_t blocks, slave_addr, rev; 2767fcec570bSAlex Deucher uint32_t index, id; 2768fcec570bSAlex Deucher uint32_t reg, val, and_mask, or_mask; 2769fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2770fcec570bSAlex Deucher 2771fcec570bSAlex Deucher if (!tmds) 2772fcec570bSAlex Deucher return false; 2773fcec570bSAlex Deucher 2774fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2775fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE); 2776fcec570bSAlex Deucher rev = RBIOS8(offset); 2777fcec570bSAlex Deucher if (offset) { 2778fcec570bSAlex Deucher rev = RBIOS8(offset); 2779fcec570bSAlex Deucher if (rev > 1) { 2780fcec570bSAlex Deucher blocks = RBIOS8(offset + 3); 2781fcec570bSAlex Deucher index = offset + 4; 2782fcec570bSAlex Deucher while (blocks > 0) { 2783fcec570bSAlex Deucher id = RBIOS16(index); 2784fcec570bSAlex Deucher index += 2; 2785fcec570bSAlex Deucher switch (id >> 13) { 2786fcec570bSAlex Deucher case 0: 2787fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2788fcec570bSAlex Deucher val = RBIOS32(index); 2789fcec570bSAlex Deucher index += 4; 2790fcec570bSAlex Deucher WREG32(reg, val); 2791fcec570bSAlex Deucher break; 2792fcec570bSAlex Deucher case 2: 2793fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2794fcec570bSAlex Deucher and_mask = RBIOS32(index); 2795fcec570bSAlex Deucher index += 4; 2796fcec570bSAlex Deucher or_mask = RBIOS32(index); 2797fcec570bSAlex Deucher index += 4; 2798fcec570bSAlex Deucher val = RREG32(reg); 2799fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2800fcec570bSAlex Deucher WREG32(reg, val); 2801fcec570bSAlex Deucher break; 2802fcec570bSAlex Deucher case 3: 2803fcec570bSAlex Deucher val = RBIOS16(index); 2804fcec570bSAlex Deucher index += 2; 2805fcec570bSAlex Deucher udelay(val); 2806fcec570bSAlex Deucher break; 2807fcec570bSAlex Deucher case 4: 2808fcec570bSAlex Deucher val = RBIOS16(index); 2809fcec570bSAlex Deucher index += 2; 2810fcec570bSAlex Deucher udelay(val * 1000); 2811fcec570bSAlex Deucher break; 2812fcec570bSAlex Deucher case 6: 2813fcec570bSAlex Deucher slave_addr = id & 0xff; 2814fcec570bSAlex Deucher slave_addr >>= 1; /* 7 bit addressing */ 2815fcec570bSAlex Deucher index++; 2816fcec570bSAlex Deucher reg = RBIOS8(index); 2817fcec570bSAlex Deucher index++; 2818fcec570bSAlex Deucher val = RBIOS8(index); 2819fcec570bSAlex Deucher index++; 28205a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2821fcec570bSAlex Deucher slave_addr, 2822fcec570bSAlex Deucher reg, val); 2823fcec570bSAlex Deucher break; 2824fcec570bSAlex Deucher default: 2825fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2826fcec570bSAlex Deucher break; 2827fcec570bSAlex Deucher } 2828fcec570bSAlex Deucher blocks--; 2829fcec570bSAlex Deucher } 2830fcec570bSAlex Deucher return true; 2831fcec570bSAlex Deucher } 2832fcec570bSAlex Deucher } 2833fcec570bSAlex Deucher } else { 2834fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2835fcec570bSAlex Deucher if (offset) { 2836fcec570bSAlex Deucher index = offset + 10; 2837fcec570bSAlex Deucher id = RBIOS16(index); 2838fcec570bSAlex Deucher while (id != 0xffff) { 2839fcec570bSAlex Deucher index += 2; 2840fcec570bSAlex Deucher switch (id >> 13) { 2841fcec570bSAlex Deucher case 0: 2842fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2843fcec570bSAlex Deucher val = RBIOS32(index); 2844fcec570bSAlex Deucher WREG32(reg, val); 2845fcec570bSAlex Deucher break; 2846fcec570bSAlex Deucher case 2: 2847fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2848fcec570bSAlex Deucher and_mask = RBIOS32(index); 2849fcec570bSAlex Deucher index += 4; 2850fcec570bSAlex Deucher or_mask = RBIOS32(index); 2851fcec570bSAlex Deucher index += 4; 2852fcec570bSAlex Deucher val = RREG32(reg); 2853fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2854fcec570bSAlex Deucher WREG32(reg, val); 2855fcec570bSAlex Deucher break; 2856fcec570bSAlex Deucher case 4: 2857fcec570bSAlex Deucher val = RBIOS16(index); 2858fcec570bSAlex Deucher index += 2; 2859fcec570bSAlex Deucher udelay(val); 2860fcec570bSAlex Deucher break; 2861fcec570bSAlex Deucher case 5: 2862fcec570bSAlex Deucher reg = id & 0x1fff; 2863fcec570bSAlex Deucher and_mask = RBIOS32(index); 2864fcec570bSAlex Deucher index += 4; 2865fcec570bSAlex Deucher or_mask = RBIOS32(index); 2866fcec570bSAlex Deucher index += 4; 2867fcec570bSAlex Deucher val = RREG32_PLL(reg); 2868fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2869fcec570bSAlex Deucher WREG32_PLL(reg, val); 2870fcec570bSAlex Deucher break; 2871fcec570bSAlex Deucher case 6: 2872fcec570bSAlex Deucher reg = id & 0x1fff; 2873fcec570bSAlex Deucher val = RBIOS8(index); 2874fcec570bSAlex Deucher index += 1; 28755a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2876fcec570bSAlex Deucher tmds->slave_addr, 2877fcec570bSAlex Deucher reg, val); 2878fcec570bSAlex Deucher break; 2879fcec570bSAlex Deucher default: 2880fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2881fcec570bSAlex Deucher break; 2882fcec570bSAlex Deucher } 2883fcec570bSAlex Deucher id = RBIOS16(index); 2884fcec570bSAlex Deucher } 2885fcec570bSAlex Deucher return true; 2886fcec570bSAlex Deucher } 2887fcec570bSAlex Deucher } 2888fcec570bSAlex Deucher return false; 2889fcec570bSAlex Deucher } 2890fcec570bSAlex Deucher 2891771fe6b9SJerome Glisse static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset) 2892771fe6b9SJerome Glisse { 2893771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2894771fe6b9SJerome Glisse 2895771fe6b9SJerome Glisse if (offset) { 2896771fe6b9SJerome Glisse while (RBIOS16(offset)) { 2897771fe6b9SJerome Glisse uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13); 2898771fe6b9SJerome Glisse uint32_t addr = (RBIOS16(offset) & 0x1fff); 2899771fe6b9SJerome Glisse uint32_t val, and_mask, or_mask; 2900771fe6b9SJerome Glisse uint32_t tmp; 2901771fe6b9SJerome Glisse 2902771fe6b9SJerome Glisse offset += 2; 2903771fe6b9SJerome Glisse switch (cmd) { 2904771fe6b9SJerome Glisse case 0: 2905771fe6b9SJerome Glisse val = RBIOS32(offset); 2906771fe6b9SJerome Glisse offset += 4; 2907771fe6b9SJerome Glisse WREG32(addr, val); 2908771fe6b9SJerome Glisse break; 2909771fe6b9SJerome Glisse case 1: 2910771fe6b9SJerome Glisse val = RBIOS32(offset); 2911771fe6b9SJerome Glisse offset += 4; 2912771fe6b9SJerome Glisse WREG32(addr, val); 2913771fe6b9SJerome Glisse break; 2914771fe6b9SJerome Glisse case 2: 2915771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2916771fe6b9SJerome Glisse offset += 4; 2917771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2918771fe6b9SJerome Glisse offset += 4; 2919771fe6b9SJerome Glisse tmp = RREG32(addr); 2920771fe6b9SJerome Glisse tmp &= and_mask; 2921771fe6b9SJerome Glisse tmp |= or_mask; 2922771fe6b9SJerome Glisse WREG32(addr, tmp); 2923771fe6b9SJerome Glisse break; 2924771fe6b9SJerome Glisse case 3: 2925771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2926771fe6b9SJerome Glisse offset += 4; 2927771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2928771fe6b9SJerome Glisse offset += 4; 2929771fe6b9SJerome Glisse tmp = RREG32(addr); 2930771fe6b9SJerome Glisse tmp &= and_mask; 2931771fe6b9SJerome Glisse tmp |= or_mask; 2932771fe6b9SJerome Glisse WREG32(addr, tmp); 2933771fe6b9SJerome Glisse break; 2934771fe6b9SJerome Glisse case 4: 2935771fe6b9SJerome Glisse val = RBIOS16(offset); 2936771fe6b9SJerome Glisse offset += 2; 2937771fe6b9SJerome Glisse udelay(val); 2938771fe6b9SJerome Glisse break; 2939771fe6b9SJerome Glisse case 5: 2940771fe6b9SJerome Glisse val = RBIOS16(offset); 2941771fe6b9SJerome Glisse offset += 2; 2942771fe6b9SJerome Glisse switch (addr) { 2943771fe6b9SJerome Glisse case 8: 2944771fe6b9SJerome Glisse while (val--) { 2945771fe6b9SJerome Glisse if (! 2946771fe6b9SJerome Glisse (RREG32_PLL 2947771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2948771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2949771fe6b9SJerome Glisse break; 2950771fe6b9SJerome Glisse } 2951771fe6b9SJerome Glisse break; 2952771fe6b9SJerome Glisse case 9: 2953771fe6b9SJerome Glisse while (val--) { 2954771fe6b9SJerome Glisse if ((RREG32(RADEON_MC_STATUS) & 2955771fe6b9SJerome Glisse RADEON_MC_IDLE)) 2956771fe6b9SJerome Glisse break; 2957771fe6b9SJerome Glisse } 2958771fe6b9SJerome Glisse break; 2959771fe6b9SJerome Glisse default: 2960771fe6b9SJerome Glisse break; 2961771fe6b9SJerome Glisse } 2962771fe6b9SJerome Glisse break; 2963771fe6b9SJerome Glisse default: 2964771fe6b9SJerome Glisse break; 2965771fe6b9SJerome Glisse } 2966771fe6b9SJerome Glisse } 2967771fe6b9SJerome Glisse } 2968771fe6b9SJerome Glisse } 2969771fe6b9SJerome Glisse 2970771fe6b9SJerome Glisse static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset) 2971771fe6b9SJerome Glisse { 2972771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2973771fe6b9SJerome Glisse 2974771fe6b9SJerome Glisse if (offset) { 2975771fe6b9SJerome Glisse while (RBIOS8(offset)) { 2976771fe6b9SJerome Glisse uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6); 2977771fe6b9SJerome Glisse uint8_t addr = (RBIOS8(offset) & 0x3f); 2978771fe6b9SJerome Glisse uint32_t val, shift, tmp; 2979771fe6b9SJerome Glisse uint32_t and_mask, or_mask; 2980771fe6b9SJerome Glisse 2981771fe6b9SJerome Glisse offset++; 2982771fe6b9SJerome Glisse switch (cmd) { 2983771fe6b9SJerome Glisse case 0: 2984771fe6b9SJerome Glisse val = RBIOS32(offset); 2985771fe6b9SJerome Glisse offset += 4; 2986771fe6b9SJerome Glisse WREG32_PLL(addr, val); 2987771fe6b9SJerome Glisse break; 2988771fe6b9SJerome Glisse case 1: 2989771fe6b9SJerome Glisse shift = RBIOS8(offset) * 8; 2990771fe6b9SJerome Glisse offset++; 2991771fe6b9SJerome Glisse and_mask = RBIOS8(offset) << shift; 2992771fe6b9SJerome Glisse and_mask |= ~(0xff << shift); 2993771fe6b9SJerome Glisse offset++; 2994771fe6b9SJerome Glisse or_mask = RBIOS8(offset) << shift; 2995771fe6b9SJerome Glisse offset++; 2996771fe6b9SJerome Glisse tmp = RREG32_PLL(addr); 2997771fe6b9SJerome Glisse tmp &= and_mask; 2998771fe6b9SJerome Glisse tmp |= or_mask; 2999771fe6b9SJerome Glisse WREG32_PLL(addr, tmp); 3000771fe6b9SJerome Glisse break; 3001771fe6b9SJerome Glisse case 2: 3002771fe6b9SJerome Glisse case 3: 3003771fe6b9SJerome Glisse tmp = 1000; 3004771fe6b9SJerome Glisse switch (addr) { 3005771fe6b9SJerome Glisse case 1: 3006771fe6b9SJerome Glisse udelay(150); 3007771fe6b9SJerome Glisse break; 3008771fe6b9SJerome Glisse case 2: 3009771fe6b9SJerome Glisse udelay(1000); 3010771fe6b9SJerome Glisse break; 3011771fe6b9SJerome Glisse case 3: 3012771fe6b9SJerome Glisse while (tmp--) { 3013771fe6b9SJerome Glisse if (! 3014771fe6b9SJerome Glisse (RREG32_PLL 3015771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 3016771fe6b9SJerome Glisse RADEON_MC_BUSY)) 3017771fe6b9SJerome Glisse break; 3018771fe6b9SJerome Glisse } 3019771fe6b9SJerome Glisse break; 3020771fe6b9SJerome Glisse case 4: 3021771fe6b9SJerome Glisse while (tmp--) { 3022771fe6b9SJerome Glisse if (RREG32_PLL 3023771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 3024771fe6b9SJerome Glisse RADEON_DLL_READY) 3025771fe6b9SJerome Glisse break; 3026771fe6b9SJerome Glisse } 3027771fe6b9SJerome Glisse break; 3028771fe6b9SJerome Glisse case 5: 3029771fe6b9SJerome Glisse tmp = 3030771fe6b9SJerome Glisse RREG32_PLL(RADEON_CLK_PWRMGT_CNTL); 3031771fe6b9SJerome Glisse if (tmp & RADEON_CG_NO1_DEBUG_0) { 3032771fe6b9SJerome Glisse #if 0 3033771fe6b9SJerome Glisse uint32_t mclk_cntl = 3034771fe6b9SJerome Glisse RREG32_PLL 3035771fe6b9SJerome Glisse (RADEON_MCLK_CNTL); 3036771fe6b9SJerome Glisse mclk_cntl &= 0xffff0000; 3037771fe6b9SJerome Glisse /*mclk_cntl |= 0x00001111;*//* ??? */ 3038771fe6b9SJerome Glisse WREG32_PLL(RADEON_MCLK_CNTL, 3039771fe6b9SJerome Glisse mclk_cntl); 3040771fe6b9SJerome Glisse udelay(10000); 3041771fe6b9SJerome Glisse #endif 3042771fe6b9SJerome Glisse WREG32_PLL 3043771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL, 3044771fe6b9SJerome Glisse tmp & 3045771fe6b9SJerome Glisse ~RADEON_CG_NO1_DEBUG_0); 3046771fe6b9SJerome Glisse udelay(10000); 3047771fe6b9SJerome Glisse } 3048771fe6b9SJerome Glisse break; 3049771fe6b9SJerome Glisse default: 3050771fe6b9SJerome Glisse break; 3051771fe6b9SJerome Glisse } 3052771fe6b9SJerome Glisse break; 3053771fe6b9SJerome Glisse default: 3054771fe6b9SJerome Glisse break; 3055771fe6b9SJerome Glisse } 3056771fe6b9SJerome Glisse } 3057771fe6b9SJerome Glisse } 3058771fe6b9SJerome Glisse } 3059771fe6b9SJerome Glisse 3060771fe6b9SJerome Glisse static void combios_parse_ram_reset_table(struct drm_device *dev, 3061771fe6b9SJerome Glisse uint16_t offset) 3062771fe6b9SJerome Glisse { 3063771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3064771fe6b9SJerome Glisse uint32_t tmp; 3065771fe6b9SJerome Glisse 3066771fe6b9SJerome Glisse if (offset) { 3067771fe6b9SJerome Glisse uint8_t val = RBIOS8(offset); 3068771fe6b9SJerome Glisse while (val != 0xff) { 3069771fe6b9SJerome Glisse offset++; 3070771fe6b9SJerome Glisse 3071771fe6b9SJerome Glisse if (val == 0x0f) { 3072771fe6b9SJerome Glisse uint32_t channel_complete_mask; 3073771fe6b9SJerome Glisse 3074771fe6b9SJerome Glisse if (ASIC_IS_R300(rdev)) 3075771fe6b9SJerome Glisse channel_complete_mask = 3076771fe6b9SJerome Glisse R300_MEM_PWRUP_COMPLETE; 3077771fe6b9SJerome Glisse else 3078771fe6b9SJerome Glisse channel_complete_mask = 3079771fe6b9SJerome Glisse RADEON_MEM_PWRUP_COMPLETE; 3080771fe6b9SJerome Glisse tmp = 20000; 3081771fe6b9SJerome Glisse while (tmp--) { 3082771fe6b9SJerome Glisse if ((RREG32(RADEON_MEM_STR_CNTL) & 3083771fe6b9SJerome Glisse channel_complete_mask) == 3084771fe6b9SJerome Glisse channel_complete_mask) 3085771fe6b9SJerome Glisse break; 3086771fe6b9SJerome Glisse } 3087771fe6b9SJerome Glisse } else { 3088771fe6b9SJerome Glisse uint32_t or_mask = RBIOS16(offset); 3089771fe6b9SJerome Glisse offset += 2; 3090771fe6b9SJerome Glisse 3091771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 3092771fe6b9SJerome Glisse tmp &= RADEON_SDRAM_MODE_MASK; 3093771fe6b9SJerome Glisse tmp |= or_mask; 3094771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 3095771fe6b9SJerome Glisse 3096771fe6b9SJerome Glisse or_mask = val << 24; 3097771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 3098771fe6b9SJerome Glisse tmp &= RADEON_B3MEM_RESET_MASK; 3099771fe6b9SJerome Glisse tmp |= or_mask; 3100771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 3101771fe6b9SJerome Glisse } 3102771fe6b9SJerome Glisse val = RBIOS8(offset); 3103771fe6b9SJerome Glisse } 3104771fe6b9SJerome Glisse } 3105771fe6b9SJerome Glisse } 3106771fe6b9SJerome Glisse 3107771fe6b9SJerome Glisse static uint32_t combios_detect_ram(struct drm_device *dev, int ram, 3108771fe6b9SJerome Glisse int mem_addr_mapping) 3109771fe6b9SJerome Glisse { 3110771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3111771fe6b9SJerome Glisse uint32_t mem_cntl; 3112771fe6b9SJerome Glisse uint32_t mem_size; 3113771fe6b9SJerome Glisse uint32_t addr = 0; 3114771fe6b9SJerome Glisse 3115771fe6b9SJerome Glisse mem_cntl = RREG32(RADEON_MEM_CNTL); 3116771fe6b9SJerome Glisse if (mem_cntl & RV100_HALF_MODE) 3117771fe6b9SJerome Glisse ram /= 2; 3118771fe6b9SJerome Glisse mem_size = ram; 3119771fe6b9SJerome Glisse mem_cntl &= ~(0xff << 8); 3120771fe6b9SJerome Glisse mem_cntl |= (mem_addr_mapping & 0xff) << 8; 3121771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 3122771fe6b9SJerome Glisse RREG32(RADEON_MEM_CNTL); 3123771fe6b9SJerome Glisse 3124771fe6b9SJerome Glisse /* sdram reset ? */ 3125771fe6b9SJerome Glisse 3126771fe6b9SJerome Glisse /* something like this???? */ 3127771fe6b9SJerome Glisse while (ram--) { 3128771fe6b9SJerome Glisse addr = ram * 1024 * 1024; 3129771fe6b9SJerome Glisse /* write to each page */ 3130771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 3131771fe6b9SJerome Glisse WREG32(RADEON_MM_DATA, 0xdeadbeef); 3132771fe6b9SJerome Glisse /* read back and verify */ 3133771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 3134771fe6b9SJerome Glisse if (RREG32(RADEON_MM_DATA) != 0xdeadbeef) 3135771fe6b9SJerome Glisse return 0; 3136771fe6b9SJerome Glisse } 3137771fe6b9SJerome Glisse 3138771fe6b9SJerome Glisse return mem_size; 3139771fe6b9SJerome Glisse } 3140771fe6b9SJerome Glisse 3141771fe6b9SJerome Glisse static void combios_write_ram_size(struct drm_device *dev) 3142771fe6b9SJerome Glisse { 3143771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3144771fe6b9SJerome Glisse uint8_t rev; 3145771fe6b9SJerome Glisse uint16_t offset; 3146771fe6b9SJerome Glisse uint32_t mem_size = 0; 3147771fe6b9SJerome Glisse uint32_t mem_cntl = 0; 3148771fe6b9SJerome Glisse 3149771fe6b9SJerome Glisse /* should do something smarter here I guess... */ 3150771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_IGP) 3151771fe6b9SJerome Glisse return; 3152771fe6b9SJerome Glisse 3153771fe6b9SJerome Glisse /* first check detected mem table */ 3154771fe6b9SJerome Glisse offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE); 3155771fe6b9SJerome Glisse if (offset) { 3156771fe6b9SJerome Glisse rev = RBIOS8(offset); 3157771fe6b9SJerome Glisse if (rev < 3) { 3158771fe6b9SJerome Glisse mem_cntl = RBIOS32(offset + 1); 3159771fe6b9SJerome Glisse mem_size = RBIOS16(offset + 5); 31604ce9198eSAlex Deucher if ((rdev->family < CHIP_R200) && 31614ce9198eSAlex Deucher !ASIC_IS_RN50(rdev)) 3162771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 3163771fe6b9SJerome Glisse } 3164771fe6b9SJerome Glisse } 3165771fe6b9SJerome Glisse 3166771fe6b9SJerome Glisse if (!mem_size) { 3167771fe6b9SJerome Glisse offset = 3168771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 3169771fe6b9SJerome Glisse if (offset) { 3170771fe6b9SJerome Glisse rev = RBIOS8(offset - 1); 3171771fe6b9SJerome Glisse if (rev < 1) { 31724ce9198eSAlex Deucher if ((rdev->family < CHIP_R200) 31734ce9198eSAlex Deucher && !ASIC_IS_RN50(rdev)) { 3174771fe6b9SJerome Glisse int ram = 0; 3175771fe6b9SJerome Glisse int mem_addr_mapping = 0; 3176771fe6b9SJerome Glisse 3177771fe6b9SJerome Glisse while (RBIOS8(offset)) { 3178771fe6b9SJerome Glisse ram = RBIOS8(offset); 3179771fe6b9SJerome Glisse mem_addr_mapping = 3180771fe6b9SJerome Glisse RBIOS8(offset + 1); 3181771fe6b9SJerome Glisse if (mem_addr_mapping != 0x25) 3182771fe6b9SJerome Glisse ram *= 2; 3183771fe6b9SJerome Glisse mem_size = 3184771fe6b9SJerome Glisse combios_detect_ram(dev, ram, 3185771fe6b9SJerome Glisse mem_addr_mapping); 3186771fe6b9SJerome Glisse if (mem_size) 3187771fe6b9SJerome Glisse break; 3188771fe6b9SJerome Glisse offset += 2; 3189771fe6b9SJerome Glisse } 3190771fe6b9SJerome Glisse } else 3191771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 3192771fe6b9SJerome Glisse } else { 3193771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 3194771fe6b9SJerome Glisse mem_size *= 2; /* convert to MB */ 3195771fe6b9SJerome Glisse } 3196771fe6b9SJerome Glisse } 3197771fe6b9SJerome Glisse } 3198771fe6b9SJerome Glisse 3199771fe6b9SJerome Glisse mem_size *= (1024 * 1024); /* convert to bytes */ 3200771fe6b9SJerome Glisse WREG32(RADEON_CONFIG_MEMSIZE, mem_size); 3201771fe6b9SJerome Glisse } 3202771fe6b9SJerome Glisse 3203771fe6b9SJerome Glisse void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable) 3204771fe6b9SJerome Glisse { 3205771fe6b9SJerome Glisse uint16_t dyn_clk_info = 3206771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 3207771fe6b9SJerome Glisse 3208771fe6b9SJerome Glisse if (dyn_clk_info) 3209771fe6b9SJerome Glisse combios_parse_pll_table(dev, dyn_clk_info); 3210771fe6b9SJerome Glisse } 3211771fe6b9SJerome Glisse 3212771fe6b9SJerome Glisse void radeon_combios_asic_init(struct drm_device *dev) 3213771fe6b9SJerome Glisse { 3214771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3215771fe6b9SJerome Glisse uint16_t table; 3216771fe6b9SJerome Glisse 3217771fe6b9SJerome Glisse /* port hardcoded mac stuff from radeonfb */ 3218771fe6b9SJerome Glisse if (rdev->bios == NULL) 3219771fe6b9SJerome Glisse return; 3220771fe6b9SJerome Glisse 3221771fe6b9SJerome Glisse /* ASIC INIT 1 */ 3222771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE); 3223771fe6b9SJerome Glisse if (table) 3224771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3225771fe6b9SJerome Glisse 3226771fe6b9SJerome Glisse /* PLL INIT */ 3227771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE); 3228771fe6b9SJerome Glisse if (table) 3229771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 3230771fe6b9SJerome Glisse 3231771fe6b9SJerome Glisse /* ASIC INIT 2 */ 3232771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE); 3233771fe6b9SJerome Glisse if (table) 3234771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3235771fe6b9SJerome Glisse 3236771fe6b9SJerome Glisse if (!(rdev->flags & RADEON_IS_IGP)) { 3237771fe6b9SJerome Glisse /* ASIC INIT 4 */ 3238771fe6b9SJerome Glisse table = 3239771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE); 3240771fe6b9SJerome Glisse if (table) 3241771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3242771fe6b9SJerome Glisse 3243771fe6b9SJerome Glisse /* RAM RESET */ 3244771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE); 3245771fe6b9SJerome Glisse if (table) 3246771fe6b9SJerome Glisse combios_parse_ram_reset_table(dev, table); 3247771fe6b9SJerome Glisse 3248771fe6b9SJerome Glisse /* ASIC INIT 3 */ 3249771fe6b9SJerome Glisse table = 3250771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE); 3251771fe6b9SJerome Glisse if (table) 3252771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3253771fe6b9SJerome Glisse 3254771fe6b9SJerome Glisse /* write CONFIG_MEMSIZE */ 3255771fe6b9SJerome Glisse combios_write_ram_size(dev); 3256771fe6b9SJerome Glisse } 3257771fe6b9SJerome Glisse 3258580b4fffSDave Airlie /* quirk for rs4xx HP nx6125 laptop to make it resume 3259580b4fffSDave Airlie * - it hangs on resume inside the dynclk 1 table. 3260580b4fffSDave Airlie */ 3261580b4fffSDave Airlie if (rdev->family == CHIP_RS480 && 3262580b4fffSDave Airlie rdev->pdev->subsystem_vendor == 0x103c && 3263580b4fffSDave Airlie rdev->pdev->subsystem_device == 0x308b) 3264580b4fffSDave Airlie return; 3265580b4fffSDave Airlie 326652fa2bbcSAlex Deucher /* quirk for rs4xx HP dv5000 laptop to make it resume 326752fa2bbcSAlex Deucher * - it hangs on resume inside the dynclk 1 table. 326852fa2bbcSAlex Deucher */ 326952fa2bbcSAlex Deucher if (rdev->family == CHIP_RS480 && 327052fa2bbcSAlex Deucher rdev->pdev->subsystem_vendor == 0x103c && 327152fa2bbcSAlex Deucher rdev->pdev->subsystem_device == 0x30a4) 327252fa2bbcSAlex Deucher return; 327352fa2bbcSAlex Deucher 3274771fe6b9SJerome Glisse /* DYN CLK 1 */ 3275771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 3276771fe6b9SJerome Glisse if (table) 3277771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 3278771fe6b9SJerome Glisse 3279771fe6b9SJerome Glisse } 3280771fe6b9SJerome Glisse 3281771fe6b9SJerome Glisse void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev) 3282771fe6b9SJerome Glisse { 3283771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3284771fe6b9SJerome Glisse uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch; 3285771fe6b9SJerome Glisse 3286771fe6b9SJerome Glisse bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); 3287771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3288771fe6b9SJerome Glisse bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH); 3289771fe6b9SJerome Glisse 3290771fe6b9SJerome Glisse /* let the bios control the backlight */ 3291771fe6b9SJerome Glisse bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN; 3292771fe6b9SJerome Glisse 3293771fe6b9SJerome Glisse /* tell the bios not to handle mode switching */ 3294771fe6b9SJerome Glisse bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS | 3295771fe6b9SJerome Glisse RADEON_ACC_MODE_CHANGE); 3296771fe6b9SJerome Glisse 3297771fe6b9SJerome Glisse /* tell the bios a driver is loaded */ 3298771fe6b9SJerome Glisse bios_7_scratch |= RADEON_DRV_LOADED; 3299771fe6b9SJerome Glisse 3300771fe6b9SJerome Glisse WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch); 3301771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3302771fe6b9SJerome Glisse WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch); 3303771fe6b9SJerome Glisse } 3304771fe6b9SJerome Glisse 3305771fe6b9SJerome Glisse void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock) 3306771fe6b9SJerome Glisse { 3307771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3308771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3309771fe6b9SJerome Glisse uint32_t bios_6_scratch; 3310771fe6b9SJerome Glisse 3311771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3312771fe6b9SJerome Glisse 3313771fe6b9SJerome Glisse if (lock) 3314771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DRIVER_CRITICAL; 3315771fe6b9SJerome Glisse else 3316771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DRIVER_CRITICAL; 3317771fe6b9SJerome Glisse 3318771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3319771fe6b9SJerome Glisse } 3320771fe6b9SJerome Glisse 3321771fe6b9SJerome Glisse void 3322771fe6b9SJerome Glisse radeon_combios_connected_scratch_regs(struct drm_connector *connector, 3323771fe6b9SJerome Glisse struct drm_encoder *encoder, 3324771fe6b9SJerome Glisse bool connected) 3325771fe6b9SJerome Glisse { 3326771fe6b9SJerome Glisse struct drm_device *dev = connector->dev; 3327771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3328771fe6b9SJerome Glisse struct radeon_connector *radeon_connector = 3329771fe6b9SJerome Glisse to_radeon_connector(connector); 3330771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3331771fe6b9SJerome Glisse uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH); 3332771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3333771fe6b9SJerome Glisse 3334771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) && 3335771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) { 3336771fe6b9SJerome Glisse if (connected) { 3337d9fdaafbSDave Airlie DRM_DEBUG_KMS("TV1 connected\n"); 3338771fe6b9SJerome Glisse /* fix me */ 3339771fe6b9SJerome Glisse bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO; 3340771fe6b9SJerome Glisse /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */ 3341771fe6b9SJerome Glisse bios_5_scratch |= RADEON_TV1_ON; 3342771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_TV1; 3343771fe6b9SJerome Glisse } else { 3344d9fdaafbSDave Airlie DRM_DEBUG_KMS("TV1 disconnected\n"); 3345771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK; 3346771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_ON; 3347771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_TV1; 3348771fe6b9SJerome Glisse } 3349771fe6b9SJerome Glisse } 3350771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) && 3351771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) { 3352771fe6b9SJerome Glisse if (connected) { 3353d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD1 connected\n"); 3354771fe6b9SJerome Glisse bios_4_scratch |= RADEON_LCD1_ATTACHED; 3355771fe6b9SJerome Glisse bios_5_scratch |= RADEON_LCD1_ON; 3356771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_LCD1; 3357771fe6b9SJerome Glisse } else { 3358d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD1 disconnected\n"); 3359771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_LCD1_ATTACHED; 3360771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_ON; 3361771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_LCD1; 3362771fe6b9SJerome Glisse } 3363771fe6b9SJerome Glisse } 3364771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) && 3365771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) { 3366771fe6b9SJerome Glisse if (connected) { 3367d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT1 connected\n"); 3368771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR; 3369771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT1_ON; 3370771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT1; 3371771fe6b9SJerome Glisse } else { 3372d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT1 disconnected\n"); 3373771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK; 3374771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_ON; 3375771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT1; 3376771fe6b9SJerome Glisse } 3377771fe6b9SJerome Glisse } 3378771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) && 3379771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) { 3380771fe6b9SJerome Glisse if (connected) { 3381d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT2 connected\n"); 3382771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR; 3383771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT2_ON; 3384771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT2; 3385771fe6b9SJerome Glisse } else { 3386d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT2 disconnected\n"); 3387771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK; 3388771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_ON; 3389771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT2; 3390771fe6b9SJerome Glisse } 3391771fe6b9SJerome Glisse } 3392771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) && 3393771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) { 3394771fe6b9SJerome Glisse if (connected) { 3395d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP1 connected\n"); 3396771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP1_ATTACHED; 3397771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP1_ON; 3398771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP1; 3399771fe6b9SJerome Glisse } else { 3400d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP1 disconnected\n"); 3401771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP1_ATTACHED; 3402771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_ON; 3403771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP1; 3404771fe6b9SJerome Glisse } 3405771fe6b9SJerome Glisse } 3406771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) && 3407771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) { 3408771fe6b9SJerome Glisse if (connected) { 3409d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP2 connected\n"); 3410771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP2_ATTACHED; 3411771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP2_ON; 3412771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP2; 3413771fe6b9SJerome Glisse } else { 3414d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP2 disconnected\n"); 3415771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP2_ATTACHED; 3416771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_ON; 3417771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP2; 3418771fe6b9SJerome Glisse } 3419771fe6b9SJerome Glisse } 3420771fe6b9SJerome Glisse WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch); 3421771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3422771fe6b9SJerome Glisse } 3423771fe6b9SJerome Glisse 3424771fe6b9SJerome Glisse void 3425771fe6b9SJerome Glisse radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc) 3426771fe6b9SJerome Glisse { 3427771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3428771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3429771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3430771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3431771fe6b9SJerome Glisse 3432771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { 3433771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_CRTC_MASK; 3434771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT); 3435771fe6b9SJerome Glisse } 3436771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { 3437771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK; 3438771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT); 3439771fe6b9SJerome Glisse } 3440771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { 3441771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK; 3442771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT); 3443771fe6b9SJerome Glisse } 3444771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { 3445771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK; 3446771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT); 3447771fe6b9SJerome Glisse } 3448771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { 3449771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK; 3450771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT); 3451771fe6b9SJerome Glisse } 3452771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { 3453771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK; 3454771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT); 3455771fe6b9SJerome Glisse } 3456771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3457771fe6b9SJerome Glisse } 3458771fe6b9SJerome Glisse 3459771fe6b9SJerome Glisse void 3460771fe6b9SJerome Glisse radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on) 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_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3466771fe6b9SJerome Glisse 3467771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { 3468771fe6b9SJerome Glisse if (on) 3469771fe6b9SJerome Glisse bios_6_scratch |= RADEON_TV_DPMS_ON; 3470771fe6b9SJerome Glisse else 3471771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_TV_DPMS_ON; 3472771fe6b9SJerome Glisse } 3473771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) { 3474771fe6b9SJerome Glisse if (on) 3475771fe6b9SJerome Glisse bios_6_scratch |= RADEON_CRT_DPMS_ON; 3476771fe6b9SJerome Glisse else 3477771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_CRT_DPMS_ON; 3478771fe6b9SJerome Glisse } 3479771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 3480771fe6b9SJerome Glisse if (on) 3481771fe6b9SJerome Glisse bios_6_scratch |= RADEON_LCD_DPMS_ON; 3482771fe6b9SJerome Glisse else 3483771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_LCD_DPMS_ON; 3484771fe6b9SJerome Glisse } 3485771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 3486771fe6b9SJerome Glisse if (on) 3487771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DFP_DPMS_ON; 3488771fe6b9SJerome Glisse else 3489771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DFP_DPMS_ON; 3490771fe6b9SJerome Glisse } 3491771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3492771fe6b9SJerome Glisse } 3493