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 508179e8078SAlex Deucher * r1xx/r2xx 509179e8078SAlex Deucher * DDC_MONID = RADEON_GPIO_MONID 510179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_CRT2_DDC 511179e8078SAlex Deucher * r3xx 512179e8078SAlex Deucher * DDC_MONID = RADEON_GPIO_MONID 513179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_DVI_DDC 514179e8078SAlex Deucher * rs3xx/rs4xx 515179e8078SAlex Deucher * DDC_MONID = RADEON_GPIOPAD_MASK 516179e8078SAlex Deucher * DDC_CRT2 = RADEON_GPIO_MONID 517179e8078SAlex Deucher */ 518179e8078SAlex Deucher switch (ddc) { 519179e8078SAlex Deucher case DDC_NONE_DETECTED: 520179e8078SAlex Deucher default: 521179e8078SAlex Deucher ddc_line = 0; 522179e8078SAlex Deucher break; 523179e8078SAlex Deucher case DDC_DVI: 524179e8078SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 525179e8078SAlex Deucher break; 526179e8078SAlex Deucher case DDC_VGA: 527179e8078SAlex Deucher ddc_line = RADEON_GPIO_VGA_DDC; 528179e8078SAlex Deucher break; 529179e8078SAlex Deucher case DDC_LCD: 530179e8078SAlex Deucher ddc_line = RADEON_GPIOPAD_MASK; 531179e8078SAlex Deucher break; 532179e8078SAlex Deucher case DDC_GPIO: 533179e8078SAlex Deucher ddc_line = RADEON_MDGPIO_MASK; 534179e8078SAlex Deucher break; 535179e8078SAlex Deucher case DDC_MONID: 536179e8078SAlex Deucher if (rdev->family == CHIP_RS300 || 537179e8078SAlex Deucher rdev->family == CHIP_RS400 || 538179e8078SAlex Deucher rdev->family == CHIP_RS480) 539179e8078SAlex Deucher ddc_line = RADEON_GPIOPAD_MASK; 540179e8078SAlex Deucher else 541179e8078SAlex Deucher ddc_line = RADEON_GPIO_MONID; 542179e8078SAlex Deucher break; 543179e8078SAlex Deucher case DDC_CRT2: 544179e8078SAlex Deucher if (rdev->family == CHIP_RS300 || 545179e8078SAlex Deucher rdev->family == CHIP_RS400 || 546179e8078SAlex Deucher rdev->family == CHIP_RS480) 547179e8078SAlex Deucher ddc_line = RADEON_GPIO_MONID; 548179e8078SAlex Deucher else if (rdev->family >= CHIP_R300) { 549179e8078SAlex Deucher ddc_line = RADEON_GPIO_DVI_DDC; 550179e8078SAlex Deucher ddc = DDC_DVI; 551179e8078SAlex Deucher } else 552179e8078SAlex Deucher ddc_line = RADEON_GPIO_CRT2_DDC; 553179e8078SAlex Deucher break; 554179e8078SAlex Deucher } 555771fe6b9SJerome Glisse 5566a93cb25SAlex Deucher if (ddc_line == RADEON_GPIOPAD_MASK) { 5576a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_GPIOPAD_MASK; 5586a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_GPIOPAD_MASK; 5596a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_GPIOPAD_A; 5606a93cb25SAlex Deucher i2c.a_data_reg = RADEON_GPIOPAD_A; 5616a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_GPIOPAD_EN; 5626a93cb25SAlex Deucher i2c.en_data_reg = RADEON_GPIOPAD_EN; 5636a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_GPIOPAD_Y; 5646a93cb25SAlex Deucher i2c.y_data_reg = RADEON_GPIOPAD_Y; 5656a93cb25SAlex Deucher } else if (ddc_line == RADEON_MDGPIO_MASK) { 5666a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_MDGPIO_MASK; 5676a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_MDGPIO_MASK; 5686a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_MDGPIO_A; 5696a93cb25SAlex Deucher i2c.a_data_reg = RADEON_MDGPIO_A; 5706a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_MDGPIO_EN; 5716a93cb25SAlex Deucher i2c.en_data_reg = RADEON_MDGPIO_EN; 5726a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_MDGPIO_Y; 5736a93cb25SAlex Deucher i2c.y_data_reg = RADEON_MDGPIO_Y; 5746a93cb25SAlex Deucher } else { 575771fe6b9SJerome Glisse i2c.mask_clk_reg = ddc_line; 576771fe6b9SJerome Glisse i2c.mask_data_reg = ddc_line; 577771fe6b9SJerome Glisse i2c.a_clk_reg = ddc_line; 578771fe6b9SJerome Glisse i2c.a_data_reg = ddc_line; 5799b9fe724SAlex Deucher i2c.en_clk_reg = ddc_line; 5809b9fe724SAlex Deucher i2c.en_data_reg = ddc_line; 5819b9fe724SAlex Deucher i2c.y_clk_reg = ddc_line; 5829b9fe724SAlex Deucher i2c.y_data_reg = ddc_line; 583771fe6b9SJerome Glisse } 584771fe6b9SJerome Glisse 585179e8078SAlex Deucher if (clk_mask && data_mask) { 586be663057SAlex Deucher /* system specific masks */ 587179e8078SAlex Deucher i2c.mask_clk_mask = clk_mask; 588179e8078SAlex Deucher i2c.mask_data_mask = data_mask; 589179e8078SAlex Deucher i2c.a_clk_mask = clk_mask; 590179e8078SAlex Deucher i2c.a_data_mask = data_mask; 591179e8078SAlex Deucher i2c.en_clk_mask = clk_mask; 592179e8078SAlex Deucher i2c.en_data_mask = data_mask; 593179e8078SAlex Deucher i2c.y_clk_mask = clk_mask; 594179e8078SAlex Deucher i2c.y_data_mask = data_mask; 595be663057SAlex Deucher } else if ((ddc_line == RADEON_GPIOPAD_MASK) || 596be663057SAlex Deucher (ddc_line == RADEON_MDGPIO_MASK)) { 597be663057SAlex Deucher /* default gpiopad masks */ 598be663057SAlex Deucher i2c.mask_clk_mask = (0x20 << 8); 599be663057SAlex Deucher i2c.mask_data_mask = 0x80; 600be663057SAlex Deucher i2c.a_clk_mask = (0x20 << 8); 601be663057SAlex Deucher i2c.a_data_mask = 0x80; 602be663057SAlex Deucher i2c.en_clk_mask = (0x20 << 8); 603be663057SAlex Deucher i2c.en_data_mask = 0x80; 604be663057SAlex Deucher i2c.y_clk_mask = (0x20 << 8); 605be663057SAlex Deucher i2c.y_data_mask = 0x80; 606179e8078SAlex Deucher } else { 607be663057SAlex Deucher /* default masks for ddc pads */ 608179e8078SAlex Deucher i2c.mask_clk_mask = RADEON_GPIO_EN_1; 609179e8078SAlex Deucher i2c.mask_data_mask = RADEON_GPIO_EN_0; 610179e8078SAlex Deucher i2c.a_clk_mask = RADEON_GPIO_A_1; 611179e8078SAlex Deucher i2c.a_data_mask = RADEON_GPIO_A_0; 612179e8078SAlex Deucher i2c.en_clk_mask = RADEON_GPIO_EN_1; 613179e8078SAlex Deucher i2c.en_data_mask = RADEON_GPIO_EN_0; 614179e8078SAlex Deucher i2c.y_clk_mask = RADEON_GPIO_Y_1; 615179e8078SAlex Deucher i2c.y_data_mask = RADEON_GPIO_Y_0; 616179e8078SAlex Deucher } 617179e8078SAlex Deucher 61840bacf16SAlex Deucher switch (rdev->family) { 61940bacf16SAlex Deucher case CHIP_R100: 62040bacf16SAlex Deucher case CHIP_RV100: 62140bacf16SAlex Deucher case CHIP_RS100: 62240bacf16SAlex Deucher case CHIP_RV200: 62340bacf16SAlex Deucher case CHIP_RS200: 62440bacf16SAlex Deucher case CHIP_RS300: 62540bacf16SAlex Deucher switch (ddc_line) { 62640bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 627b28ea411SAlex Deucher i2c.hw_capable = true; 62840bacf16SAlex Deucher break; 62940bacf16SAlex Deucher default: 63040bacf16SAlex Deucher i2c.hw_capable = false; 63140bacf16SAlex Deucher break; 63240bacf16SAlex Deucher } 63340bacf16SAlex Deucher break; 63440bacf16SAlex Deucher case CHIP_R200: 63540bacf16SAlex Deucher switch (ddc_line) { 63640bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 63740bacf16SAlex Deucher case RADEON_GPIO_MONID: 63840bacf16SAlex Deucher i2c.hw_capable = true; 63940bacf16SAlex Deucher break; 64040bacf16SAlex Deucher default: 64140bacf16SAlex Deucher i2c.hw_capable = false; 64240bacf16SAlex Deucher break; 64340bacf16SAlex Deucher } 64440bacf16SAlex Deucher break; 64540bacf16SAlex Deucher case CHIP_RV250: 64640bacf16SAlex Deucher case CHIP_RV280: 64740bacf16SAlex Deucher switch (ddc_line) { 64840bacf16SAlex Deucher case RADEON_GPIO_VGA_DDC: 64940bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 65040bacf16SAlex Deucher case RADEON_GPIO_CRT2_DDC: 65140bacf16SAlex Deucher i2c.hw_capable = true; 65240bacf16SAlex Deucher break; 65340bacf16SAlex Deucher default: 65440bacf16SAlex Deucher i2c.hw_capable = false; 65540bacf16SAlex Deucher break; 65640bacf16SAlex Deucher } 65740bacf16SAlex Deucher break; 65840bacf16SAlex Deucher case CHIP_R300: 65940bacf16SAlex Deucher case CHIP_R350: 66040bacf16SAlex Deucher switch (ddc_line) { 66140bacf16SAlex Deucher case RADEON_GPIO_VGA_DDC: 66240bacf16SAlex Deucher case RADEON_GPIO_DVI_DDC: 66340bacf16SAlex Deucher i2c.hw_capable = true; 66440bacf16SAlex Deucher break; 66540bacf16SAlex Deucher default: 66640bacf16SAlex Deucher i2c.hw_capable = false; 66740bacf16SAlex Deucher break; 66840bacf16SAlex Deucher } 66940bacf16SAlex Deucher break; 67040bacf16SAlex Deucher case CHIP_RV350: 67140bacf16SAlex Deucher case CHIP_RV380: 67240bacf16SAlex Deucher case CHIP_RS400: 67340bacf16SAlex Deucher case CHIP_RS480: 6746a93cb25SAlex Deucher switch (ddc_line) { 6756a93cb25SAlex Deucher case RADEON_GPIO_VGA_DDC: 6766a93cb25SAlex Deucher case RADEON_GPIO_DVI_DDC: 6776a93cb25SAlex Deucher i2c.hw_capable = true; 6786a93cb25SAlex Deucher break; 6796a93cb25SAlex Deucher case RADEON_GPIO_MONID: 6806a93cb25SAlex Deucher /* hw i2c on RADEON_GPIO_MONID doesn't seem to work 6816a93cb25SAlex Deucher * reliably on some pre-r4xx hardware; not sure why. 6826a93cb25SAlex Deucher */ 6836a93cb25SAlex Deucher i2c.hw_capable = false; 6846a93cb25SAlex Deucher break; 6856a93cb25SAlex Deucher default: 6866a93cb25SAlex Deucher i2c.hw_capable = false; 6876a93cb25SAlex Deucher break; 6886a93cb25SAlex Deucher } 68940bacf16SAlex Deucher break; 69040bacf16SAlex Deucher default: 69140bacf16SAlex Deucher i2c.hw_capable = false; 69240bacf16SAlex Deucher break; 6936a93cb25SAlex Deucher } 6946a93cb25SAlex Deucher i2c.mm_i2c = false; 695f376b94fSAlex Deucher 696179e8078SAlex Deucher i2c.i2c_id = ddc; 6978e36ed00SAlex Deucher i2c.hpd = RADEON_HPD_NONE; 6986a93cb25SAlex Deucher 699771fe6b9SJerome Glisse if (ddc_line) 700771fe6b9SJerome Glisse i2c.valid = true; 701771fe6b9SJerome Glisse else 702771fe6b9SJerome Glisse i2c.valid = false; 703771fe6b9SJerome Glisse 704771fe6b9SJerome Glisse return i2c; 705771fe6b9SJerome Glisse } 706771fe6b9SJerome Glisse 707f376b94fSAlex Deucher void radeon_combios_i2c_init(struct radeon_device *rdev) 708f376b94fSAlex Deucher { 709f376b94fSAlex Deucher struct drm_device *dev = rdev->ddev; 710f376b94fSAlex Deucher struct radeon_i2c_bus_rec i2c; 711f376b94fSAlex Deucher 712f376b94fSAlex Deucher 713179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 714179e8078SAlex Deucher rdev->i2c_bus[0] = radeon_i2c_create(dev, &i2c, "DVI_DDC"); 715f376b94fSAlex Deucher 716179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 717179e8078SAlex Deucher rdev->i2c_bus[1] = radeon_i2c_create(dev, &i2c, "VGA_DDC"); 718f376b94fSAlex Deucher 719f376b94fSAlex Deucher i2c.valid = true; 720f376b94fSAlex Deucher i2c.hw_capable = true; 721f376b94fSAlex Deucher i2c.mm_i2c = true; 722179e8078SAlex Deucher i2c.i2c_id = 0xa0; 723179e8078SAlex Deucher rdev->i2c_bus[2] = radeon_i2c_create(dev, &i2c, "MM_I2C"); 724179e8078SAlex Deucher 725179e8078SAlex Deucher if (rdev->family == CHIP_RS300 || 726179e8078SAlex Deucher rdev->family == CHIP_RS400 || 727179e8078SAlex Deucher rdev->family == CHIP_RS480) { 728179e8078SAlex Deucher u16 offset; 729179e8078SAlex Deucher u8 id, blocks, clk, data; 730179e8078SAlex Deucher int i; 731179e8078SAlex Deucher 732179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 733179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 734179e8078SAlex Deucher 735179e8078SAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE); 736179e8078SAlex Deucher if (offset) { 737179e8078SAlex Deucher blocks = RBIOS8(offset + 2); 738179e8078SAlex Deucher for (i = 0; i < blocks; i++) { 739179e8078SAlex Deucher id = RBIOS8(offset + 3 + (i * 5) + 0); 740179e8078SAlex Deucher if (id == 136) { 741179e8078SAlex Deucher clk = RBIOS8(offset + 3 + (i * 5) + 3); 742179e8078SAlex Deucher data = RBIOS8(offset + 3 + (i * 5) + 4); 743179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 744791cfe26SAlex Deucher (1 << clk), (1 << data)); 745179e8078SAlex Deucher rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "GPIOPAD_MASK"); 746179e8078SAlex Deucher break; 747179e8078SAlex Deucher } 748179e8078SAlex Deucher } 749179e8078SAlex Deucher } 750179e8078SAlex Deucher 751179e8078SAlex Deucher } else if (rdev->family >= CHIP_R300) { 752179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 753179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 754179e8078SAlex Deucher } else { 755179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 756179e8078SAlex Deucher rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); 757179e8078SAlex Deucher 758179e8078SAlex Deucher i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 759179e8078SAlex Deucher rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "CRT2_DDC"); 760179e8078SAlex Deucher } 761f376b94fSAlex Deucher } 762f376b94fSAlex Deucher 763771fe6b9SJerome Glisse bool radeon_combios_get_clock_info(struct drm_device *dev) 764771fe6b9SJerome Glisse { 765771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 766771fe6b9SJerome Glisse uint16_t pll_info; 767771fe6b9SJerome Glisse struct radeon_pll *p1pll = &rdev->clock.p1pll; 768771fe6b9SJerome Glisse struct radeon_pll *p2pll = &rdev->clock.p2pll; 769771fe6b9SJerome Glisse struct radeon_pll *spll = &rdev->clock.spll; 770771fe6b9SJerome Glisse struct radeon_pll *mpll = &rdev->clock.mpll; 771771fe6b9SJerome Glisse int8_t rev; 772771fe6b9SJerome Glisse uint16_t sclk, mclk; 773771fe6b9SJerome Glisse 774771fe6b9SJerome Glisse pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE); 775771fe6b9SJerome Glisse if (pll_info) { 776771fe6b9SJerome Glisse rev = RBIOS8(pll_info); 777771fe6b9SJerome Glisse 778771fe6b9SJerome Glisse /* pixel clocks */ 779771fe6b9SJerome Glisse p1pll->reference_freq = RBIOS16(pll_info + 0xe); 780771fe6b9SJerome Glisse p1pll->reference_div = RBIOS16(pll_info + 0x10); 781771fe6b9SJerome Glisse p1pll->pll_out_min = RBIOS32(pll_info + 0x12); 782771fe6b9SJerome Glisse p1pll->pll_out_max = RBIOS32(pll_info + 0x16); 78386cb2bbfSAlex Deucher p1pll->lcd_pll_out_min = p1pll->pll_out_min; 78486cb2bbfSAlex Deucher p1pll->lcd_pll_out_max = p1pll->pll_out_max; 785771fe6b9SJerome Glisse 786771fe6b9SJerome Glisse if (rev > 9) { 787771fe6b9SJerome Glisse p1pll->pll_in_min = RBIOS32(pll_info + 0x36); 788771fe6b9SJerome Glisse p1pll->pll_in_max = RBIOS32(pll_info + 0x3a); 789771fe6b9SJerome Glisse } else { 790771fe6b9SJerome Glisse p1pll->pll_in_min = 40; 791771fe6b9SJerome Glisse p1pll->pll_in_max = 500; 792771fe6b9SJerome Glisse } 793771fe6b9SJerome Glisse *p2pll = *p1pll; 794771fe6b9SJerome Glisse 795771fe6b9SJerome Glisse /* system clock */ 796771fe6b9SJerome Glisse spll->reference_freq = RBIOS16(pll_info + 0x1a); 797771fe6b9SJerome Glisse spll->reference_div = RBIOS16(pll_info + 0x1c); 798771fe6b9SJerome Glisse spll->pll_out_min = RBIOS32(pll_info + 0x1e); 799771fe6b9SJerome Glisse spll->pll_out_max = RBIOS32(pll_info + 0x22); 800771fe6b9SJerome Glisse 801771fe6b9SJerome Glisse if (rev > 10) { 802771fe6b9SJerome Glisse spll->pll_in_min = RBIOS32(pll_info + 0x48); 803771fe6b9SJerome Glisse spll->pll_in_max = RBIOS32(pll_info + 0x4c); 804771fe6b9SJerome Glisse } else { 805771fe6b9SJerome Glisse /* ??? */ 806771fe6b9SJerome Glisse spll->pll_in_min = 40; 807771fe6b9SJerome Glisse spll->pll_in_max = 500; 808771fe6b9SJerome Glisse } 809771fe6b9SJerome Glisse 810771fe6b9SJerome Glisse /* memory clock */ 811771fe6b9SJerome Glisse mpll->reference_freq = RBIOS16(pll_info + 0x26); 812771fe6b9SJerome Glisse mpll->reference_div = RBIOS16(pll_info + 0x28); 813771fe6b9SJerome Glisse mpll->pll_out_min = RBIOS32(pll_info + 0x2a); 814771fe6b9SJerome Glisse mpll->pll_out_max = RBIOS32(pll_info + 0x2e); 815771fe6b9SJerome Glisse 816771fe6b9SJerome Glisse if (rev > 10) { 817771fe6b9SJerome Glisse mpll->pll_in_min = RBIOS32(pll_info + 0x5a); 818771fe6b9SJerome Glisse mpll->pll_in_max = RBIOS32(pll_info + 0x5e); 819771fe6b9SJerome Glisse } else { 820771fe6b9SJerome Glisse /* ??? */ 821771fe6b9SJerome Glisse mpll->pll_in_min = 40; 822771fe6b9SJerome Glisse mpll->pll_in_max = 500; 823771fe6b9SJerome Glisse } 824771fe6b9SJerome Glisse 825771fe6b9SJerome Glisse /* default sclk/mclk */ 826771fe6b9SJerome Glisse sclk = RBIOS16(pll_info + 0xa); 827771fe6b9SJerome Glisse mclk = RBIOS16(pll_info + 0x8); 828771fe6b9SJerome Glisse if (sclk == 0) 829771fe6b9SJerome Glisse sclk = 200 * 100; 830771fe6b9SJerome Glisse if (mclk == 0) 831771fe6b9SJerome Glisse mclk = 200 * 100; 832771fe6b9SJerome Glisse 833771fe6b9SJerome Glisse rdev->clock.default_sclk = sclk; 834771fe6b9SJerome Glisse rdev->clock.default_mclk = mclk; 835771fe6b9SJerome Glisse 836771fe6b9SJerome Glisse return true; 837771fe6b9SJerome Glisse } 838771fe6b9SJerome Glisse return false; 839771fe6b9SJerome Glisse } 840771fe6b9SJerome Glisse 84106b6476dSAlex Deucher bool radeon_combios_sideport_present(struct radeon_device *rdev) 84206b6476dSAlex Deucher { 84306b6476dSAlex Deucher struct drm_device *dev = rdev->ddev; 84406b6476dSAlex Deucher u16 igp_info; 84506b6476dSAlex Deucher 8464c70b2eaSAlex Deucher /* sideport is AMD only */ 8474c70b2eaSAlex Deucher if (rdev->family == CHIP_RS400) 8484c70b2eaSAlex Deucher return false; 8494c70b2eaSAlex Deucher 85006b6476dSAlex Deucher igp_info = combios_get_table_offset(dev, COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE); 85106b6476dSAlex Deucher 85206b6476dSAlex Deucher if (igp_info) { 85306b6476dSAlex Deucher if (RBIOS16(igp_info + 0x4)) 85406b6476dSAlex Deucher return true; 85506b6476dSAlex Deucher } 85606b6476dSAlex Deucher return false; 85706b6476dSAlex Deucher } 85806b6476dSAlex Deucher 859246263ccSAlex Deucher static const uint32_t default_primarydac_adj[CHIP_LAST] = { 860246263ccSAlex Deucher 0x00000808, /* r100 */ 861246263ccSAlex Deucher 0x00000808, /* rv100 */ 862246263ccSAlex Deucher 0x00000808, /* rs100 */ 863246263ccSAlex Deucher 0x00000808, /* rv200 */ 864246263ccSAlex Deucher 0x00000808, /* rs200 */ 865246263ccSAlex Deucher 0x00000808, /* r200 */ 866246263ccSAlex Deucher 0x00000808, /* rv250 */ 867246263ccSAlex Deucher 0x00000000, /* rs300 */ 868246263ccSAlex Deucher 0x00000808, /* rv280 */ 869246263ccSAlex Deucher 0x00000808, /* r300 */ 870246263ccSAlex Deucher 0x00000808, /* r350 */ 871246263ccSAlex Deucher 0x00000808, /* rv350 */ 872246263ccSAlex Deucher 0x00000808, /* rv380 */ 873246263ccSAlex Deucher 0x00000808, /* r420 */ 874246263ccSAlex Deucher 0x00000808, /* r423 */ 875246263ccSAlex Deucher 0x00000808, /* rv410 */ 876246263ccSAlex Deucher 0x00000000, /* rs400 */ 877246263ccSAlex Deucher 0x00000000, /* rs480 */ 878246263ccSAlex Deucher }; 879246263ccSAlex Deucher 880246263ccSAlex Deucher static void radeon_legacy_get_primary_dac_info_from_table(struct radeon_device *rdev, 881246263ccSAlex Deucher struct radeon_encoder_primary_dac *p_dac) 882246263ccSAlex Deucher { 883246263ccSAlex Deucher p_dac->ps2_pdac_adj = default_primarydac_adj[rdev->family]; 884246263ccSAlex Deucher return; 885246263ccSAlex Deucher } 886246263ccSAlex Deucher 887771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct 888771fe6b9SJerome Glisse radeon_encoder 889771fe6b9SJerome Glisse *encoder) 890771fe6b9SJerome Glisse { 891771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 892771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 893771fe6b9SJerome Glisse uint16_t dac_info; 894771fe6b9SJerome Glisse uint8_t rev, bg, dac; 895771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *p_dac = NULL; 896246263ccSAlex Deucher int found = 0; 897771fe6b9SJerome Glisse 898246263ccSAlex Deucher p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), 899771fe6b9SJerome Glisse GFP_KERNEL); 900771fe6b9SJerome Glisse 901771fe6b9SJerome Glisse if (!p_dac) 902771fe6b9SJerome Glisse return NULL; 903771fe6b9SJerome Glisse 904246263ccSAlex Deucher /* check CRT table */ 905246263ccSAlex Deucher dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 906246263ccSAlex Deucher if (dac_info) { 907771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 908771fe6b9SJerome Glisse if (rev < 2) { 909771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 910771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf; 911771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 912771fe6b9SJerome Glisse } else { 913771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 914771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x3) & 0xf; 915771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 916771fe6b9SJerome Glisse } 9173a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 9183a89b4a9SAlex Deucher if (p_dac->ps2_pdac_adj) 919246263ccSAlex Deucher found = 1; 920771fe6b9SJerome Glisse } 921771fe6b9SJerome Glisse 922246263ccSAlex Deucher if (!found) /* fallback to defaults */ 923246263ccSAlex Deucher radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac); 924246263ccSAlex Deucher 925771fe6b9SJerome Glisse return p_dac; 926771fe6b9SJerome Glisse } 927771fe6b9SJerome Glisse 928d79766faSAlex Deucher enum radeon_tv_std 929d79766faSAlex Deucher radeon_combios_get_tv_info(struct radeon_device *rdev) 930771fe6b9SJerome Glisse { 931d79766faSAlex Deucher struct drm_device *dev = rdev->ddev; 932771fe6b9SJerome Glisse uint16_t tv_info; 933771fe6b9SJerome Glisse enum radeon_tv_std tv_std = TV_STD_NTSC; 934771fe6b9SJerome Glisse 935771fe6b9SJerome Glisse tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 936771fe6b9SJerome Glisse if (tv_info) { 937771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 938771fe6b9SJerome Glisse switch (RBIOS8(tv_info + 7) & 0xf) { 939771fe6b9SJerome Glisse case 1: 940771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 94140f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: NTSC\n"); 942771fe6b9SJerome Glisse break; 943771fe6b9SJerome Glisse case 2: 944771fe6b9SJerome Glisse tv_std = TV_STD_PAL; 94540f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL\n"); 946771fe6b9SJerome Glisse break; 947771fe6b9SJerome Glisse case 3: 948771fe6b9SJerome Glisse tv_std = TV_STD_PAL_M; 94940f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL-M\n"); 950771fe6b9SJerome Glisse break; 951771fe6b9SJerome Glisse case 4: 952771fe6b9SJerome Glisse tv_std = TV_STD_PAL_60; 95340f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: PAL-60\n"); 954771fe6b9SJerome Glisse break; 955771fe6b9SJerome Glisse case 5: 956771fe6b9SJerome Glisse tv_std = TV_STD_NTSC_J; 95740f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: NTSC-J\n"); 958771fe6b9SJerome Glisse break; 959771fe6b9SJerome Glisse case 6: 960771fe6b9SJerome Glisse tv_std = TV_STD_SCART_PAL; 96140f76d81SAlex Deucher DRM_DEBUG_KMS("Default TV standard: SCART-PAL\n"); 962771fe6b9SJerome Glisse break; 963771fe6b9SJerome Glisse default: 964771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 96540f76d81SAlex Deucher DRM_DEBUG_KMS 966771fe6b9SJerome Glisse ("Unknown TV standard; defaulting to NTSC\n"); 967771fe6b9SJerome Glisse break; 968771fe6b9SJerome Glisse } 969771fe6b9SJerome Glisse 970771fe6b9SJerome Glisse switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) { 971771fe6b9SJerome Glisse case 0: 97240f76d81SAlex Deucher DRM_DEBUG_KMS("29.498928713 MHz TV ref clk\n"); 973771fe6b9SJerome Glisse break; 974771fe6b9SJerome Glisse case 1: 97540f76d81SAlex Deucher DRM_DEBUG_KMS("28.636360000 MHz TV ref clk\n"); 976771fe6b9SJerome Glisse break; 977771fe6b9SJerome Glisse case 2: 97840f76d81SAlex Deucher DRM_DEBUG_KMS("14.318180000 MHz TV ref clk\n"); 979771fe6b9SJerome Glisse break; 980771fe6b9SJerome Glisse case 3: 98140f76d81SAlex Deucher DRM_DEBUG_KMS("27.000000000 MHz TV ref clk\n"); 982771fe6b9SJerome Glisse break; 983771fe6b9SJerome Glisse default: 984771fe6b9SJerome Glisse break; 985771fe6b9SJerome Glisse } 986771fe6b9SJerome Glisse } 987771fe6b9SJerome Glisse } 988771fe6b9SJerome Glisse return tv_std; 989771fe6b9SJerome Glisse } 990771fe6b9SJerome Glisse 991771fe6b9SJerome Glisse static const uint32_t default_tvdac_adj[CHIP_LAST] = { 992771fe6b9SJerome Glisse 0x00000000, /* r100 */ 993771fe6b9SJerome Glisse 0x00280000, /* rv100 */ 994771fe6b9SJerome Glisse 0x00000000, /* rs100 */ 995771fe6b9SJerome Glisse 0x00880000, /* rv200 */ 996771fe6b9SJerome Glisse 0x00000000, /* rs200 */ 997771fe6b9SJerome Glisse 0x00000000, /* r200 */ 998771fe6b9SJerome Glisse 0x00770000, /* rv250 */ 999771fe6b9SJerome Glisse 0x00290000, /* rs300 */ 1000771fe6b9SJerome Glisse 0x00560000, /* rv280 */ 1001771fe6b9SJerome Glisse 0x00780000, /* r300 */ 1002771fe6b9SJerome Glisse 0x00770000, /* r350 */ 1003771fe6b9SJerome Glisse 0x00780000, /* rv350 */ 1004771fe6b9SJerome Glisse 0x00780000, /* rv380 */ 1005771fe6b9SJerome Glisse 0x01080000, /* r420 */ 1006771fe6b9SJerome Glisse 0x01080000, /* r423 */ 1007771fe6b9SJerome Glisse 0x01080000, /* rv410 */ 1008771fe6b9SJerome Glisse 0x00780000, /* rs400 */ 1009771fe6b9SJerome Glisse 0x00780000, /* rs480 */ 1010771fe6b9SJerome Glisse }; 1011771fe6b9SJerome Glisse 10126a719e05SDave Airlie static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev, 10136a719e05SDave Airlie struct radeon_encoder_tv_dac *tv_dac) 1014771fe6b9SJerome Glisse { 1015771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; 1016771fe6b9SJerome Glisse if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) 1017771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 0x00880000; 1018771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1019771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10206a719e05SDave Airlie return; 1021771fe6b9SJerome Glisse } 1022771fe6b9SJerome Glisse 1023771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct 1024771fe6b9SJerome Glisse radeon_encoder 1025771fe6b9SJerome Glisse *encoder) 1026771fe6b9SJerome Glisse { 1027771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1028771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1029771fe6b9SJerome Glisse uint16_t dac_info; 1030771fe6b9SJerome Glisse uint8_t rev, bg, dac; 1031771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *tv_dac = NULL; 10326a719e05SDave Airlie int found = 0; 10336a719e05SDave Airlie 10346a719e05SDave Airlie tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); 10356a719e05SDave Airlie if (!tv_dac) 10366a719e05SDave Airlie return NULL; 1037771fe6b9SJerome Glisse 1038771fe6b9SJerome Glisse /* first check TV table */ 1039771fe6b9SJerome Glisse dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 1040771fe6b9SJerome Glisse if (dac_info) { 1041771fe6b9SJerome Glisse rev = RBIOS8(dac_info + 0x3); 1042771fe6b9SJerome Glisse if (rev > 4) { 1043771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 1044771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xd) & 0xf; 1045771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 1046771fe6b9SJerome Glisse 1047771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 1048771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xf) & 0xf; 1049771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 1050771fe6b9SJerome Glisse 1051771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x10) & 0xf; 1052771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x11) & 0xf; 1053771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 10543a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10553a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10566a719e05SDave Airlie found = 1; 1057771fe6b9SJerome Glisse } else if (rev > 1) { 1058771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 1059771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; 1060771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 1061771fe6b9SJerome Glisse 1062771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xd) & 0xf; 1063771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf; 1064771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 1065771fe6b9SJerome Glisse 1066771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 1067771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; 1068771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 10693a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10703a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10716a719e05SDave Airlie found = 1; 1072771fe6b9SJerome Glisse } 1073d79766faSAlex Deucher tv_dac->tv_std = radeon_combios_get_tv_info(rdev); 10746a719e05SDave Airlie } 10756a719e05SDave Airlie if (!found) { 1076771fe6b9SJerome Glisse /* then check CRT table */ 1077771fe6b9SJerome Glisse dac_info = 1078771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 1079771fe6b9SJerome Glisse if (dac_info) { 1080771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 1081771fe6b9SJerome Glisse if (rev < 2) { 1082771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x3) & 0xf; 1083771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf; 1084771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 1085771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 1086771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1087771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10883a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10893a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 10906a719e05SDave Airlie found = 1; 1091771fe6b9SJerome Glisse } else { 1092771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x4) & 0xf; 1093771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x5) & 0xf; 1094771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 1095771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 1096771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 1097771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 10983a89b4a9SAlex Deucher /* if the values are all zeros, use the table */ 10993a89b4a9SAlex Deucher if (tv_dac->ps2_tvdac_adj) 11006a719e05SDave Airlie found = 1; 1101771fe6b9SJerome Glisse } 11026fe7ac3fSAlex Deucher } else { 11036fe7ac3fSAlex Deucher DRM_INFO("No TV DAC info found in BIOS\n"); 1104771fe6b9SJerome Glisse } 1105771fe6b9SJerome Glisse } 1106771fe6b9SJerome Glisse 11076a719e05SDave Airlie if (!found) /* fallback to defaults */ 11086a719e05SDave Airlie radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac); 11096a719e05SDave Airlie 1110771fe6b9SJerome Glisse return tv_dac; 1111771fe6b9SJerome Glisse } 1112771fe6b9SJerome Glisse 1113771fe6b9SJerome Glisse static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct 1114771fe6b9SJerome Glisse radeon_device 1115771fe6b9SJerome Glisse *rdev) 1116771fe6b9SJerome Glisse { 1117771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 1118771fe6b9SJerome Glisse uint32_t fp_vert_stretch, fp_horz_stretch; 1119771fe6b9SJerome Glisse uint32_t ppll_div_sel, ppll_val; 11208b5c7444SMichel Dänzer uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL); 1121771fe6b9SJerome Glisse 1122771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 1123771fe6b9SJerome Glisse 1124771fe6b9SJerome Glisse if (!lvds) 1125771fe6b9SJerome Glisse return NULL; 1126771fe6b9SJerome Glisse 1127771fe6b9SJerome Glisse fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH); 1128771fe6b9SJerome Glisse fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH); 1129771fe6b9SJerome Glisse 11308b5c7444SMichel Dänzer /* These should be fail-safe defaults, fingers crossed */ 11318b5c7444SMichel Dänzer lvds->panel_pwr_delay = 200; 11328b5c7444SMichel Dänzer lvds->panel_vcc_delay = 2000; 11338b5c7444SMichel Dänzer 11348b5c7444SMichel Dänzer lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL); 11358b5c7444SMichel Dänzer lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf; 11368b5c7444SMichel Dänzer lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf; 11378b5c7444SMichel Dänzer 1138771fe6b9SJerome Glisse if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE) 1139de2103e4SAlex Deucher lvds->native_mode.vdisplay = 1140771fe6b9SJerome Glisse ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >> 1141771fe6b9SJerome Glisse RADEON_VERT_PANEL_SHIFT) + 1; 1142771fe6b9SJerome Glisse else 1143de2103e4SAlex Deucher lvds->native_mode.vdisplay = 1144771fe6b9SJerome Glisse (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1; 1145771fe6b9SJerome Glisse 1146771fe6b9SJerome Glisse if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE) 1147de2103e4SAlex Deucher lvds->native_mode.hdisplay = 1148771fe6b9SJerome Glisse (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >> 1149771fe6b9SJerome Glisse RADEON_HORZ_PANEL_SHIFT) + 1) * 8; 1150771fe6b9SJerome Glisse else 1151de2103e4SAlex Deucher lvds->native_mode.hdisplay = 1152771fe6b9SJerome Glisse ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8; 1153771fe6b9SJerome Glisse 1154de2103e4SAlex Deucher if ((lvds->native_mode.hdisplay < 640) || 1155de2103e4SAlex Deucher (lvds->native_mode.vdisplay < 480)) { 1156de2103e4SAlex Deucher lvds->native_mode.hdisplay = 640; 1157de2103e4SAlex Deucher lvds->native_mode.vdisplay = 480; 1158771fe6b9SJerome Glisse } 1159771fe6b9SJerome Glisse 1160771fe6b9SJerome Glisse ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3; 1161771fe6b9SJerome Glisse ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel); 1162771fe6b9SJerome Glisse if ((ppll_val & 0x000707ff) == 0x1bb) 1163771fe6b9SJerome Glisse lvds->use_bios_dividers = false; 1164771fe6b9SJerome Glisse else { 1165771fe6b9SJerome Glisse lvds->panel_ref_divider = 1166771fe6b9SJerome Glisse RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff; 1167771fe6b9SJerome Glisse lvds->panel_post_divider = (ppll_val >> 16) & 0x7; 1168771fe6b9SJerome Glisse lvds->panel_fb_divider = ppll_val & 0x7ff; 1169771fe6b9SJerome Glisse 1170771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1171771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1172771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1173771fe6b9SJerome Glisse } 1174771fe6b9SJerome Glisse lvds->panel_vcc_delay = 200; 1175771fe6b9SJerome Glisse 1176771fe6b9SJerome Glisse DRM_INFO("Panel info derived from registers\n"); 1177de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1178de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1179771fe6b9SJerome Glisse 1180771fe6b9SJerome Glisse return lvds; 1181771fe6b9SJerome Glisse } 1182771fe6b9SJerome Glisse 1183771fe6b9SJerome Glisse struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder 1184771fe6b9SJerome Glisse *encoder) 1185771fe6b9SJerome Glisse { 1186771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1187771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1188771fe6b9SJerome Glisse uint16_t lcd_info; 1189771fe6b9SJerome Glisse uint32_t panel_setup; 1190771fe6b9SJerome Glisse char stmp[30]; 1191771fe6b9SJerome Glisse int tmp, i; 1192771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 1193771fe6b9SJerome Glisse 1194771fe6b9SJerome Glisse lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 1195771fe6b9SJerome Glisse 1196771fe6b9SJerome Glisse if (lcd_info) { 1197771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 1198771fe6b9SJerome Glisse 1199771fe6b9SJerome Glisse if (!lvds) 1200771fe6b9SJerome Glisse return NULL; 1201771fe6b9SJerome Glisse 1202771fe6b9SJerome Glisse for (i = 0; i < 24; i++) 1203771fe6b9SJerome Glisse stmp[i] = RBIOS8(lcd_info + i + 1); 1204771fe6b9SJerome Glisse stmp[24] = 0; 1205771fe6b9SJerome Glisse 1206771fe6b9SJerome Glisse DRM_INFO("Panel ID String: %s\n", stmp); 1207771fe6b9SJerome Glisse 1208de2103e4SAlex Deucher lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19); 1209de2103e4SAlex Deucher lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b); 1210771fe6b9SJerome Glisse 1211de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 1212de2103e4SAlex Deucher lvds->native_mode.vdisplay); 1213771fe6b9SJerome Glisse 1214771fe6b9SJerome Glisse lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c); 121594cf6434SAndrew Morton lvds->panel_vcc_delay = min_t(u16, lvds->panel_vcc_delay, 2000); 1216771fe6b9SJerome Glisse 1217771fe6b9SJerome Glisse lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24); 1218771fe6b9SJerome Glisse lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf; 1219771fe6b9SJerome Glisse lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf; 1220771fe6b9SJerome Glisse 1221771fe6b9SJerome Glisse lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e); 1222771fe6b9SJerome Glisse lvds->panel_post_divider = RBIOS8(lcd_info + 0x30); 1223771fe6b9SJerome Glisse lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31); 1224771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 1225771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 1226771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 1227771fe6b9SJerome Glisse 1228771fe6b9SJerome Glisse panel_setup = RBIOS32(lcd_info + 0x39); 1229771fe6b9SJerome Glisse lvds->lvds_gen_cntl = 0xff00; 1230771fe6b9SJerome Glisse if (panel_setup & 0x1) 1231771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT; 1232771fe6b9SJerome Glisse 1233771fe6b9SJerome Glisse if ((panel_setup >> 4) & 0x1) 1234771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE; 1235771fe6b9SJerome Glisse 1236771fe6b9SJerome Glisse switch ((panel_setup >> 8) & 0x7) { 1237771fe6b9SJerome Glisse case 0: 1238771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM; 1239771fe6b9SJerome Glisse break; 1240771fe6b9SJerome Glisse case 1: 1241771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY; 1242771fe6b9SJerome Glisse break; 1243771fe6b9SJerome Glisse case 2: 1244771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY; 1245771fe6b9SJerome Glisse break; 1246771fe6b9SJerome Glisse default: 1247771fe6b9SJerome Glisse break; 1248771fe6b9SJerome Glisse } 1249771fe6b9SJerome Glisse 1250771fe6b9SJerome Glisse if ((panel_setup >> 16) & 0x1) 1251771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW; 1252771fe6b9SJerome Glisse 1253771fe6b9SJerome Glisse if ((panel_setup >> 17) & 0x1) 1254771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW; 1255771fe6b9SJerome Glisse 1256771fe6b9SJerome Glisse if ((panel_setup >> 18) & 0x1) 1257771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW; 1258771fe6b9SJerome Glisse 1259771fe6b9SJerome Glisse if ((panel_setup >> 23) & 0x1) 1260771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL; 1261771fe6b9SJerome Glisse 1262771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000); 1263771fe6b9SJerome Glisse 1264771fe6b9SJerome Glisse for (i = 0; i < 32; i++) { 1265771fe6b9SJerome Glisse tmp = RBIOS16(lcd_info + 64 + i * 2); 1266771fe6b9SJerome Glisse if (tmp == 0) 1267771fe6b9SJerome Glisse break; 1268771fe6b9SJerome Glisse 1269de2103e4SAlex Deucher if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) && 127068b61a7fSAlex Deucher (RBIOS16(tmp + 2) == lvds->native_mode.vdisplay)) { 127168b61a7fSAlex Deucher lvds->native_mode.htotal = lvds->native_mode.hdisplay + 127268b61a7fSAlex Deucher (RBIOS16(tmp + 17) - RBIOS16(tmp + 19)) * 8; 127368b61a7fSAlex Deucher lvds->native_mode.hsync_start = lvds->native_mode.hdisplay + 127468b61a7fSAlex Deucher (RBIOS16(tmp + 21) - RBIOS16(tmp + 19) - 1) * 8; 127568b61a7fSAlex Deucher lvds->native_mode.hsync_end = lvds->native_mode.hsync_start + 127668b61a7fSAlex Deucher (RBIOS8(tmp + 23) * 8); 1277771fe6b9SJerome Glisse 127868b61a7fSAlex Deucher lvds->native_mode.vtotal = lvds->native_mode.vdisplay + 127968b61a7fSAlex Deucher (RBIOS16(tmp + 24) - RBIOS16(tmp + 26)); 128068b61a7fSAlex Deucher lvds->native_mode.vsync_start = lvds->native_mode.vdisplay + 128168b61a7fSAlex Deucher ((RBIOS16(tmp + 28) & 0x7ff) - RBIOS16(tmp + 26)); 128268b61a7fSAlex Deucher lvds->native_mode.vsync_end = lvds->native_mode.vsync_start + 128368b61a7fSAlex Deucher ((RBIOS16(tmp + 28) & 0xf800) >> 11); 1284de2103e4SAlex Deucher 1285de2103e4SAlex Deucher lvds->native_mode.clock = RBIOS16(tmp + 9) * 10; 1286771fe6b9SJerome Glisse lvds->native_mode.flags = 0; 1287de2103e4SAlex Deucher /* set crtc values */ 1288de2103e4SAlex Deucher drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V); 1289de2103e4SAlex Deucher 1290771fe6b9SJerome Glisse } 1291771fe6b9SJerome Glisse } 12926fe7ac3fSAlex Deucher } else { 1293771fe6b9SJerome Glisse DRM_INFO("No panel info found in BIOS\n"); 12948dfaa8a7SMichel Dänzer lvds = radeon_legacy_get_lvds_info_from_regs(rdev); 12956fe7ac3fSAlex Deucher } 129603047cdfSMichel Dänzer 12978dfaa8a7SMichel Dänzer if (lvds) 12988dfaa8a7SMichel Dänzer encoder->native_mode = lvds->native_mode; 1299771fe6b9SJerome Glisse return lvds; 1300771fe6b9SJerome Glisse } 1301771fe6b9SJerome Glisse 1302771fe6b9SJerome Glisse static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = { 1303771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */ 1304771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */ 1305771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */ 1306771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */ 1307771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */ 1308771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */ 1309771fe6b9SJerome Glisse {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */ 1310771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */ 1311771fe6b9SJerome Glisse {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */ 1312771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */ 1313771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */ 1314771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */ 1315771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */ 1316771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */ 1317771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */ 1318771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */ 1319fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */ 1320fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */ 1321771fe6b9SJerome Glisse }; 1322771fe6b9SJerome Glisse 1323445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder, 1324445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1325771fe6b9SJerome Glisse { 1326445282dbSDave Airlie struct drm_device *dev = encoder->base.dev; 1327445282dbSDave Airlie struct radeon_device *rdev = dev->dev_private; 1328771fe6b9SJerome Glisse int i; 1329771fe6b9SJerome Glisse 1330771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 1331771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1332771fe6b9SJerome Glisse default_tmds_pll[rdev->family][i].value; 1333771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq; 1334771fe6b9SJerome Glisse } 1335771fe6b9SJerome Glisse 1336445282dbSDave Airlie return true; 1337771fe6b9SJerome Glisse } 1338771fe6b9SJerome Glisse 1339445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder, 1340445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1341771fe6b9SJerome Glisse { 1342771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1343771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1344771fe6b9SJerome Glisse uint16_t tmds_info; 1345771fe6b9SJerome Glisse int i, n; 1346771fe6b9SJerome Glisse uint8_t ver; 1347771fe6b9SJerome Glisse 1348771fe6b9SJerome Glisse tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 1349771fe6b9SJerome Glisse 1350771fe6b9SJerome Glisse if (tmds_info) { 1351771fe6b9SJerome Glisse ver = RBIOS8(tmds_info); 135240f76d81SAlex Deucher DRM_DEBUG_KMS("DFP table revision: %d\n", ver); 1353771fe6b9SJerome Glisse if (ver == 3) { 1354771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1355771fe6b9SJerome Glisse if (n > 4) 1356771fe6b9SJerome Glisse n = 4; 1357771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1358771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1359771fe6b9SJerome Glisse RBIOS32(tmds_info + i * 10 + 0x08); 1360771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1361771fe6b9SJerome Glisse RBIOS16(tmds_info + i * 10 + 0x10); 1362d9fdaafbSDave Airlie DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", 1363771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1364771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1365771fe6b9SJerome Glisse } 1366771fe6b9SJerome Glisse } else if (ver == 4) { 1367771fe6b9SJerome Glisse int stride = 0; 1368771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1369771fe6b9SJerome Glisse if (n > 4) 1370771fe6b9SJerome Glisse n = 4; 1371771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1372771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1373771fe6b9SJerome Glisse RBIOS32(tmds_info + stride + 0x08); 1374771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1375771fe6b9SJerome Glisse RBIOS16(tmds_info + stride + 0x10); 1376771fe6b9SJerome Glisse if (i == 0) 1377771fe6b9SJerome Glisse stride += 10; 1378771fe6b9SJerome Glisse else 1379771fe6b9SJerome Glisse stride += 6; 1380d9fdaafbSDave Airlie DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n", 1381771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1382771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1383771fe6b9SJerome Glisse } 1384771fe6b9SJerome Glisse } 1385fcec570bSAlex Deucher } else { 1386771fe6b9SJerome Glisse DRM_INFO("No TMDS info found in BIOS\n"); 1387fcec570bSAlex Deucher return false; 1388fcec570bSAlex Deucher } 1389445282dbSDave Airlie return true; 1390445282dbSDave Airlie } 1391445282dbSDave Airlie 1392fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder, 1393fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1394771fe6b9SJerome Glisse { 1395771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1396771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1397fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1398fcec570bSAlex Deucher 1399fcec570bSAlex Deucher /* default for macs */ 1400179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1401f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1402fcec570bSAlex Deucher 1403fcec570bSAlex Deucher /* XXX some macs have duallink chips */ 1404fcec570bSAlex Deucher switch (rdev->mode_info.connector_table) { 1405fcec570bSAlex Deucher case CT_POWERBOOK_EXTERNAL: 1406fcec570bSAlex Deucher case CT_MINI_EXTERNAL: 1407fcec570bSAlex Deucher default: 1408fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1409fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1410fcec570bSAlex Deucher break; 1411fcec570bSAlex Deucher } 1412fcec570bSAlex Deucher 1413fcec570bSAlex Deucher return true; 1414fcec570bSAlex Deucher } 1415fcec570bSAlex Deucher 1416fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder, 1417fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1418fcec570bSAlex Deucher { 1419fcec570bSAlex Deucher struct drm_device *dev = encoder->base.dev; 1420fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 1421fcec570bSAlex Deucher uint16_t offset; 1422179e8078SAlex Deucher uint8_t ver; 1423fcec570bSAlex Deucher enum radeon_combios_ddc gpio; 1424fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1425771fe6b9SJerome Glisse 1426fcec570bSAlex Deucher tmds->i2c_bus = NULL; 1427fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 1428179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1429f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1430fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1431fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1432fcec570bSAlex Deucher } else { 1433fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 1434fcec570bSAlex Deucher if (offset) { 1435fcec570bSAlex Deucher ver = RBIOS8(offset); 143640f76d81SAlex Deucher DRM_DEBUG_KMS("External TMDS Table revision: %d\n", ver); 1437fcec570bSAlex Deucher tmds->slave_addr = RBIOS8(offset + 4 + 2); 1438fcec570bSAlex Deucher tmds->slave_addr >>= 1; /* 7 bit addressing */ 1439fcec570bSAlex Deucher gpio = RBIOS8(offset + 4 + 3); 1440179e8078SAlex Deucher if (gpio == DDC_LCD) { 1441179e8078SAlex Deucher /* MM i2c */ 144240bacf16SAlex Deucher i2c_bus.valid = true; 144340bacf16SAlex Deucher i2c_bus.hw_capable = true; 144440bacf16SAlex Deucher i2c_bus.mm_i2c = true; 1445179e8078SAlex Deucher i2c_bus.i2c_id = 0xa0; 1446179e8078SAlex Deucher } else 1447179e8078SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0); 1448f376b94fSAlex Deucher tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 1449fcec570bSAlex Deucher } 1450fcec570bSAlex Deucher } 1451fcec570bSAlex Deucher 1452fcec570bSAlex Deucher if (!tmds->i2c_bus) { 1453fcec570bSAlex Deucher DRM_INFO("No valid Ext TMDS info found in BIOS\n"); 1454fcec570bSAlex Deucher return false; 1455fcec570bSAlex Deucher } 1456fcec570bSAlex Deucher 1457fcec570bSAlex Deucher return true; 1458fcec570bSAlex Deucher } 1459771fe6b9SJerome Glisse 1460771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) 1461771fe6b9SJerome Glisse { 1462771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1463771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 1464eed45b30SAlex Deucher struct radeon_hpd hpd; 1465771fe6b9SJerome Glisse 1466771fe6b9SJerome Glisse rdev->mode_info.connector_table = radeon_connector_table; 1467771fe6b9SJerome Glisse if (rdev->mode_info.connector_table == CT_NONE) { 1468771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 146971a157e8SGrant Likely if (of_machine_is_compatible("PowerBook3,3")) { 1470771fe6b9SJerome Glisse /* powerbook with VGA */ 1471771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_VGA; 147271a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook3,4") || 147371a157e8SGrant Likely of_machine_is_compatible("PowerBook3,5")) { 1474771fe6b9SJerome Glisse /* powerbook with internal tmds */ 1475771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; 147671a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,1") || 147771a157e8SGrant Likely of_machine_is_compatible("PowerBook5,2") || 147871a157e8SGrant Likely of_machine_is_compatible("PowerBook5,3") || 147971a157e8SGrant Likely of_machine_is_compatible("PowerBook5,4") || 148071a157e8SGrant Likely of_machine_is_compatible("PowerBook5,5")) { 1481771fe6b9SJerome Glisse /* powerbook with external single link tmds (sil164) */ 1482771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 148371a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,6")) { 1484771fe6b9SJerome Glisse /* powerbook with external dual or single link tmds */ 1485771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 148671a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook5,7") || 148771a157e8SGrant Likely of_machine_is_compatible("PowerBook5,8") || 148871a157e8SGrant Likely of_machine_is_compatible("PowerBook5,9")) { 1489771fe6b9SJerome Glisse /* PowerBook6,2 ? */ 1490771fe6b9SJerome Glisse /* powerbook with external dual link tmds (sil1178?) */ 1491771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 149271a157e8SGrant Likely } else if (of_machine_is_compatible("PowerBook4,1") || 149371a157e8SGrant Likely of_machine_is_compatible("PowerBook4,2") || 149471a157e8SGrant Likely of_machine_is_compatible("PowerBook4,3") || 149571a157e8SGrant Likely of_machine_is_compatible("PowerBook6,3") || 149671a157e8SGrant Likely of_machine_is_compatible("PowerBook6,5") || 149771a157e8SGrant Likely of_machine_is_compatible("PowerBook6,7")) { 1498771fe6b9SJerome Glisse /* ibook */ 1499771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IBOOK; 150071a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac4,4")) { 1501771fe6b9SJerome Glisse /* emac */ 1502771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_EMAC; 150371a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac10,1")) { 1504771fe6b9SJerome Glisse /* mini with internal tmds */ 1505771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_INTERNAL; 150671a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac10,2")) { 1507771fe6b9SJerome Glisse /* mini with external tmds */ 1508771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_EXTERNAL; 150971a157e8SGrant Likely } else if (of_machine_is_compatible("PowerMac12,1")) { 1510771fe6b9SJerome Glisse /* PowerMac8,1 ? */ 1511771fe6b9SJerome Glisse /* imac g5 isight */ 1512771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; 1513aa74fbb4SAlex Deucher } else if ((rdev->pdev->device == 0x4a48) && 1514aa74fbb4SAlex Deucher (rdev->pdev->subsystem_vendor == 0x1002) && 1515aa74fbb4SAlex Deucher (rdev->pdev->subsystem_device == 0x4a48)) { 1516aa74fbb4SAlex Deucher /* Mac X800 */ 1517aa74fbb4SAlex Deucher rdev->mode_info.connector_table = CT_MAC_X800; 15189fad321aSAlex Deucher } else if ((rdev->pdev->device == 0x4150) && 15199fad321aSAlex Deucher (rdev->pdev->subsystem_vendor == 0x1002) && 15209fad321aSAlex Deucher (rdev->pdev->subsystem_device == 0x4150)) { 15219fad321aSAlex Deucher /* Mac G5 9600 */ 15229fad321aSAlex Deucher rdev->mode_info.connector_table = CT_MAC_G5_9600; 1523771fe6b9SJerome Glisse } else 1524771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 152576a7142aSDave Airlie #ifdef CONFIG_PPC64 152676a7142aSDave Airlie if (ASIC_IS_RN50(rdev)) 152776a7142aSDave Airlie rdev->mode_info.connector_table = CT_RN50_POWER; 152876a7142aSDave Airlie else 152976a7142aSDave Airlie #endif 1530771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_GENERIC; 1531771fe6b9SJerome Glisse } 1532771fe6b9SJerome Glisse 1533771fe6b9SJerome Glisse switch (rdev->mode_info.connector_table) { 1534771fe6b9SJerome Glisse case CT_GENERIC: 1535771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (generic)\n", 1536771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1537771fe6b9SJerome Glisse /* these are the most common settings */ 1538771fe6b9SJerome Glisse if (rdev->flags & RADEON_SINGLE_CRTC) { 1539771fe6b9SJerome Glisse /* VGA - primary dac */ 1540179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1541eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1542771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15435137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1544771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1545771fe6b9SJerome Glisse 1), 1546771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1547771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1548771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1549771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1550b75fad06SAlex Deucher &ddc_i2c, 1551eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1552eed45b30SAlex Deucher &hpd); 1553771fe6b9SJerome Glisse } else if (rdev->flags & RADEON_IS_MOBILITY) { 1554771fe6b9SJerome Glisse /* LVDS */ 1555179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_NONE_DETECTED, 0, 0); 1556eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1557771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15585137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1559771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1560771fe6b9SJerome Glisse 0), 1561771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1562771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1563771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1564771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 1565b75fad06SAlex Deucher &ddc_i2c, 1566eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1567eed45b30SAlex Deucher &hpd); 1568771fe6b9SJerome Glisse 1569771fe6b9SJerome Glisse /* VGA - primary dac */ 1570179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1571eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1572771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15735137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1574771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1575771fe6b9SJerome Glisse 1), 1576771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1577771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1578771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1579771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1580b75fad06SAlex Deucher &ddc_i2c, 1581eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1582eed45b30SAlex Deucher &hpd); 1583771fe6b9SJerome Glisse } else { 1584771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1585179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1586eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 1587771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15885137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1589771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1590771fe6b9SJerome Glisse 0), 1591771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1592771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 15935137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1594771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1595771fe6b9SJerome Glisse 2), 1596771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1597771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1598771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1599771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1600771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 1601b75fad06SAlex Deucher &ddc_i2c, 1602eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1603eed45b30SAlex Deucher &hpd); 1604771fe6b9SJerome Glisse 1605771fe6b9SJerome Glisse /* VGA - primary dac */ 1606179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1607eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1608771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16095137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1610771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1611771fe6b9SJerome Glisse 1), 1612771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1613771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1614771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1615771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1616b75fad06SAlex Deucher &ddc_i2c, 1617eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1618eed45b30SAlex Deucher &hpd); 1619771fe6b9SJerome Glisse } 1620771fe6b9SJerome Glisse 1621771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 1622771fe6b9SJerome Glisse /* TV - tv dac */ 1623eed45b30SAlex Deucher ddc_i2c.valid = false; 1624eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1625771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16265137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1627771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1628771fe6b9SJerome Glisse 2), 1629771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1630771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, 1631771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1632771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1633b75fad06SAlex Deucher &ddc_i2c, 1634eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1635eed45b30SAlex Deucher &hpd); 1636771fe6b9SJerome Glisse } 1637771fe6b9SJerome Glisse break; 1638771fe6b9SJerome Glisse case CT_IBOOK: 1639771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (ibook)\n", 1640771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1641771fe6b9SJerome Glisse /* LVDS */ 1642179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1643eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1644771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16455137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1646771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1647771fe6b9SJerome Glisse 0), 1648771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1649771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1650b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1651eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1652eed45b30SAlex Deucher &hpd); 1653771fe6b9SJerome Glisse /* VGA - TV DAC */ 1654179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1655eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1656771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16575137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1658771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1659771fe6b9SJerome Glisse 2), 1660771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1661771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1662b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1663eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1664eed45b30SAlex Deucher &hpd); 1665771fe6b9SJerome Glisse /* TV - TV DAC */ 1666eed45b30SAlex Deucher ddc_i2c.valid = false; 1667eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1668771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16695137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1670771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1671771fe6b9SJerome Glisse 2), 1672771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1673771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1674771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1675b75fad06SAlex Deucher &ddc_i2c, 1676eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1677eed45b30SAlex Deucher &hpd); 1678771fe6b9SJerome Glisse break; 1679771fe6b9SJerome Glisse case CT_POWERBOOK_EXTERNAL: 1680771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook external tmds)\n", 1681771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1682771fe6b9SJerome Glisse /* LVDS */ 1683179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1684eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1685771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16865137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1687771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1688771fe6b9SJerome Glisse 0), 1689771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1690771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1691b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1692eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1693eed45b30SAlex Deucher &hpd); 1694771fe6b9SJerome Glisse /* DVI-I - primary dac, ext tmds */ 1695179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1696eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1697771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 16985137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1699771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1700771fe6b9SJerome Glisse 0), 1701771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1702771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17035137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1704771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1705771fe6b9SJerome Glisse 1), 1706771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1707b75fad06SAlex Deucher /* XXX some are SL */ 1708771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1709771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1710771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1711b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1712eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 1713eed45b30SAlex Deucher &hpd); 1714771fe6b9SJerome Glisse /* TV - TV DAC */ 1715eed45b30SAlex Deucher ddc_i2c.valid = false; 1716eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1717771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17185137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1719771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1720771fe6b9SJerome Glisse 2), 1721771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1722771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1723771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1724b75fad06SAlex Deucher &ddc_i2c, 1725eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1726eed45b30SAlex Deucher &hpd); 1727771fe6b9SJerome Glisse break; 1728771fe6b9SJerome Glisse case CT_POWERBOOK_INTERNAL: 1729771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook internal tmds)\n", 1730771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1731771fe6b9SJerome Glisse /* LVDS */ 1732179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1733eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1734771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17355137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1736771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1737771fe6b9SJerome Glisse 0), 1738771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1739771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1740b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1741eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1742eed45b30SAlex Deucher &hpd); 1743771fe6b9SJerome Glisse /* DVI-I - primary dac, int tmds */ 1744179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1745eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1746771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17475137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1748771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1749771fe6b9SJerome Glisse 0), 1750771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1751771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17525137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1753771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1754771fe6b9SJerome Glisse 1), 1755771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1756771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1757771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1758771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1759b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1760eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1761eed45b30SAlex Deucher &hpd); 1762771fe6b9SJerome Glisse /* TV - TV DAC */ 1763eed45b30SAlex Deucher ddc_i2c.valid = false; 1764eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1765771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17665137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1767771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1768771fe6b9SJerome Glisse 2), 1769771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1770771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1771771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1772b75fad06SAlex Deucher &ddc_i2c, 1773eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1774eed45b30SAlex Deucher &hpd); 1775771fe6b9SJerome Glisse break; 1776771fe6b9SJerome Glisse case CT_POWERBOOK_VGA: 1777771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook vga)\n", 1778771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1779771fe6b9SJerome Glisse /* LVDS */ 1780179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1781eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1782771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17835137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1784771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1785771fe6b9SJerome Glisse 0), 1786771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1787771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1788b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1789eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 1790eed45b30SAlex Deucher &hpd); 1791771fe6b9SJerome Glisse /* VGA - primary dac */ 1792179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1793eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1794771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 17955137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1796771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1797771fe6b9SJerome Glisse 1), 1798771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1799771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT, 1800b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1801eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1802eed45b30SAlex Deucher &hpd); 1803771fe6b9SJerome Glisse /* TV - TV DAC */ 1804eed45b30SAlex Deucher ddc_i2c.valid = false; 1805eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1806771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18075137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1808771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1809771fe6b9SJerome Glisse 2), 1810771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1811771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1812771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1813b75fad06SAlex Deucher &ddc_i2c, 1814eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1815eed45b30SAlex Deucher &hpd); 1816771fe6b9SJerome Glisse break; 1817771fe6b9SJerome Glisse case CT_MINI_EXTERNAL: 1818771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini external tmds)\n", 1819771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1820771fe6b9SJerome Glisse /* DVI-I - tv dac, ext tmds */ 1821179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1822eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 1823771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18245137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1825771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1826771fe6b9SJerome Glisse 0), 1827771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1828771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18295137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1830771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1831771fe6b9SJerome Glisse 2), 1832771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1833b75fad06SAlex Deucher /* XXX are any DL? */ 1834771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1835771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1836771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1837b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1838eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1839eed45b30SAlex Deucher &hpd); 1840771fe6b9SJerome Glisse /* TV - TV DAC */ 1841eed45b30SAlex Deucher ddc_i2c.valid = false; 1842eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1843771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18445137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1845771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1846771fe6b9SJerome Glisse 2), 1847771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1848771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1849771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1850b75fad06SAlex Deucher &ddc_i2c, 1851eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1852eed45b30SAlex Deucher &hpd); 1853771fe6b9SJerome Glisse break; 1854771fe6b9SJerome Glisse case CT_MINI_INTERNAL: 1855771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini internal tmds)\n", 1856771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1857771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1858179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1859eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1860771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18615137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1862771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1863771fe6b9SJerome Glisse 0), 1864771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1865771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18665137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1867771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1868771fe6b9SJerome Glisse 2), 1869771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1870771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1871771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1872771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1873b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1874eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 1875eed45b30SAlex Deucher &hpd); 1876771fe6b9SJerome Glisse /* TV - TV DAC */ 1877eed45b30SAlex Deucher ddc_i2c.valid = false; 1878eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1879771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18805137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1881771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1882771fe6b9SJerome Glisse 2), 1883771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1884771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1885771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1886b75fad06SAlex Deucher &ddc_i2c, 1887eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1888eed45b30SAlex Deucher &hpd); 1889771fe6b9SJerome Glisse break; 1890771fe6b9SJerome Glisse case CT_IMAC_G5_ISIGHT: 1891771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (imac g5 isight)\n", 1892771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1893771fe6b9SJerome Glisse /* DVI-D - int tmds */ 1894179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 1895eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 1896771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 18975137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1898771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1899771fe6b9SJerome Glisse 0), 1900771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1901771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT, 1902b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVID, &ddc_i2c, 1903eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 1904eed45b30SAlex Deucher &hpd); 1905771fe6b9SJerome Glisse /* VGA - tv dac */ 1906179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 1907eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1908771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19095137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1910771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1911771fe6b9SJerome Glisse 2), 1912771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1913771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1914b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1915eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1916eed45b30SAlex Deucher &hpd); 1917771fe6b9SJerome Glisse /* TV - TV DAC */ 1918eed45b30SAlex Deucher ddc_i2c.valid = false; 1919eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1920771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19215137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1922771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1923771fe6b9SJerome Glisse 2), 1924771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1925771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1926771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1927b75fad06SAlex Deucher &ddc_i2c, 1928eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1929eed45b30SAlex Deucher &hpd); 1930771fe6b9SJerome Glisse break; 1931771fe6b9SJerome Glisse case CT_EMAC: 1932771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (emac)\n", 1933771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1934771fe6b9SJerome Glisse /* VGA - primary dac */ 1935179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 1936eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1937771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19385137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1939771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1940771fe6b9SJerome Glisse 1), 1941771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1942771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 1943b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1944eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1945eed45b30SAlex Deucher &hpd); 1946771fe6b9SJerome Glisse /* VGA - tv dac */ 1947179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 1948eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1949771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19505137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1951771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1952771fe6b9SJerome Glisse 2), 1953771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1954771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1955b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1956eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 1957eed45b30SAlex Deucher &hpd); 1958771fe6b9SJerome Glisse /* TV - TV DAC */ 1959eed45b30SAlex Deucher ddc_i2c.valid = false; 1960eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 1961771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 19625137ee94SAlex Deucher radeon_get_encoder_enum(dev, 1963771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1964771fe6b9SJerome Glisse 2), 1965771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1966771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1967771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1968b75fad06SAlex Deucher &ddc_i2c, 1969eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 1970eed45b30SAlex Deucher &hpd); 1971771fe6b9SJerome Glisse break; 197276a7142aSDave Airlie case CT_RN50_POWER: 197376a7142aSDave Airlie DRM_INFO("Connector Table: %d (rn50-power)\n", 197476a7142aSDave Airlie rdev->mode_info.connector_table); 197576a7142aSDave Airlie /* VGA - primary dac */ 1976179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 197776a7142aSDave Airlie hpd.hpd = RADEON_HPD_NONE; 197876a7142aSDave Airlie radeon_add_legacy_encoder(dev, 19795137ee94SAlex Deucher radeon_get_encoder_enum(dev, 198076a7142aSDave Airlie ATOM_DEVICE_CRT1_SUPPORT, 198176a7142aSDave Airlie 1), 198276a7142aSDave Airlie ATOM_DEVICE_CRT1_SUPPORT); 198376a7142aSDave Airlie radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 198476a7142aSDave Airlie DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 198576a7142aSDave Airlie CONNECTOR_OBJECT_ID_VGA, 198676a7142aSDave Airlie &hpd); 1987179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); 198876a7142aSDave Airlie hpd.hpd = RADEON_HPD_NONE; 198976a7142aSDave Airlie radeon_add_legacy_encoder(dev, 19905137ee94SAlex Deucher radeon_get_encoder_enum(dev, 199176a7142aSDave Airlie ATOM_DEVICE_CRT2_SUPPORT, 199276a7142aSDave Airlie 2), 199376a7142aSDave Airlie ATOM_DEVICE_CRT2_SUPPORT); 199476a7142aSDave Airlie radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 199576a7142aSDave Airlie DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 199676a7142aSDave Airlie CONNECTOR_OBJECT_ID_VGA, 199776a7142aSDave Airlie &hpd); 199876a7142aSDave Airlie break; 1999aa74fbb4SAlex Deucher case CT_MAC_X800: 2000aa74fbb4SAlex Deucher DRM_INFO("Connector Table: %d (mac x800)\n", 2001aa74fbb4SAlex Deucher rdev->mode_info.connector_table); 2002aa74fbb4SAlex Deucher /* DVI - primary dac, internal tmds */ 2003aa74fbb4SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 2004aa74fbb4SAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 2005aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2006aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2007aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 2008aa74fbb4SAlex Deucher 0), 2009aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 2010aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2011aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2012aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2013aa74fbb4SAlex Deucher 1), 2014aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 2015aa74fbb4SAlex Deucher radeon_add_legacy_connector(dev, 0, 2016aa74fbb4SAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 2017aa74fbb4SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2018aa74fbb4SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 2019aa74fbb4SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2020aa74fbb4SAlex Deucher &hpd); 2021aa74fbb4SAlex Deucher /* DVI - tv dac, dvo */ 2022aa74fbb4SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); 2023aa74fbb4SAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 2024aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2025aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2026aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT, 2027aa74fbb4SAlex Deucher 0), 2028aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT); 2029aa74fbb4SAlex Deucher radeon_add_legacy_encoder(dev, 2030aa74fbb4SAlex Deucher radeon_get_encoder_enum(dev, 2031aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2032aa74fbb4SAlex Deucher 2), 2033aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 2034aa74fbb4SAlex Deucher radeon_add_legacy_connector(dev, 1, 2035aa74fbb4SAlex Deucher ATOM_DEVICE_DFP2_SUPPORT | 2036aa74fbb4SAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 2037aa74fbb4SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 2038aa74fbb4SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, 2039aa74fbb4SAlex Deucher &hpd); 2040aa74fbb4SAlex Deucher break; 20419fad321aSAlex Deucher case CT_MAC_G5_9600: 20429fad321aSAlex Deucher DRM_INFO("Connector Table: %d (mac g5 9600)\n", 20439fad321aSAlex Deucher rdev->mode_info.connector_table); 20449fad321aSAlex Deucher /* DVI - tv dac, dvo */ 20459fad321aSAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 20469fad321aSAlex Deucher hpd.hpd = RADEON_HPD_1; /* ??? */ 20479fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20489fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20499fad321aSAlex Deucher ATOM_DEVICE_DFP2_SUPPORT, 20509fad321aSAlex Deucher 0), 20519fad321aSAlex Deucher ATOM_DEVICE_DFP2_SUPPORT); 20529fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20539fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20549fad321aSAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 20559fad321aSAlex Deucher 2), 20569fad321aSAlex Deucher ATOM_DEVICE_CRT2_SUPPORT); 20579fad321aSAlex Deucher radeon_add_legacy_connector(dev, 0, 20589fad321aSAlex Deucher ATOM_DEVICE_DFP2_SUPPORT | 20599fad321aSAlex Deucher ATOM_DEVICE_CRT2_SUPPORT, 20609fad321aSAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 20619fad321aSAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 20629fad321aSAlex Deucher &hpd); 20639fad321aSAlex Deucher /* ADC - primary dac, internal tmds */ 20649fad321aSAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 20659fad321aSAlex Deucher hpd.hpd = RADEON_HPD_2; /* ??? */ 20669fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20679fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20689fad321aSAlex Deucher ATOM_DEVICE_DFP1_SUPPORT, 20699fad321aSAlex Deucher 0), 20709fad321aSAlex Deucher ATOM_DEVICE_DFP1_SUPPORT); 20719fad321aSAlex Deucher radeon_add_legacy_encoder(dev, 20729fad321aSAlex Deucher radeon_get_encoder_enum(dev, 20739fad321aSAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 20749fad321aSAlex Deucher 1), 20759fad321aSAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 20769fad321aSAlex Deucher radeon_add_legacy_connector(dev, 1, 20779fad321aSAlex Deucher ATOM_DEVICE_DFP1_SUPPORT | 20789fad321aSAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 20799fad321aSAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 20809fad321aSAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 20819fad321aSAlex Deucher &hpd); 2082beb47274SAlex Deucher /* TV - TV DAC */ 2083beb47274SAlex Deucher ddc_i2c.valid = false; 2084beb47274SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2085beb47274SAlex Deucher radeon_add_legacy_encoder(dev, 2086beb47274SAlex Deucher radeon_get_encoder_enum(dev, 2087beb47274SAlex Deucher ATOM_DEVICE_TV1_SUPPORT, 2088beb47274SAlex Deucher 2), 2089beb47274SAlex Deucher ATOM_DEVICE_TV1_SUPPORT); 2090beb47274SAlex Deucher radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 2091beb47274SAlex Deucher DRM_MODE_CONNECTOR_SVIDEO, 2092beb47274SAlex Deucher &ddc_i2c, 2093beb47274SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2094beb47274SAlex Deucher &hpd); 20959fad321aSAlex Deucher break; 2096771fe6b9SJerome Glisse default: 2097771fe6b9SJerome Glisse DRM_INFO("Connector table: %d (invalid)\n", 2098771fe6b9SJerome Glisse rdev->mode_info.connector_table); 2099771fe6b9SJerome Glisse return false; 2100771fe6b9SJerome Glisse } 2101771fe6b9SJerome Glisse 2102771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2103771fe6b9SJerome Glisse 2104771fe6b9SJerome Glisse return true; 2105771fe6b9SJerome Glisse } 2106771fe6b9SJerome Glisse 2107771fe6b9SJerome Glisse static bool radeon_apply_legacy_quirks(struct drm_device *dev, 2108771fe6b9SJerome Glisse int bios_index, 2109771fe6b9SJerome Glisse enum radeon_combios_connector 2110771fe6b9SJerome Glisse *legacy_connector, 2111eed45b30SAlex Deucher struct radeon_i2c_bus_rec *ddc_i2c, 2112eed45b30SAlex Deucher struct radeon_hpd *hpd) 2113771fe6b9SJerome Glisse { 2114fcec570bSAlex Deucher 2115771fe6b9SJerome Glisse /* Certain IBM chipset RN50s have a BIOS reporting two VGAs, 2116771fe6b9SJerome Glisse one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */ 2117771fe6b9SJerome Glisse if (dev->pdev->device == 0x515e && 2118771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x1014) { 2119771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_CRT_LEGACY && 2120771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 2121771fe6b9SJerome Glisse return false; 2122771fe6b9SJerome Glisse } 2123771fe6b9SJerome Glisse 2124771fe6b9SJerome Glisse /* X300 card with extra non-existent DVI port */ 2125771fe6b9SJerome Glisse if (dev->pdev->device == 0x5B60 && 2126771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x17af && 2127771fe6b9SJerome Glisse dev->pdev->subsystem_device == 0x201e && bios_index == 2) { 2128771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_DVI_I_LEGACY) 2129771fe6b9SJerome Glisse return false; 2130771fe6b9SJerome Glisse } 2131771fe6b9SJerome Glisse 2132771fe6b9SJerome Glisse return true; 2133771fe6b9SJerome Glisse } 2134771fe6b9SJerome Glisse 2135790cfb34SAlex Deucher static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev) 2136790cfb34SAlex Deucher { 2137790cfb34SAlex Deucher /* Acer 5102 has non-existent TV port */ 2138790cfb34SAlex Deucher if (dev->pdev->device == 0x5975 && 2139790cfb34SAlex Deucher dev->pdev->subsystem_vendor == 0x1025 && 2140790cfb34SAlex Deucher dev->pdev->subsystem_device == 0x009f) 2141790cfb34SAlex Deucher return false; 2142790cfb34SAlex Deucher 2143fc7f7119SAlex Deucher /* HP dc5750 has non-existent TV port */ 2144fc7f7119SAlex Deucher if (dev->pdev->device == 0x5974 && 2145fc7f7119SAlex Deucher dev->pdev->subsystem_vendor == 0x103c && 2146fc7f7119SAlex Deucher dev->pdev->subsystem_device == 0x280a) 2147fc7f7119SAlex Deucher return false; 2148fc7f7119SAlex Deucher 2149fd874ad0SAlex Deucher /* MSI S270 has non-existent TV port */ 2150fd874ad0SAlex Deucher if (dev->pdev->device == 0x5955 && 2151fd874ad0SAlex Deucher dev->pdev->subsystem_vendor == 0x1462 && 2152fd874ad0SAlex Deucher dev->pdev->subsystem_device == 0x0131) 2153fd874ad0SAlex Deucher return false; 2154fd874ad0SAlex Deucher 2155790cfb34SAlex Deucher return true; 2156790cfb34SAlex Deucher } 2157790cfb34SAlex Deucher 2158b75fad06SAlex Deucher static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d) 2159b75fad06SAlex Deucher { 2160b75fad06SAlex Deucher struct radeon_device *rdev = dev->dev_private; 2161b75fad06SAlex Deucher uint32_t ext_tmds_info; 2162b75fad06SAlex Deucher 2163b75fad06SAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2164b75fad06SAlex Deucher if (is_dvi_d) 2165b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 2166b75fad06SAlex Deucher else 2167b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2168b75fad06SAlex Deucher } 2169b75fad06SAlex Deucher ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2170b75fad06SAlex Deucher if (ext_tmds_info) { 2171b75fad06SAlex Deucher uint8_t rev = RBIOS8(ext_tmds_info); 2172b75fad06SAlex Deucher uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5); 2173b75fad06SAlex Deucher if (rev >= 3) { 2174b75fad06SAlex Deucher if (is_dvi_d) 2175b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 2176b75fad06SAlex Deucher else 2177b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 2178b75fad06SAlex Deucher } else { 2179b75fad06SAlex Deucher if (flags & 1) { 2180b75fad06SAlex Deucher if (is_dvi_d) 2181b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 2182b75fad06SAlex Deucher else 2183b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 2184b75fad06SAlex Deucher } 2185b75fad06SAlex Deucher } 2186b75fad06SAlex Deucher } 2187b75fad06SAlex Deucher if (is_dvi_d) 2188b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 2189b75fad06SAlex Deucher else 2190b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2191b75fad06SAlex Deucher } 2192b75fad06SAlex Deucher 2193771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) 2194771fe6b9SJerome Glisse { 2195771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2196771fe6b9SJerome Glisse uint32_t conn_info, entry, devices; 2197b75fad06SAlex Deucher uint16_t tmp, connector_object_id; 2198771fe6b9SJerome Glisse enum radeon_combios_ddc ddc_type; 2199771fe6b9SJerome Glisse enum radeon_combios_connector connector; 2200771fe6b9SJerome Glisse int i = 0; 2201771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 2202eed45b30SAlex Deucher struct radeon_hpd hpd; 2203771fe6b9SJerome Glisse 2204771fe6b9SJerome Glisse conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE); 2205771fe6b9SJerome Glisse if (conn_info) { 2206771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 2207771fe6b9SJerome Glisse entry = conn_info + 2 + i * 2; 2208771fe6b9SJerome Glisse 2209771fe6b9SJerome Glisse if (!RBIOS16(entry)) 2210771fe6b9SJerome Glisse break; 2211771fe6b9SJerome Glisse 2212771fe6b9SJerome Glisse tmp = RBIOS16(entry); 2213771fe6b9SJerome Glisse 2214771fe6b9SJerome Glisse connector = (tmp >> 12) & 0xf; 2215771fe6b9SJerome Glisse 2216771fe6b9SJerome Glisse ddc_type = (tmp >> 8) & 0xf; 2217179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, ddc_type, 0, 0); 2218771fe6b9SJerome Glisse 2219eed45b30SAlex Deucher switch (connector) { 2220eed45b30SAlex Deucher case CONNECTOR_PROPRIETARY_LEGACY: 2221eed45b30SAlex Deucher case CONNECTOR_DVI_I_LEGACY: 2222eed45b30SAlex Deucher case CONNECTOR_DVI_D_LEGACY: 2223eed45b30SAlex Deucher if ((tmp >> 4) & 0x1) 2224eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_2; 2225eed45b30SAlex Deucher else 2226eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_1; 2227eed45b30SAlex Deucher break; 2228eed45b30SAlex Deucher default: 2229eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2230eed45b30SAlex Deucher break; 2231eed45b30SAlex Deucher } 2232eed45b30SAlex Deucher 22332d152c6bSAlex Deucher if (!radeon_apply_legacy_quirks(dev, i, &connector, 2234eed45b30SAlex Deucher &ddc_i2c, &hpd)) 22352d152c6bSAlex Deucher continue; 2236771fe6b9SJerome Glisse 2237771fe6b9SJerome Glisse switch (connector) { 2238771fe6b9SJerome Glisse case CONNECTOR_PROPRIETARY_LEGACY: 2239771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) 2240771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2241771fe6b9SJerome Glisse else 2242771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2243771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22445137ee94SAlex Deucher radeon_get_encoder_enum 2245771fe6b9SJerome Glisse (dev, devices, 0), 2246771fe6b9SJerome Glisse devices); 2247771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2248771fe6b9SJerome Glisse legacy_connector_convert 2249771fe6b9SJerome Glisse [connector], 2250b75fad06SAlex Deucher &ddc_i2c, 2251eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, 2252eed45b30SAlex Deucher &hpd); 2253771fe6b9SJerome Glisse break; 2254771fe6b9SJerome Glisse case CONNECTOR_CRT_LEGACY: 2255771fe6b9SJerome Glisse if (tmp & 0x1) { 2256771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT2_SUPPORT; 2257771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22585137ee94SAlex Deucher radeon_get_encoder_enum 2259771fe6b9SJerome Glisse (dev, 2260771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2261771fe6b9SJerome Glisse 2), 2262771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2263771fe6b9SJerome Glisse } else { 2264771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT1_SUPPORT; 2265771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22665137ee94SAlex Deucher radeon_get_encoder_enum 2267771fe6b9SJerome Glisse (dev, 2268771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2269771fe6b9SJerome Glisse 1), 2270771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2271771fe6b9SJerome Glisse } 2272771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2273771fe6b9SJerome Glisse i, 2274771fe6b9SJerome Glisse devices, 2275771fe6b9SJerome Glisse legacy_connector_convert 2276771fe6b9SJerome Glisse [connector], 2277b75fad06SAlex Deucher &ddc_i2c, 2278eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2279eed45b30SAlex Deucher &hpd); 2280771fe6b9SJerome Glisse break; 2281771fe6b9SJerome Glisse case CONNECTOR_DVI_I_LEGACY: 2282771fe6b9SJerome Glisse devices = 0; 2283771fe6b9SJerome Glisse if (tmp & 0x1) { 2284771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT2_SUPPORT; 2285771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22865137ee94SAlex Deucher radeon_get_encoder_enum 2287771fe6b9SJerome Glisse (dev, 2288771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 2289771fe6b9SJerome Glisse 2), 2290771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 2291771fe6b9SJerome Glisse } else { 2292771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT1_SUPPORT; 2293771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 22945137ee94SAlex Deucher radeon_get_encoder_enum 2295771fe6b9SJerome Glisse (dev, 2296771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2297771fe6b9SJerome Glisse 1), 2298771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2299771fe6b9SJerome Glisse } 2300771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) { 2301771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP2_SUPPORT; 2302771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23035137ee94SAlex Deucher radeon_get_encoder_enum 2304771fe6b9SJerome Glisse (dev, 2305771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 2306771fe6b9SJerome Glisse 0), 2307771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 2308b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 0); 2309771fe6b9SJerome Glisse } else { 2310771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP1_SUPPORT; 2311771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23125137ee94SAlex Deucher radeon_get_encoder_enum 2313771fe6b9SJerome Glisse (dev, 2314771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2315771fe6b9SJerome Glisse 0), 2316771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2317b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2318771fe6b9SJerome Glisse } 2319771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2320771fe6b9SJerome Glisse i, 2321771fe6b9SJerome Glisse devices, 2322771fe6b9SJerome Glisse legacy_connector_convert 2323771fe6b9SJerome Glisse [connector], 2324b75fad06SAlex Deucher &ddc_i2c, 2325eed45b30SAlex Deucher connector_object_id, 2326eed45b30SAlex Deucher &hpd); 2327771fe6b9SJerome Glisse break; 2328771fe6b9SJerome Glisse case CONNECTOR_DVI_D_LEGACY: 2329b75fad06SAlex Deucher if ((tmp >> 4) & 0x1) { 2330771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 2331b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 1); 2332b75fad06SAlex Deucher } else { 2333771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 2334b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 2335b75fad06SAlex Deucher } 2336771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23375137ee94SAlex Deucher radeon_get_encoder_enum 2338771fe6b9SJerome Glisse (dev, devices, 0), 2339771fe6b9SJerome Glisse devices); 2340771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 2341771fe6b9SJerome Glisse legacy_connector_convert 2342771fe6b9SJerome Glisse [connector], 2343b75fad06SAlex Deucher &ddc_i2c, 2344eed45b30SAlex Deucher connector_object_id, 2345eed45b30SAlex Deucher &hpd); 2346771fe6b9SJerome Glisse break; 2347771fe6b9SJerome Glisse case CONNECTOR_CTV_LEGACY: 2348771fe6b9SJerome Glisse case CONNECTOR_STV_LEGACY: 2349771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23505137ee94SAlex Deucher radeon_get_encoder_enum 2351771fe6b9SJerome Glisse (dev, 2352771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2353771fe6b9SJerome Glisse 2), 2354771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2355771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, 2356771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2357771fe6b9SJerome Glisse legacy_connector_convert 2358771fe6b9SJerome Glisse [connector], 2359b75fad06SAlex Deucher &ddc_i2c, 2360eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2361eed45b30SAlex Deucher &hpd); 2362771fe6b9SJerome Glisse break; 2363771fe6b9SJerome Glisse default: 2364771fe6b9SJerome Glisse DRM_ERROR("Unknown connector type: %d\n", 2365771fe6b9SJerome Glisse connector); 2366771fe6b9SJerome Glisse continue; 2367771fe6b9SJerome Glisse } 2368771fe6b9SJerome Glisse 2369771fe6b9SJerome Glisse } 2370771fe6b9SJerome Glisse } else { 2371771fe6b9SJerome Glisse uint16_t tmds_info = 2372771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 2373771fe6b9SJerome Glisse if (tmds_info) { 2374d9fdaafbSDave Airlie DRM_DEBUG_KMS("Found DFP table, assuming DVI connector\n"); 2375771fe6b9SJerome Glisse 2376771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23775137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2378771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 2379771fe6b9SJerome Glisse 1), 2380771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 2381771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 23825137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2383771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2384771fe6b9SJerome Glisse 0), 2385771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 2386771fe6b9SJerome Glisse 2387179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); 23888e36ed00SAlex Deucher hpd.hpd = RADEON_HPD_1; 2389771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2390771fe6b9SJerome Glisse 0, 2391771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT | 2392771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 2393771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 2394b75fad06SAlex Deucher &ddc_i2c, 2395eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I, 2396eed45b30SAlex Deucher &hpd); 2397771fe6b9SJerome Glisse } else { 2398d0c403e9SAlex Deucher uint16_t crt_info = 2399d0c403e9SAlex Deucher combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 2400d9fdaafbSDave Airlie DRM_DEBUG_KMS("Found CRT table, assuming VGA connector\n"); 2401d0c403e9SAlex Deucher if (crt_info) { 2402d0c403e9SAlex Deucher radeon_add_legacy_encoder(dev, 24035137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2404d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2405d0c403e9SAlex Deucher 1), 2406d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 2407179e8078SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); 2408eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2409d0c403e9SAlex Deucher radeon_add_legacy_connector(dev, 2410d0c403e9SAlex Deucher 0, 2411d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2412d0c403e9SAlex Deucher DRM_MODE_CONNECTOR_VGA, 2413b75fad06SAlex Deucher &ddc_i2c, 2414eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_VGA, 2415eed45b30SAlex Deucher &hpd); 2416d0c403e9SAlex Deucher } else { 2417d9fdaafbSDave Airlie DRM_DEBUG_KMS("No connector info found\n"); 2418771fe6b9SJerome Glisse return false; 2419771fe6b9SJerome Glisse } 2420771fe6b9SJerome Glisse } 2421d0c403e9SAlex Deucher } 2422771fe6b9SJerome Glisse 2423771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) { 2424771fe6b9SJerome Glisse uint16_t lcd_info = 2425771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 2426771fe6b9SJerome Glisse if (lcd_info) { 2427771fe6b9SJerome Glisse uint16_t lcd_ddc_info = 2428771fe6b9SJerome Glisse combios_get_table_offset(dev, 2429771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE); 2430771fe6b9SJerome Glisse 2431771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24325137ee94SAlex Deucher radeon_get_encoder_enum(dev, 2433771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2434771fe6b9SJerome Glisse 0), 2435771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 2436771fe6b9SJerome Glisse 2437771fe6b9SJerome Glisse if (lcd_ddc_info) { 2438771fe6b9SJerome Glisse ddc_type = RBIOS8(lcd_ddc_info + 2); 2439771fe6b9SJerome Glisse switch (ddc_type) { 2440771fe6b9SJerome Glisse case DDC_LCD: 2441771fe6b9SJerome Glisse ddc_i2c = 2442179e8078SAlex Deucher combios_setup_i2c_bus(rdev, 2443179e8078SAlex Deucher DDC_LCD, 2444179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 3), 2445179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 7)); 2446f376b94fSAlex Deucher radeon_i2c_add(rdev, &ddc_i2c, "LCD"); 2447771fe6b9SJerome Glisse break; 2448771fe6b9SJerome Glisse case DDC_GPIO: 2449771fe6b9SJerome Glisse ddc_i2c = 2450179e8078SAlex Deucher combios_setup_i2c_bus(rdev, 2451179e8078SAlex Deucher DDC_GPIO, 2452179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 3), 2453179e8078SAlex Deucher RBIOS32(lcd_ddc_info + 7)); 2454f376b94fSAlex Deucher radeon_i2c_add(rdev, &ddc_i2c, "LCD"); 2455771fe6b9SJerome Glisse break; 2456771fe6b9SJerome Glisse default: 2457179e8078SAlex Deucher ddc_i2c = 2458179e8078SAlex Deucher combios_setup_i2c_bus(rdev, ddc_type, 0, 0); 2459771fe6b9SJerome Glisse break; 2460771fe6b9SJerome Glisse } 2461d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD DDC Info Table found!\n"); 2462771fe6b9SJerome Glisse } else 2463771fe6b9SJerome Glisse ddc_i2c.valid = false; 2464771fe6b9SJerome Glisse 2465eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2466771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2467771fe6b9SJerome Glisse 5, 2468771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2469771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 2470b75fad06SAlex Deucher &ddc_i2c, 2471eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_LVDS, 2472eed45b30SAlex Deucher &hpd); 2473771fe6b9SJerome Glisse } 2474771fe6b9SJerome Glisse } 2475771fe6b9SJerome Glisse 2476771fe6b9SJerome Glisse /* check TV table */ 2477771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 2478771fe6b9SJerome Glisse uint32_t tv_info = 2479771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 2480771fe6b9SJerome Glisse if (tv_info) { 2481771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 2482790cfb34SAlex Deucher if (radeon_apply_legacy_tv_quirks(dev)) { 2483eed45b30SAlex Deucher hpd.hpd = RADEON_HPD_NONE; 2484d294ed69SDave Airlie ddc_i2c.valid = false; 2485771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 24865137ee94SAlex Deucher radeon_get_encoder_enum 2487771fe6b9SJerome Glisse (dev, 2488771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2489771fe6b9SJerome Glisse 2), 2490771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2491771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 6, 2492771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2493771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 2494b75fad06SAlex Deucher &ddc_i2c, 2495eed45b30SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO, 2496eed45b30SAlex Deucher &hpd); 2497771fe6b9SJerome Glisse } 2498771fe6b9SJerome Glisse } 2499771fe6b9SJerome Glisse } 2500790cfb34SAlex Deucher } 2501771fe6b9SJerome Glisse 2502771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2503771fe6b9SJerome Glisse 2504771fe6b9SJerome Glisse return true; 2505771fe6b9SJerome Glisse } 2506771fe6b9SJerome Glisse 2507*63f7d982SAlex Deucher static const char *thermal_controller_names[] = { 2508*63f7d982SAlex Deucher "NONE", 2509*63f7d982SAlex Deucher "lm63", 2510*63f7d982SAlex Deucher "adm1032", 2511*63f7d982SAlex Deucher }; 2512*63f7d982SAlex Deucher 251356278a8eSAlex Deucher void radeon_combios_get_power_modes(struct radeon_device *rdev) 251456278a8eSAlex Deucher { 251556278a8eSAlex Deucher struct drm_device *dev = rdev->ddev; 251656278a8eSAlex Deucher u16 offset, misc, misc2 = 0; 251756278a8eSAlex Deucher u8 rev, blocks, tmp; 251856278a8eSAlex Deucher int state_index = 0; 251956278a8eSAlex Deucher 2520a48b9b4eSAlex Deucher rdev->pm.default_power_state_index = -1; 252156278a8eSAlex Deucher 25220975b162SAlex Deucher /* allocate 2 power states */ 25230975b162SAlex Deucher rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * 2, GFP_KERNEL); 25240975b162SAlex Deucher if (!rdev->pm.power_state) { 25250975b162SAlex Deucher rdev->pm.default_power_state_index = state_index; 25260975b162SAlex Deucher rdev->pm.num_power_states = 0; 25270975b162SAlex Deucher 25280975b162SAlex Deucher rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; 25290975b162SAlex Deucher rdev->pm.current_clock_mode_index = 0; 25300975b162SAlex Deucher return; 25310975b162SAlex Deucher } 25320975b162SAlex Deucher 2533*63f7d982SAlex Deucher /* check for a thermal chip */ 2534*63f7d982SAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_OVERDRIVE_INFO_TABLE); 2535*63f7d982SAlex Deucher if (offset) { 2536*63f7d982SAlex Deucher u8 thermal_controller = 0, gpio = 0, i2c_addr = 0, clk_bit = 0, data_bit = 0; 2537*63f7d982SAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 2538*63f7d982SAlex Deucher 2539*63f7d982SAlex Deucher rev = RBIOS8(offset); 2540*63f7d982SAlex Deucher 2541*63f7d982SAlex Deucher if (rev == 0) { 2542*63f7d982SAlex Deucher thermal_controller = RBIOS8(offset + 3); 2543*63f7d982SAlex Deucher gpio = RBIOS8(offset + 4) & 0x3f; 2544*63f7d982SAlex Deucher i2c_addr = RBIOS8(offset + 5); 2545*63f7d982SAlex Deucher } else if (rev == 1) { 2546*63f7d982SAlex Deucher thermal_controller = RBIOS8(offset + 4); 2547*63f7d982SAlex Deucher gpio = RBIOS8(offset + 5) & 0x3f; 2548*63f7d982SAlex Deucher i2c_addr = RBIOS8(offset + 6); 2549*63f7d982SAlex Deucher } else if (rev == 2) { 2550*63f7d982SAlex Deucher thermal_controller = RBIOS8(offset + 4); 2551*63f7d982SAlex Deucher gpio = RBIOS8(offset + 5) & 0x3f; 2552*63f7d982SAlex Deucher i2c_addr = RBIOS8(offset + 6); 2553*63f7d982SAlex Deucher clk_bit = RBIOS8(offset + 0xa); 2554*63f7d982SAlex Deucher data_bit = RBIOS8(offset + 0xb); 2555*63f7d982SAlex Deucher } 2556*63f7d982SAlex Deucher if ((thermal_controller > 0) && (thermal_controller < 3)) { 2557*63f7d982SAlex Deucher DRM_INFO("Possible %s thermal controller at 0x%02x\n", 2558*63f7d982SAlex Deucher thermal_controller_names[thermal_controller], 2559*63f7d982SAlex Deucher i2c_addr >> 1); 2560*63f7d982SAlex Deucher if (gpio == DDC_LCD) { 2561*63f7d982SAlex Deucher /* MM i2c */ 2562*63f7d982SAlex Deucher i2c_bus.valid = true; 2563*63f7d982SAlex Deucher i2c_bus.hw_capable = true; 2564*63f7d982SAlex Deucher i2c_bus.mm_i2c = true; 2565*63f7d982SAlex Deucher i2c_bus.i2c_id = 0xa0; 2566*63f7d982SAlex Deucher } else if (gpio == DDC_GPIO) 2567*63f7d982SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 1 << clk_bit, 1 << data_bit); 2568*63f7d982SAlex Deucher else 2569*63f7d982SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0); 2570*63f7d982SAlex Deucher rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); 2571*63f7d982SAlex Deucher if (rdev->pm.i2c_bus) { 2572*63f7d982SAlex Deucher struct i2c_board_info info = { }; 2573*63f7d982SAlex Deucher const char *name = thermal_controller_names[thermal_controller]; 2574*63f7d982SAlex Deucher info.addr = i2c_addr >> 1; 2575*63f7d982SAlex Deucher strlcpy(info.type, name, sizeof(info.type)); 2576*63f7d982SAlex Deucher i2c_new_device(&rdev->pm.i2c_bus->adapter, &info); 2577*63f7d982SAlex Deucher } 2578*63f7d982SAlex Deucher } 2579*63f7d982SAlex Deucher } 2580*63f7d982SAlex Deucher 258156278a8eSAlex Deucher if (rdev->flags & RADEON_IS_MOBILITY) { 258256278a8eSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE); 258356278a8eSAlex Deucher if (offset) { 258456278a8eSAlex Deucher rev = RBIOS8(offset); 258556278a8eSAlex Deucher blocks = RBIOS8(offset + 0x2); 258656278a8eSAlex Deucher /* power mode 0 tends to be the only valid one */ 258756278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 258856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = RBIOS32(offset + 0x5 + 0x2); 258956278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = RBIOS32(offset + 0x5 + 0x6); 259056278a8eSAlex Deucher if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) || 259156278a8eSAlex Deucher (rdev->pm.power_state[state_index].clock_info[0].sclk == 0)) 259256278a8eSAlex Deucher goto default_mode; 25930ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 25940ec0e74fSAlex Deucher POWER_STATE_TYPE_BATTERY; 259556278a8eSAlex Deucher misc = RBIOS16(offset + 0x5 + 0x0); 259656278a8eSAlex Deucher if (rev > 4) 259756278a8eSAlex Deucher misc2 = RBIOS16(offset + 0x5 + 0xe); 259879daedc9SAlex Deucher rdev->pm.power_state[state_index].misc = misc; 259979daedc9SAlex Deucher rdev->pm.power_state[state_index].misc2 = misc2; 260056278a8eSAlex Deucher if (misc & 0x4) { 260156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_GPIO; 260256278a8eSAlex Deucher if (misc & 0x8) 260356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 260456278a8eSAlex Deucher true; 260556278a8eSAlex Deucher else 260656278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = 260756278a8eSAlex Deucher false; 260856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = true; 260956278a8eSAlex Deucher if (rev < 6) { 261056278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 261156278a8eSAlex Deucher RBIOS16(offset + 0x5 + 0xb) * 4; 261256278a8eSAlex Deucher tmp = RBIOS8(offset + 0x5 + 0xd); 261356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 261456278a8eSAlex Deucher } else { 261556278a8eSAlex Deucher u8 entries = RBIOS8(offset + 0x5 + 0xb); 261656278a8eSAlex Deucher u16 voltage_table_offset = RBIOS16(offset + 0x5 + 0xc); 261756278a8eSAlex Deucher if (entries && voltage_table_offset) { 261856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg = 261956278a8eSAlex Deucher RBIOS16(voltage_table_offset) * 4; 262056278a8eSAlex Deucher tmp = RBIOS8(voltage_table_offset + 0x2); 262156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp); 262256278a8eSAlex Deucher } else 262356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = false; 262456278a8eSAlex Deucher } 262556278a8eSAlex Deucher switch ((misc2 & 0x700) >> 8) { 262656278a8eSAlex Deucher case 0: 262756278a8eSAlex Deucher default: 262856278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 0; 262956278a8eSAlex Deucher break; 263056278a8eSAlex Deucher case 1: 263156278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 33; 263256278a8eSAlex Deucher break; 263356278a8eSAlex Deucher case 2: 263456278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 66; 263556278a8eSAlex Deucher break; 263656278a8eSAlex Deucher case 3: 263756278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 99; 263856278a8eSAlex Deucher break; 263956278a8eSAlex Deucher case 4: 264056278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 132; 264156278a8eSAlex Deucher break; 264256278a8eSAlex Deucher } 264356278a8eSAlex Deucher } else 264456278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 264556278a8eSAlex Deucher if (rev > 6) 264679daedc9SAlex Deucher rdev->pm.power_state[state_index].pcie_lanes = 264756278a8eSAlex Deucher RBIOS8(offset + 0x5 + 0x10); 2648d7311171SAlex Deucher rdev->pm.power_state[state_index].flags = RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; 264956278a8eSAlex Deucher state_index++; 265056278a8eSAlex Deucher } else { 265156278a8eSAlex Deucher /* XXX figure out some good default low power mode for mobility cards w/out power tables */ 265256278a8eSAlex Deucher } 265356278a8eSAlex Deucher } else { 265456278a8eSAlex Deucher /* XXX figure out some good default low power mode for desktop cards */ 265556278a8eSAlex Deucher } 265656278a8eSAlex Deucher 265756278a8eSAlex Deucher default_mode: 265856278a8eSAlex Deucher /* add the default mode */ 26590ec0e74fSAlex Deucher rdev->pm.power_state[state_index].type = 26600ec0e74fSAlex Deucher POWER_STATE_TYPE_DEFAULT; 266156278a8eSAlex Deucher rdev->pm.power_state[state_index].num_clock_modes = 1; 266256278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk; 266356278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk; 266456278a8eSAlex Deucher rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0]; 266584d88f4cSAlex Deucher if ((state_index > 0) && 26668de016e2SAlex Deucher (rdev->pm.power_state[0].clock_info[0].voltage.type == VOLTAGE_GPIO)) 266784d88f4cSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage = 266884d88f4cSAlex Deucher rdev->pm.power_state[0].clock_info[0].voltage; 266984d88f4cSAlex Deucher else 267056278a8eSAlex Deucher rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; 267179daedc9SAlex Deucher rdev->pm.power_state[state_index].pcie_lanes = 16; 2672a48b9b4eSAlex Deucher rdev->pm.power_state[state_index].flags = 0; 2673a48b9b4eSAlex Deucher rdev->pm.default_power_state_index = state_index; 267456278a8eSAlex Deucher rdev->pm.num_power_states = state_index + 1; 26759038dfdfSRafał Miłecki 2676a48b9b4eSAlex Deucher rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; 2677a48b9b4eSAlex Deucher rdev->pm.current_clock_mode_index = 0; 267856278a8eSAlex Deucher } 267956278a8eSAlex Deucher 2680fcec570bSAlex Deucher void radeon_external_tmds_setup(struct drm_encoder *encoder) 2681fcec570bSAlex Deucher { 2682fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2683fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2684fcec570bSAlex Deucher 2685fcec570bSAlex Deucher if (!tmds) 2686fcec570bSAlex Deucher return; 2687fcec570bSAlex Deucher 2688fcec570bSAlex Deucher switch (tmds->dvo_chip) { 2689fcec570bSAlex Deucher case DVO_SIL164: 2690fcec570bSAlex Deucher /* sil 164 */ 26915a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2692fcec570bSAlex Deucher tmds->slave_addr, 2693fcec570bSAlex Deucher 0x08, 0x30); 26945a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2695fcec570bSAlex Deucher tmds->slave_addr, 2696fcec570bSAlex Deucher 0x09, 0x00); 26975a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2698fcec570bSAlex Deucher tmds->slave_addr, 2699fcec570bSAlex Deucher 0x0a, 0x90); 27005a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2701fcec570bSAlex Deucher tmds->slave_addr, 2702fcec570bSAlex Deucher 0x0c, 0x89); 27035a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2704fcec570bSAlex Deucher tmds->slave_addr, 2705fcec570bSAlex Deucher 0x08, 0x3b); 2706fcec570bSAlex Deucher break; 2707fcec570bSAlex Deucher case DVO_SIL1178: 2708fcec570bSAlex Deucher /* sil 1178 - untested */ 2709fcec570bSAlex Deucher /* 2710fcec570bSAlex Deucher * 0x0f, 0x44 2711fcec570bSAlex Deucher * 0x0f, 0x4c 2712fcec570bSAlex Deucher * 0x0e, 0x01 2713fcec570bSAlex Deucher * 0x0a, 0x80 2714fcec570bSAlex Deucher * 0x09, 0x30 2715fcec570bSAlex Deucher * 0x0c, 0xc9 2716fcec570bSAlex Deucher * 0x0d, 0x70 2717fcec570bSAlex Deucher * 0x08, 0x32 2718fcec570bSAlex Deucher * 0x08, 0x33 2719fcec570bSAlex Deucher */ 2720fcec570bSAlex Deucher break; 2721fcec570bSAlex Deucher default: 2722fcec570bSAlex Deucher break; 2723fcec570bSAlex Deucher } 2724fcec570bSAlex Deucher 2725fcec570bSAlex Deucher } 2726fcec570bSAlex Deucher 2727fcec570bSAlex Deucher bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder) 2728fcec570bSAlex Deucher { 2729fcec570bSAlex Deucher struct drm_device *dev = encoder->dev; 2730fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 2731fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2732fcec570bSAlex Deucher uint16_t offset; 2733fcec570bSAlex Deucher uint8_t blocks, slave_addr, rev; 2734fcec570bSAlex Deucher uint32_t index, id; 2735fcec570bSAlex Deucher uint32_t reg, val, and_mask, or_mask; 2736fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2737fcec570bSAlex Deucher 2738fcec570bSAlex Deucher if (!tmds) 2739fcec570bSAlex Deucher return false; 2740fcec570bSAlex Deucher 2741fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2742fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE); 2743fcec570bSAlex Deucher rev = RBIOS8(offset); 2744fcec570bSAlex Deucher if (offset) { 2745fcec570bSAlex Deucher rev = RBIOS8(offset); 2746fcec570bSAlex Deucher if (rev > 1) { 2747fcec570bSAlex Deucher blocks = RBIOS8(offset + 3); 2748fcec570bSAlex Deucher index = offset + 4; 2749fcec570bSAlex Deucher while (blocks > 0) { 2750fcec570bSAlex Deucher id = RBIOS16(index); 2751fcec570bSAlex Deucher index += 2; 2752fcec570bSAlex Deucher switch (id >> 13) { 2753fcec570bSAlex Deucher case 0: 2754fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2755fcec570bSAlex Deucher val = RBIOS32(index); 2756fcec570bSAlex Deucher index += 4; 2757fcec570bSAlex Deucher WREG32(reg, val); 2758fcec570bSAlex Deucher break; 2759fcec570bSAlex Deucher case 2: 2760fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2761fcec570bSAlex Deucher and_mask = RBIOS32(index); 2762fcec570bSAlex Deucher index += 4; 2763fcec570bSAlex Deucher or_mask = RBIOS32(index); 2764fcec570bSAlex Deucher index += 4; 2765fcec570bSAlex Deucher val = RREG32(reg); 2766fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2767fcec570bSAlex Deucher WREG32(reg, val); 2768fcec570bSAlex Deucher break; 2769fcec570bSAlex Deucher case 3: 2770fcec570bSAlex Deucher val = RBIOS16(index); 2771fcec570bSAlex Deucher index += 2; 2772fcec570bSAlex Deucher udelay(val); 2773fcec570bSAlex Deucher break; 2774fcec570bSAlex Deucher case 4: 2775fcec570bSAlex Deucher val = RBIOS16(index); 2776fcec570bSAlex Deucher index += 2; 2777fcec570bSAlex Deucher udelay(val * 1000); 2778fcec570bSAlex Deucher break; 2779fcec570bSAlex Deucher case 6: 2780fcec570bSAlex Deucher slave_addr = id & 0xff; 2781fcec570bSAlex Deucher slave_addr >>= 1; /* 7 bit addressing */ 2782fcec570bSAlex Deucher index++; 2783fcec570bSAlex Deucher reg = RBIOS8(index); 2784fcec570bSAlex Deucher index++; 2785fcec570bSAlex Deucher val = RBIOS8(index); 2786fcec570bSAlex Deucher index++; 27875a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2788fcec570bSAlex Deucher slave_addr, 2789fcec570bSAlex Deucher reg, val); 2790fcec570bSAlex Deucher break; 2791fcec570bSAlex Deucher default: 2792fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2793fcec570bSAlex Deucher break; 2794fcec570bSAlex Deucher } 2795fcec570bSAlex Deucher blocks--; 2796fcec570bSAlex Deucher } 2797fcec570bSAlex Deucher return true; 2798fcec570bSAlex Deucher } 2799fcec570bSAlex Deucher } 2800fcec570bSAlex Deucher } else { 2801fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2802fcec570bSAlex Deucher if (offset) { 2803fcec570bSAlex Deucher index = offset + 10; 2804fcec570bSAlex Deucher id = RBIOS16(index); 2805fcec570bSAlex Deucher while (id != 0xffff) { 2806fcec570bSAlex Deucher index += 2; 2807fcec570bSAlex Deucher switch (id >> 13) { 2808fcec570bSAlex Deucher case 0: 2809fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2810fcec570bSAlex Deucher val = RBIOS32(index); 2811fcec570bSAlex Deucher WREG32(reg, val); 2812fcec570bSAlex Deucher break; 2813fcec570bSAlex Deucher case 2: 2814fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2815fcec570bSAlex Deucher and_mask = RBIOS32(index); 2816fcec570bSAlex Deucher index += 4; 2817fcec570bSAlex Deucher or_mask = RBIOS32(index); 2818fcec570bSAlex Deucher index += 4; 2819fcec570bSAlex Deucher val = RREG32(reg); 2820fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2821fcec570bSAlex Deucher WREG32(reg, val); 2822fcec570bSAlex Deucher break; 2823fcec570bSAlex Deucher case 4: 2824fcec570bSAlex Deucher val = RBIOS16(index); 2825fcec570bSAlex Deucher index += 2; 2826fcec570bSAlex Deucher udelay(val); 2827fcec570bSAlex Deucher break; 2828fcec570bSAlex Deucher case 5: 2829fcec570bSAlex Deucher reg = id & 0x1fff; 2830fcec570bSAlex Deucher and_mask = RBIOS32(index); 2831fcec570bSAlex Deucher index += 4; 2832fcec570bSAlex Deucher or_mask = RBIOS32(index); 2833fcec570bSAlex Deucher index += 4; 2834fcec570bSAlex Deucher val = RREG32_PLL(reg); 2835fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2836fcec570bSAlex Deucher WREG32_PLL(reg, val); 2837fcec570bSAlex Deucher break; 2838fcec570bSAlex Deucher case 6: 2839fcec570bSAlex Deucher reg = id & 0x1fff; 2840fcec570bSAlex Deucher val = RBIOS8(index); 2841fcec570bSAlex Deucher index += 1; 28425a6f98f5SAlex Deucher radeon_i2c_put_byte(tmds->i2c_bus, 2843fcec570bSAlex Deucher tmds->slave_addr, 2844fcec570bSAlex Deucher reg, val); 2845fcec570bSAlex Deucher break; 2846fcec570bSAlex Deucher default: 2847fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2848fcec570bSAlex Deucher break; 2849fcec570bSAlex Deucher } 2850fcec570bSAlex Deucher id = RBIOS16(index); 2851fcec570bSAlex Deucher } 2852fcec570bSAlex Deucher return true; 2853fcec570bSAlex Deucher } 2854fcec570bSAlex Deucher } 2855fcec570bSAlex Deucher return false; 2856fcec570bSAlex Deucher } 2857fcec570bSAlex Deucher 2858771fe6b9SJerome Glisse static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset) 2859771fe6b9SJerome Glisse { 2860771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2861771fe6b9SJerome Glisse 2862771fe6b9SJerome Glisse if (offset) { 2863771fe6b9SJerome Glisse while (RBIOS16(offset)) { 2864771fe6b9SJerome Glisse uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13); 2865771fe6b9SJerome Glisse uint32_t addr = (RBIOS16(offset) & 0x1fff); 2866771fe6b9SJerome Glisse uint32_t val, and_mask, or_mask; 2867771fe6b9SJerome Glisse uint32_t tmp; 2868771fe6b9SJerome Glisse 2869771fe6b9SJerome Glisse offset += 2; 2870771fe6b9SJerome Glisse switch (cmd) { 2871771fe6b9SJerome Glisse case 0: 2872771fe6b9SJerome Glisse val = RBIOS32(offset); 2873771fe6b9SJerome Glisse offset += 4; 2874771fe6b9SJerome Glisse WREG32(addr, val); 2875771fe6b9SJerome Glisse break; 2876771fe6b9SJerome Glisse case 1: 2877771fe6b9SJerome Glisse val = RBIOS32(offset); 2878771fe6b9SJerome Glisse offset += 4; 2879771fe6b9SJerome Glisse WREG32(addr, val); 2880771fe6b9SJerome Glisse break; 2881771fe6b9SJerome Glisse case 2: 2882771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2883771fe6b9SJerome Glisse offset += 4; 2884771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2885771fe6b9SJerome Glisse offset += 4; 2886771fe6b9SJerome Glisse tmp = RREG32(addr); 2887771fe6b9SJerome Glisse tmp &= and_mask; 2888771fe6b9SJerome Glisse tmp |= or_mask; 2889771fe6b9SJerome Glisse WREG32(addr, tmp); 2890771fe6b9SJerome Glisse break; 2891771fe6b9SJerome Glisse case 3: 2892771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2893771fe6b9SJerome Glisse offset += 4; 2894771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2895771fe6b9SJerome Glisse offset += 4; 2896771fe6b9SJerome Glisse tmp = RREG32(addr); 2897771fe6b9SJerome Glisse tmp &= and_mask; 2898771fe6b9SJerome Glisse tmp |= or_mask; 2899771fe6b9SJerome Glisse WREG32(addr, tmp); 2900771fe6b9SJerome Glisse break; 2901771fe6b9SJerome Glisse case 4: 2902771fe6b9SJerome Glisse val = RBIOS16(offset); 2903771fe6b9SJerome Glisse offset += 2; 2904771fe6b9SJerome Glisse udelay(val); 2905771fe6b9SJerome Glisse break; 2906771fe6b9SJerome Glisse case 5: 2907771fe6b9SJerome Glisse val = RBIOS16(offset); 2908771fe6b9SJerome Glisse offset += 2; 2909771fe6b9SJerome Glisse switch (addr) { 2910771fe6b9SJerome Glisse case 8: 2911771fe6b9SJerome Glisse while (val--) { 2912771fe6b9SJerome Glisse if (! 2913771fe6b9SJerome Glisse (RREG32_PLL 2914771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2915771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2916771fe6b9SJerome Glisse break; 2917771fe6b9SJerome Glisse } 2918771fe6b9SJerome Glisse break; 2919771fe6b9SJerome Glisse case 9: 2920771fe6b9SJerome Glisse while (val--) { 2921771fe6b9SJerome Glisse if ((RREG32(RADEON_MC_STATUS) & 2922771fe6b9SJerome Glisse RADEON_MC_IDLE)) 2923771fe6b9SJerome Glisse break; 2924771fe6b9SJerome Glisse } 2925771fe6b9SJerome Glisse break; 2926771fe6b9SJerome Glisse default: 2927771fe6b9SJerome Glisse break; 2928771fe6b9SJerome Glisse } 2929771fe6b9SJerome Glisse break; 2930771fe6b9SJerome Glisse default: 2931771fe6b9SJerome Glisse break; 2932771fe6b9SJerome Glisse } 2933771fe6b9SJerome Glisse } 2934771fe6b9SJerome Glisse } 2935771fe6b9SJerome Glisse } 2936771fe6b9SJerome Glisse 2937771fe6b9SJerome Glisse static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset) 2938771fe6b9SJerome Glisse { 2939771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2940771fe6b9SJerome Glisse 2941771fe6b9SJerome Glisse if (offset) { 2942771fe6b9SJerome Glisse while (RBIOS8(offset)) { 2943771fe6b9SJerome Glisse uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6); 2944771fe6b9SJerome Glisse uint8_t addr = (RBIOS8(offset) & 0x3f); 2945771fe6b9SJerome Glisse uint32_t val, shift, tmp; 2946771fe6b9SJerome Glisse uint32_t and_mask, or_mask; 2947771fe6b9SJerome Glisse 2948771fe6b9SJerome Glisse offset++; 2949771fe6b9SJerome Glisse switch (cmd) { 2950771fe6b9SJerome Glisse case 0: 2951771fe6b9SJerome Glisse val = RBIOS32(offset); 2952771fe6b9SJerome Glisse offset += 4; 2953771fe6b9SJerome Glisse WREG32_PLL(addr, val); 2954771fe6b9SJerome Glisse break; 2955771fe6b9SJerome Glisse case 1: 2956771fe6b9SJerome Glisse shift = RBIOS8(offset) * 8; 2957771fe6b9SJerome Glisse offset++; 2958771fe6b9SJerome Glisse and_mask = RBIOS8(offset) << shift; 2959771fe6b9SJerome Glisse and_mask |= ~(0xff << shift); 2960771fe6b9SJerome Glisse offset++; 2961771fe6b9SJerome Glisse or_mask = RBIOS8(offset) << shift; 2962771fe6b9SJerome Glisse offset++; 2963771fe6b9SJerome Glisse tmp = RREG32_PLL(addr); 2964771fe6b9SJerome Glisse tmp &= and_mask; 2965771fe6b9SJerome Glisse tmp |= or_mask; 2966771fe6b9SJerome Glisse WREG32_PLL(addr, tmp); 2967771fe6b9SJerome Glisse break; 2968771fe6b9SJerome Glisse case 2: 2969771fe6b9SJerome Glisse case 3: 2970771fe6b9SJerome Glisse tmp = 1000; 2971771fe6b9SJerome Glisse switch (addr) { 2972771fe6b9SJerome Glisse case 1: 2973771fe6b9SJerome Glisse udelay(150); 2974771fe6b9SJerome Glisse break; 2975771fe6b9SJerome Glisse case 2: 2976771fe6b9SJerome Glisse udelay(1000); 2977771fe6b9SJerome Glisse break; 2978771fe6b9SJerome Glisse case 3: 2979771fe6b9SJerome Glisse while (tmp--) { 2980771fe6b9SJerome Glisse if (! 2981771fe6b9SJerome Glisse (RREG32_PLL 2982771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2983771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2984771fe6b9SJerome Glisse break; 2985771fe6b9SJerome Glisse } 2986771fe6b9SJerome Glisse break; 2987771fe6b9SJerome Glisse case 4: 2988771fe6b9SJerome Glisse while (tmp--) { 2989771fe6b9SJerome Glisse if (RREG32_PLL 2990771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2991771fe6b9SJerome Glisse RADEON_DLL_READY) 2992771fe6b9SJerome Glisse break; 2993771fe6b9SJerome Glisse } 2994771fe6b9SJerome Glisse break; 2995771fe6b9SJerome Glisse case 5: 2996771fe6b9SJerome Glisse tmp = 2997771fe6b9SJerome Glisse RREG32_PLL(RADEON_CLK_PWRMGT_CNTL); 2998771fe6b9SJerome Glisse if (tmp & RADEON_CG_NO1_DEBUG_0) { 2999771fe6b9SJerome Glisse #if 0 3000771fe6b9SJerome Glisse uint32_t mclk_cntl = 3001771fe6b9SJerome Glisse RREG32_PLL 3002771fe6b9SJerome Glisse (RADEON_MCLK_CNTL); 3003771fe6b9SJerome Glisse mclk_cntl &= 0xffff0000; 3004771fe6b9SJerome Glisse /*mclk_cntl |= 0x00001111;*//* ??? */ 3005771fe6b9SJerome Glisse WREG32_PLL(RADEON_MCLK_CNTL, 3006771fe6b9SJerome Glisse mclk_cntl); 3007771fe6b9SJerome Glisse udelay(10000); 3008771fe6b9SJerome Glisse #endif 3009771fe6b9SJerome Glisse WREG32_PLL 3010771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL, 3011771fe6b9SJerome Glisse tmp & 3012771fe6b9SJerome Glisse ~RADEON_CG_NO1_DEBUG_0); 3013771fe6b9SJerome Glisse udelay(10000); 3014771fe6b9SJerome Glisse } 3015771fe6b9SJerome Glisse break; 3016771fe6b9SJerome Glisse default: 3017771fe6b9SJerome Glisse break; 3018771fe6b9SJerome Glisse } 3019771fe6b9SJerome Glisse break; 3020771fe6b9SJerome Glisse default: 3021771fe6b9SJerome Glisse break; 3022771fe6b9SJerome Glisse } 3023771fe6b9SJerome Glisse } 3024771fe6b9SJerome Glisse } 3025771fe6b9SJerome Glisse } 3026771fe6b9SJerome Glisse 3027771fe6b9SJerome Glisse static void combios_parse_ram_reset_table(struct drm_device *dev, 3028771fe6b9SJerome Glisse uint16_t offset) 3029771fe6b9SJerome Glisse { 3030771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3031771fe6b9SJerome Glisse uint32_t tmp; 3032771fe6b9SJerome Glisse 3033771fe6b9SJerome Glisse if (offset) { 3034771fe6b9SJerome Glisse uint8_t val = RBIOS8(offset); 3035771fe6b9SJerome Glisse while (val != 0xff) { 3036771fe6b9SJerome Glisse offset++; 3037771fe6b9SJerome Glisse 3038771fe6b9SJerome Glisse if (val == 0x0f) { 3039771fe6b9SJerome Glisse uint32_t channel_complete_mask; 3040771fe6b9SJerome Glisse 3041771fe6b9SJerome Glisse if (ASIC_IS_R300(rdev)) 3042771fe6b9SJerome Glisse channel_complete_mask = 3043771fe6b9SJerome Glisse R300_MEM_PWRUP_COMPLETE; 3044771fe6b9SJerome Glisse else 3045771fe6b9SJerome Glisse channel_complete_mask = 3046771fe6b9SJerome Glisse RADEON_MEM_PWRUP_COMPLETE; 3047771fe6b9SJerome Glisse tmp = 20000; 3048771fe6b9SJerome Glisse while (tmp--) { 3049771fe6b9SJerome Glisse if ((RREG32(RADEON_MEM_STR_CNTL) & 3050771fe6b9SJerome Glisse channel_complete_mask) == 3051771fe6b9SJerome Glisse channel_complete_mask) 3052771fe6b9SJerome Glisse break; 3053771fe6b9SJerome Glisse } 3054771fe6b9SJerome Glisse } else { 3055771fe6b9SJerome Glisse uint32_t or_mask = RBIOS16(offset); 3056771fe6b9SJerome Glisse offset += 2; 3057771fe6b9SJerome Glisse 3058771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 3059771fe6b9SJerome Glisse tmp &= RADEON_SDRAM_MODE_MASK; 3060771fe6b9SJerome Glisse tmp |= or_mask; 3061771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 3062771fe6b9SJerome Glisse 3063771fe6b9SJerome Glisse or_mask = val << 24; 3064771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 3065771fe6b9SJerome Glisse tmp &= RADEON_B3MEM_RESET_MASK; 3066771fe6b9SJerome Glisse tmp |= or_mask; 3067771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 3068771fe6b9SJerome Glisse } 3069771fe6b9SJerome Glisse val = RBIOS8(offset); 3070771fe6b9SJerome Glisse } 3071771fe6b9SJerome Glisse } 3072771fe6b9SJerome Glisse } 3073771fe6b9SJerome Glisse 3074771fe6b9SJerome Glisse static uint32_t combios_detect_ram(struct drm_device *dev, int ram, 3075771fe6b9SJerome Glisse int mem_addr_mapping) 3076771fe6b9SJerome Glisse { 3077771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3078771fe6b9SJerome Glisse uint32_t mem_cntl; 3079771fe6b9SJerome Glisse uint32_t mem_size; 3080771fe6b9SJerome Glisse uint32_t addr = 0; 3081771fe6b9SJerome Glisse 3082771fe6b9SJerome Glisse mem_cntl = RREG32(RADEON_MEM_CNTL); 3083771fe6b9SJerome Glisse if (mem_cntl & RV100_HALF_MODE) 3084771fe6b9SJerome Glisse ram /= 2; 3085771fe6b9SJerome Glisse mem_size = ram; 3086771fe6b9SJerome Glisse mem_cntl &= ~(0xff << 8); 3087771fe6b9SJerome Glisse mem_cntl |= (mem_addr_mapping & 0xff) << 8; 3088771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 3089771fe6b9SJerome Glisse RREG32(RADEON_MEM_CNTL); 3090771fe6b9SJerome Glisse 3091771fe6b9SJerome Glisse /* sdram reset ? */ 3092771fe6b9SJerome Glisse 3093771fe6b9SJerome Glisse /* something like this???? */ 3094771fe6b9SJerome Glisse while (ram--) { 3095771fe6b9SJerome Glisse addr = ram * 1024 * 1024; 3096771fe6b9SJerome Glisse /* write to each page */ 3097771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 3098771fe6b9SJerome Glisse WREG32(RADEON_MM_DATA, 0xdeadbeef); 3099771fe6b9SJerome Glisse /* read back and verify */ 3100771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 3101771fe6b9SJerome Glisse if (RREG32(RADEON_MM_DATA) != 0xdeadbeef) 3102771fe6b9SJerome Glisse return 0; 3103771fe6b9SJerome Glisse } 3104771fe6b9SJerome Glisse 3105771fe6b9SJerome Glisse return mem_size; 3106771fe6b9SJerome Glisse } 3107771fe6b9SJerome Glisse 3108771fe6b9SJerome Glisse static void combios_write_ram_size(struct drm_device *dev) 3109771fe6b9SJerome Glisse { 3110771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3111771fe6b9SJerome Glisse uint8_t rev; 3112771fe6b9SJerome Glisse uint16_t offset; 3113771fe6b9SJerome Glisse uint32_t mem_size = 0; 3114771fe6b9SJerome Glisse uint32_t mem_cntl = 0; 3115771fe6b9SJerome Glisse 3116771fe6b9SJerome Glisse /* should do something smarter here I guess... */ 3117771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_IGP) 3118771fe6b9SJerome Glisse return; 3119771fe6b9SJerome Glisse 3120771fe6b9SJerome Glisse /* first check detected mem table */ 3121771fe6b9SJerome Glisse offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE); 3122771fe6b9SJerome Glisse if (offset) { 3123771fe6b9SJerome Glisse rev = RBIOS8(offset); 3124771fe6b9SJerome Glisse if (rev < 3) { 3125771fe6b9SJerome Glisse mem_cntl = RBIOS32(offset + 1); 3126771fe6b9SJerome Glisse mem_size = RBIOS16(offset + 5); 31274ce9198eSAlex Deucher if ((rdev->family < CHIP_R200) && 31284ce9198eSAlex Deucher !ASIC_IS_RN50(rdev)) 3129771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 3130771fe6b9SJerome Glisse } 3131771fe6b9SJerome Glisse } 3132771fe6b9SJerome Glisse 3133771fe6b9SJerome Glisse if (!mem_size) { 3134771fe6b9SJerome Glisse offset = 3135771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 3136771fe6b9SJerome Glisse if (offset) { 3137771fe6b9SJerome Glisse rev = RBIOS8(offset - 1); 3138771fe6b9SJerome Glisse if (rev < 1) { 31394ce9198eSAlex Deucher if ((rdev->family < CHIP_R200) 31404ce9198eSAlex Deucher && !ASIC_IS_RN50(rdev)) { 3141771fe6b9SJerome Glisse int ram = 0; 3142771fe6b9SJerome Glisse int mem_addr_mapping = 0; 3143771fe6b9SJerome Glisse 3144771fe6b9SJerome Glisse while (RBIOS8(offset)) { 3145771fe6b9SJerome Glisse ram = RBIOS8(offset); 3146771fe6b9SJerome Glisse mem_addr_mapping = 3147771fe6b9SJerome Glisse RBIOS8(offset + 1); 3148771fe6b9SJerome Glisse if (mem_addr_mapping != 0x25) 3149771fe6b9SJerome Glisse ram *= 2; 3150771fe6b9SJerome Glisse mem_size = 3151771fe6b9SJerome Glisse combios_detect_ram(dev, ram, 3152771fe6b9SJerome Glisse mem_addr_mapping); 3153771fe6b9SJerome Glisse if (mem_size) 3154771fe6b9SJerome Glisse break; 3155771fe6b9SJerome Glisse offset += 2; 3156771fe6b9SJerome Glisse } 3157771fe6b9SJerome Glisse } else 3158771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 3159771fe6b9SJerome Glisse } else { 3160771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 3161771fe6b9SJerome Glisse mem_size *= 2; /* convert to MB */ 3162771fe6b9SJerome Glisse } 3163771fe6b9SJerome Glisse } 3164771fe6b9SJerome Glisse } 3165771fe6b9SJerome Glisse 3166771fe6b9SJerome Glisse mem_size *= (1024 * 1024); /* convert to bytes */ 3167771fe6b9SJerome Glisse WREG32(RADEON_CONFIG_MEMSIZE, mem_size); 3168771fe6b9SJerome Glisse } 3169771fe6b9SJerome Glisse 3170771fe6b9SJerome Glisse void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable) 3171771fe6b9SJerome Glisse { 3172771fe6b9SJerome Glisse uint16_t dyn_clk_info = 3173771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 3174771fe6b9SJerome Glisse 3175771fe6b9SJerome Glisse if (dyn_clk_info) 3176771fe6b9SJerome Glisse combios_parse_pll_table(dev, dyn_clk_info); 3177771fe6b9SJerome Glisse } 3178771fe6b9SJerome Glisse 3179771fe6b9SJerome Glisse void radeon_combios_asic_init(struct drm_device *dev) 3180771fe6b9SJerome Glisse { 3181771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3182771fe6b9SJerome Glisse uint16_t table; 3183771fe6b9SJerome Glisse 3184771fe6b9SJerome Glisse /* port hardcoded mac stuff from radeonfb */ 3185771fe6b9SJerome Glisse if (rdev->bios == NULL) 3186771fe6b9SJerome Glisse return; 3187771fe6b9SJerome Glisse 3188771fe6b9SJerome Glisse /* ASIC INIT 1 */ 3189771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE); 3190771fe6b9SJerome Glisse if (table) 3191771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3192771fe6b9SJerome Glisse 3193771fe6b9SJerome Glisse /* PLL INIT */ 3194771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE); 3195771fe6b9SJerome Glisse if (table) 3196771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 3197771fe6b9SJerome Glisse 3198771fe6b9SJerome Glisse /* ASIC INIT 2 */ 3199771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE); 3200771fe6b9SJerome Glisse if (table) 3201771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3202771fe6b9SJerome Glisse 3203771fe6b9SJerome Glisse if (!(rdev->flags & RADEON_IS_IGP)) { 3204771fe6b9SJerome Glisse /* ASIC INIT 4 */ 3205771fe6b9SJerome Glisse table = 3206771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE); 3207771fe6b9SJerome Glisse if (table) 3208771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3209771fe6b9SJerome Glisse 3210771fe6b9SJerome Glisse /* RAM RESET */ 3211771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE); 3212771fe6b9SJerome Glisse if (table) 3213771fe6b9SJerome Glisse combios_parse_ram_reset_table(dev, table); 3214771fe6b9SJerome Glisse 3215771fe6b9SJerome Glisse /* ASIC INIT 3 */ 3216771fe6b9SJerome Glisse table = 3217771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE); 3218771fe6b9SJerome Glisse if (table) 3219771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 3220771fe6b9SJerome Glisse 3221771fe6b9SJerome Glisse /* write CONFIG_MEMSIZE */ 3222771fe6b9SJerome Glisse combios_write_ram_size(dev); 3223771fe6b9SJerome Glisse } 3224771fe6b9SJerome Glisse 3225580b4fffSDave Airlie /* quirk for rs4xx HP nx6125 laptop to make it resume 3226580b4fffSDave Airlie * - it hangs on resume inside the dynclk 1 table. 3227580b4fffSDave Airlie */ 3228580b4fffSDave Airlie if (rdev->family == CHIP_RS480 && 3229580b4fffSDave Airlie rdev->pdev->subsystem_vendor == 0x103c && 3230580b4fffSDave Airlie rdev->pdev->subsystem_device == 0x308b) 3231580b4fffSDave Airlie return; 3232580b4fffSDave Airlie 323352fa2bbcSAlex Deucher /* quirk for rs4xx HP dv5000 laptop to make it resume 323452fa2bbcSAlex Deucher * - it hangs on resume inside the dynclk 1 table. 323552fa2bbcSAlex Deucher */ 323652fa2bbcSAlex Deucher if (rdev->family == CHIP_RS480 && 323752fa2bbcSAlex Deucher rdev->pdev->subsystem_vendor == 0x103c && 323852fa2bbcSAlex Deucher rdev->pdev->subsystem_device == 0x30a4) 323952fa2bbcSAlex Deucher return; 324052fa2bbcSAlex Deucher 3241771fe6b9SJerome Glisse /* DYN CLK 1 */ 3242771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 3243771fe6b9SJerome Glisse if (table) 3244771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 3245771fe6b9SJerome Glisse 3246771fe6b9SJerome Glisse } 3247771fe6b9SJerome Glisse 3248771fe6b9SJerome Glisse void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev) 3249771fe6b9SJerome Glisse { 3250771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3251771fe6b9SJerome Glisse uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch; 3252771fe6b9SJerome Glisse 3253771fe6b9SJerome Glisse bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); 3254771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3255771fe6b9SJerome Glisse bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH); 3256771fe6b9SJerome Glisse 3257771fe6b9SJerome Glisse /* let the bios control the backlight */ 3258771fe6b9SJerome Glisse bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN; 3259771fe6b9SJerome Glisse 3260771fe6b9SJerome Glisse /* tell the bios not to handle mode switching */ 3261771fe6b9SJerome Glisse bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS | 3262771fe6b9SJerome Glisse RADEON_ACC_MODE_CHANGE); 3263771fe6b9SJerome Glisse 3264771fe6b9SJerome Glisse /* tell the bios a driver is loaded */ 3265771fe6b9SJerome Glisse bios_7_scratch |= RADEON_DRV_LOADED; 3266771fe6b9SJerome Glisse 3267771fe6b9SJerome Glisse WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch); 3268771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3269771fe6b9SJerome Glisse WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch); 3270771fe6b9SJerome Glisse } 3271771fe6b9SJerome Glisse 3272771fe6b9SJerome Glisse void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock) 3273771fe6b9SJerome Glisse { 3274771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3275771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3276771fe6b9SJerome Glisse uint32_t bios_6_scratch; 3277771fe6b9SJerome Glisse 3278771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3279771fe6b9SJerome Glisse 3280771fe6b9SJerome Glisse if (lock) 3281771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DRIVER_CRITICAL; 3282771fe6b9SJerome Glisse else 3283771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DRIVER_CRITICAL; 3284771fe6b9SJerome Glisse 3285771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3286771fe6b9SJerome Glisse } 3287771fe6b9SJerome Glisse 3288771fe6b9SJerome Glisse void 3289771fe6b9SJerome Glisse radeon_combios_connected_scratch_regs(struct drm_connector *connector, 3290771fe6b9SJerome Glisse struct drm_encoder *encoder, 3291771fe6b9SJerome Glisse bool connected) 3292771fe6b9SJerome Glisse { 3293771fe6b9SJerome Glisse struct drm_device *dev = connector->dev; 3294771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3295771fe6b9SJerome Glisse struct radeon_connector *radeon_connector = 3296771fe6b9SJerome Glisse to_radeon_connector(connector); 3297771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3298771fe6b9SJerome Glisse uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH); 3299771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3300771fe6b9SJerome Glisse 3301771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) && 3302771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) { 3303771fe6b9SJerome Glisse if (connected) { 3304d9fdaafbSDave Airlie DRM_DEBUG_KMS("TV1 connected\n"); 3305771fe6b9SJerome Glisse /* fix me */ 3306771fe6b9SJerome Glisse bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO; 3307771fe6b9SJerome Glisse /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */ 3308771fe6b9SJerome Glisse bios_5_scratch |= RADEON_TV1_ON; 3309771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_TV1; 3310771fe6b9SJerome Glisse } else { 3311d9fdaafbSDave Airlie DRM_DEBUG_KMS("TV1 disconnected\n"); 3312771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK; 3313771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_ON; 3314771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_TV1; 3315771fe6b9SJerome Glisse } 3316771fe6b9SJerome Glisse } 3317771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) && 3318771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) { 3319771fe6b9SJerome Glisse if (connected) { 3320d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD1 connected\n"); 3321771fe6b9SJerome Glisse bios_4_scratch |= RADEON_LCD1_ATTACHED; 3322771fe6b9SJerome Glisse bios_5_scratch |= RADEON_LCD1_ON; 3323771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_LCD1; 3324771fe6b9SJerome Glisse } else { 3325d9fdaafbSDave Airlie DRM_DEBUG_KMS("LCD1 disconnected\n"); 3326771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_LCD1_ATTACHED; 3327771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_ON; 3328771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_LCD1; 3329771fe6b9SJerome Glisse } 3330771fe6b9SJerome Glisse } 3331771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) && 3332771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) { 3333771fe6b9SJerome Glisse if (connected) { 3334d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT1 connected\n"); 3335771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR; 3336771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT1_ON; 3337771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT1; 3338771fe6b9SJerome Glisse } else { 3339d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT1 disconnected\n"); 3340771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK; 3341771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_ON; 3342771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT1; 3343771fe6b9SJerome Glisse } 3344771fe6b9SJerome Glisse } 3345771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) && 3346771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) { 3347771fe6b9SJerome Glisse if (connected) { 3348d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT2 connected\n"); 3349771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR; 3350771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT2_ON; 3351771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT2; 3352771fe6b9SJerome Glisse } else { 3353d9fdaafbSDave Airlie DRM_DEBUG_KMS("CRT2 disconnected\n"); 3354771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK; 3355771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_ON; 3356771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT2; 3357771fe6b9SJerome Glisse } 3358771fe6b9SJerome Glisse } 3359771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) && 3360771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) { 3361771fe6b9SJerome Glisse if (connected) { 3362d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP1 connected\n"); 3363771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP1_ATTACHED; 3364771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP1_ON; 3365771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP1; 3366771fe6b9SJerome Glisse } else { 3367d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP1 disconnected\n"); 3368771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP1_ATTACHED; 3369771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_ON; 3370771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP1; 3371771fe6b9SJerome Glisse } 3372771fe6b9SJerome Glisse } 3373771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) && 3374771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) { 3375771fe6b9SJerome Glisse if (connected) { 3376d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP2 connected\n"); 3377771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP2_ATTACHED; 3378771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP2_ON; 3379771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP2; 3380771fe6b9SJerome Glisse } else { 3381d9fdaafbSDave Airlie DRM_DEBUG_KMS("DFP2 disconnected\n"); 3382771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP2_ATTACHED; 3383771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_ON; 3384771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP2; 3385771fe6b9SJerome Glisse } 3386771fe6b9SJerome Glisse } 3387771fe6b9SJerome Glisse WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch); 3388771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3389771fe6b9SJerome Glisse } 3390771fe6b9SJerome Glisse 3391771fe6b9SJerome Glisse void 3392771fe6b9SJerome Glisse radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc) 3393771fe6b9SJerome Glisse { 3394771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3395771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3396771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3397771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 3398771fe6b9SJerome Glisse 3399771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { 3400771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_CRTC_MASK; 3401771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT); 3402771fe6b9SJerome Glisse } 3403771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { 3404771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK; 3405771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT); 3406771fe6b9SJerome Glisse } 3407771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { 3408771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK; 3409771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT); 3410771fe6b9SJerome Glisse } 3411771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { 3412771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK; 3413771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT); 3414771fe6b9SJerome Glisse } 3415771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { 3416771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK; 3417771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT); 3418771fe6b9SJerome Glisse } 3419771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { 3420771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK; 3421771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT); 3422771fe6b9SJerome Glisse } 3423771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 3424771fe6b9SJerome Glisse } 3425771fe6b9SJerome Glisse 3426771fe6b9SJerome Glisse void 3427771fe6b9SJerome Glisse radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on) 3428771fe6b9SJerome Glisse { 3429771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 3430771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 3431771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3432771fe6b9SJerome Glisse uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 3433771fe6b9SJerome Glisse 3434771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { 3435771fe6b9SJerome Glisse if (on) 3436771fe6b9SJerome Glisse bios_6_scratch |= RADEON_TV_DPMS_ON; 3437771fe6b9SJerome Glisse else 3438771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_TV_DPMS_ON; 3439771fe6b9SJerome Glisse } 3440771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) { 3441771fe6b9SJerome Glisse if (on) 3442771fe6b9SJerome Glisse bios_6_scratch |= RADEON_CRT_DPMS_ON; 3443771fe6b9SJerome Glisse else 3444771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_CRT_DPMS_ON; 3445771fe6b9SJerome Glisse } 3446771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 3447771fe6b9SJerome Glisse if (on) 3448771fe6b9SJerome Glisse bios_6_scratch |= RADEON_LCD_DPMS_ON; 3449771fe6b9SJerome Glisse else 3450771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_LCD_DPMS_ON; 3451771fe6b9SJerome Glisse } 3452771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 3453771fe6b9SJerome Glisse if (on) 3454771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DFP_DPMS_ON; 3455771fe6b9SJerome Glisse else 3456771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DFP_DPMS_ON; 3457771fe6b9SJerome Glisse } 3458771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 3459771fe6b9SJerome Glisse } 3460