1771fe6b9SJerome Glisse /* 2771fe6b9SJerome Glisse * Copyright 2004 ATI Technologies Inc., Markham, Ontario 3771fe6b9SJerome Glisse * Copyright 2007-8 Advanced Micro Devices, Inc. 4771fe6b9SJerome Glisse * Copyright 2008 Red Hat Inc. 5771fe6b9SJerome Glisse * 6771fe6b9SJerome Glisse * Permission is hereby granted, free of charge, to any person obtaining a 7771fe6b9SJerome Glisse * copy of this software and associated documentation files (the "Software"), 8771fe6b9SJerome Glisse * to deal in the Software without restriction, including without limitation 9771fe6b9SJerome Glisse * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10771fe6b9SJerome Glisse * and/or sell copies of the Software, and to permit persons to whom the 11771fe6b9SJerome Glisse * Software is furnished to do so, subject to the following conditions: 12771fe6b9SJerome Glisse * 13771fe6b9SJerome Glisse * The above copyright notice and this permission notice shall be included in 14771fe6b9SJerome Glisse * all copies or substantial portions of the Software. 15771fe6b9SJerome Glisse * 16771fe6b9SJerome Glisse * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17771fe6b9SJerome Glisse * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18771fe6b9SJerome Glisse * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19771fe6b9SJerome Glisse * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20771fe6b9SJerome Glisse * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21771fe6b9SJerome Glisse * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22771fe6b9SJerome Glisse * OTHER DEALINGS IN THE SOFTWARE. 23771fe6b9SJerome Glisse * 24771fe6b9SJerome Glisse * Authors: Dave Airlie 25771fe6b9SJerome Glisse * Alex Deucher 26771fe6b9SJerome Glisse */ 27771fe6b9SJerome Glisse #include "drmP.h" 28771fe6b9SJerome Glisse #include "radeon_drm.h" 29771fe6b9SJerome Glisse #include "radeon.h" 30771fe6b9SJerome Glisse #include "atom.h" 31771fe6b9SJerome Glisse 32771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 33771fe6b9SJerome Glisse /* not sure which of these are needed */ 34771fe6b9SJerome Glisse #include <asm/machdep.h> 35771fe6b9SJerome Glisse #include <asm/pmac_feature.h> 36771fe6b9SJerome Glisse #include <asm/prom.h> 37771fe6b9SJerome Glisse #include <asm/pci-bridge.h> 38771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 39771fe6b9SJerome Glisse 40771fe6b9SJerome Glisse /* from radeon_encoder.c */ 41771fe6b9SJerome Glisse extern uint32_t 42771fe6b9SJerome Glisse radeon_get_encoder_id(struct drm_device *dev, uint32_t supported_device, 43771fe6b9SJerome Glisse uint8_t dac); 44771fe6b9SJerome Glisse extern void radeon_link_encoder_connector(struct drm_device *dev); 45771fe6b9SJerome Glisse 46771fe6b9SJerome Glisse /* from radeon_connector.c */ 47771fe6b9SJerome Glisse extern void 48771fe6b9SJerome Glisse radeon_add_legacy_connector(struct drm_device *dev, 49771fe6b9SJerome Glisse uint32_t connector_id, 50771fe6b9SJerome Glisse uint32_t supported_device, 51771fe6b9SJerome Glisse int connector_type, 52b75fad06SAlex Deucher struct radeon_i2c_bus_rec *i2c_bus, 53b75fad06SAlex Deucher uint16_t connector_object_id); 54771fe6b9SJerome Glisse 55771fe6b9SJerome Glisse /* from radeon_legacy_encoder.c */ 56771fe6b9SJerome Glisse extern void 57771fe6b9SJerome Glisse radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_id, 58771fe6b9SJerome Glisse uint32_t supported_device); 59771fe6b9SJerome Glisse 60771fe6b9SJerome Glisse /* old legacy ATI BIOS routines */ 61771fe6b9SJerome Glisse 62771fe6b9SJerome Glisse /* COMBIOS table offsets */ 63771fe6b9SJerome Glisse enum radeon_combios_table_offset { 64771fe6b9SJerome Glisse /* absolute offset tables */ 65771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_1_TABLE, 66771fe6b9SJerome Glisse COMBIOS_BIOS_SUPPORT_TABLE, 67771fe6b9SJerome Glisse COMBIOS_DAC_PROGRAMMING_TABLE, 68771fe6b9SJerome Glisse COMBIOS_MAX_COLOR_DEPTH_TABLE, 69771fe6b9SJerome Glisse COMBIOS_CRTC_INFO_TABLE, 70771fe6b9SJerome Glisse COMBIOS_PLL_INFO_TABLE, 71771fe6b9SJerome Glisse COMBIOS_TV_INFO_TABLE, 72771fe6b9SJerome Glisse COMBIOS_DFP_INFO_TABLE, 73771fe6b9SJerome Glisse COMBIOS_HW_CONFIG_INFO_TABLE, 74771fe6b9SJerome Glisse COMBIOS_MULTIMEDIA_INFO_TABLE, 75771fe6b9SJerome Glisse COMBIOS_TV_STD_PATCH_TABLE, 76771fe6b9SJerome Glisse COMBIOS_LCD_INFO_TABLE, 77771fe6b9SJerome Glisse COMBIOS_MOBILE_INFO_TABLE, 78771fe6b9SJerome Glisse COMBIOS_PLL_INIT_TABLE, 79771fe6b9SJerome Glisse COMBIOS_MEM_CONFIG_TABLE, 80771fe6b9SJerome Glisse COMBIOS_SAVE_MASK_TABLE, 81771fe6b9SJerome Glisse COMBIOS_HARDCODED_EDID_TABLE, 82771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_2_TABLE, 83771fe6b9SJerome Glisse COMBIOS_CONNECTOR_INFO_TABLE, 84771fe6b9SJerome Glisse COMBIOS_DYN_CLK_1_TABLE, 85771fe6b9SJerome Glisse COMBIOS_RESERVED_MEM_TABLE, 86771fe6b9SJerome Glisse COMBIOS_EXT_TMDS_INFO_TABLE, 87771fe6b9SJerome Glisse COMBIOS_MEM_CLK_INFO_TABLE, 88771fe6b9SJerome Glisse COMBIOS_EXT_DAC_INFO_TABLE, 89771fe6b9SJerome Glisse COMBIOS_MISC_INFO_TABLE, 90771fe6b9SJerome Glisse COMBIOS_CRT_INFO_TABLE, 91771fe6b9SJerome Glisse COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE, 92771fe6b9SJerome Glisse COMBIOS_COMPONENT_VIDEO_INFO_TABLE, 93771fe6b9SJerome Glisse COMBIOS_FAN_SPEED_INFO_TABLE, 94771fe6b9SJerome Glisse COMBIOS_OVERDRIVE_INFO_TABLE, 95771fe6b9SJerome Glisse COMBIOS_OEM_INFO_TABLE, 96771fe6b9SJerome Glisse COMBIOS_DYN_CLK_2_TABLE, 97771fe6b9SJerome Glisse COMBIOS_POWER_CONNECTOR_INFO_TABLE, 98771fe6b9SJerome Glisse COMBIOS_I2C_INFO_TABLE, 99771fe6b9SJerome Glisse /* relative offset tables */ 100771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_3_TABLE, /* offset from misc info */ 101771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_4_TABLE, /* offset from misc info */ 102771fe6b9SJerome Glisse COMBIOS_DETECTED_MEM_TABLE, /* offset from misc info */ 103771fe6b9SJerome Glisse COMBIOS_ASIC_INIT_5_TABLE, /* offset from misc info */ 104771fe6b9SJerome Glisse COMBIOS_RAM_RESET_TABLE, /* offset from mem config */ 105771fe6b9SJerome Glisse COMBIOS_POWERPLAY_INFO_TABLE, /* offset from mobile info */ 106771fe6b9SJerome Glisse COMBIOS_GPIO_INFO_TABLE, /* offset from mobile info */ 107771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE, /* offset from mobile info */ 108771fe6b9SJerome Glisse COMBIOS_TMDS_POWER_TABLE, /* offset from mobile info */ 109771fe6b9SJerome Glisse COMBIOS_TMDS_POWER_ON_TABLE, /* offset from tmds power */ 110771fe6b9SJerome Glisse COMBIOS_TMDS_POWER_OFF_TABLE, /* offset from tmds power */ 111771fe6b9SJerome Glisse }; 112771fe6b9SJerome Glisse 113771fe6b9SJerome Glisse enum radeon_combios_ddc { 114771fe6b9SJerome Glisse DDC_NONE_DETECTED, 115771fe6b9SJerome Glisse DDC_MONID, 116771fe6b9SJerome Glisse DDC_DVI, 117771fe6b9SJerome Glisse DDC_VGA, 118771fe6b9SJerome Glisse DDC_CRT2, 119771fe6b9SJerome Glisse DDC_LCD, 120771fe6b9SJerome Glisse DDC_GPIO, 121771fe6b9SJerome Glisse }; 122771fe6b9SJerome Glisse 123771fe6b9SJerome Glisse enum radeon_combios_connector { 124771fe6b9SJerome Glisse CONNECTOR_NONE_LEGACY, 125771fe6b9SJerome Glisse CONNECTOR_PROPRIETARY_LEGACY, 126771fe6b9SJerome Glisse CONNECTOR_CRT_LEGACY, 127771fe6b9SJerome Glisse CONNECTOR_DVI_I_LEGACY, 128771fe6b9SJerome Glisse CONNECTOR_DVI_D_LEGACY, 129771fe6b9SJerome Glisse CONNECTOR_CTV_LEGACY, 130771fe6b9SJerome Glisse CONNECTOR_STV_LEGACY, 131771fe6b9SJerome Glisse CONNECTOR_UNSUPPORTED_LEGACY 132771fe6b9SJerome Glisse }; 133771fe6b9SJerome Glisse 134771fe6b9SJerome Glisse const int legacy_connector_convert[] = { 135771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_Unknown, 136771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVID, 137771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 138771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 139771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVID, 140771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_Composite, 141771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 142771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_Unknown, 143771fe6b9SJerome Glisse }; 144771fe6b9SJerome Glisse 145771fe6b9SJerome Glisse static uint16_t combios_get_table_offset(struct drm_device *dev, 146771fe6b9SJerome Glisse enum radeon_combios_table_offset table) 147771fe6b9SJerome Glisse { 148771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 149771fe6b9SJerome Glisse int rev; 150771fe6b9SJerome Glisse uint16_t offset = 0, check_offset; 151771fe6b9SJerome Glisse 152771fe6b9SJerome Glisse switch (table) { 153771fe6b9SJerome Glisse /* absolute offset tables */ 154771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_1_TABLE: 155771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0xc); 156771fe6b9SJerome Glisse if (check_offset) 157771fe6b9SJerome Glisse offset = check_offset; 158771fe6b9SJerome Glisse break; 159771fe6b9SJerome Glisse case COMBIOS_BIOS_SUPPORT_TABLE: 160771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x14); 161771fe6b9SJerome Glisse if (check_offset) 162771fe6b9SJerome Glisse offset = check_offset; 163771fe6b9SJerome Glisse break; 164771fe6b9SJerome Glisse case COMBIOS_DAC_PROGRAMMING_TABLE: 165771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x2a); 166771fe6b9SJerome Glisse if (check_offset) 167771fe6b9SJerome Glisse offset = check_offset; 168771fe6b9SJerome Glisse break; 169771fe6b9SJerome Glisse case COMBIOS_MAX_COLOR_DEPTH_TABLE: 170771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x2c); 171771fe6b9SJerome Glisse if (check_offset) 172771fe6b9SJerome Glisse offset = check_offset; 173771fe6b9SJerome Glisse break; 174771fe6b9SJerome Glisse case COMBIOS_CRTC_INFO_TABLE: 175771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x2e); 176771fe6b9SJerome Glisse if (check_offset) 177771fe6b9SJerome Glisse offset = check_offset; 178771fe6b9SJerome Glisse break; 179771fe6b9SJerome Glisse case COMBIOS_PLL_INFO_TABLE: 180771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x30); 181771fe6b9SJerome Glisse if (check_offset) 182771fe6b9SJerome Glisse offset = check_offset; 183771fe6b9SJerome Glisse break; 184771fe6b9SJerome Glisse case COMBIOS_TV_INFO_TABLE: 185771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x32); 186771fe6b9SJerome Glisse if (check_offset) 187771fe6b9SJerome Glisse offset = check_offset; 188771fe6b9SJerome Glisse break; 189771fe6b9SJerome Glisse case COMBIOS_DFP_INFO_TABLE: 190771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x34); 191771fe6b9SJerome Glisse if (check_offset) 192771fe6b9SJerome Glisse offset = check_offset; 193771fe6b9SJerome Glisse break; 194771fe6b9SJerome Glisse case COMBIOS_HW_CONFIG_INFO_TABLE: 195771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x36); 196771fe6b9SJerome Glisse if (check_offset) 197771fe6b9SJerome Glisse offset = check_offset; 198771fe6b9SJerome Glisse break; 199771fe6b9SJerome Glisse case COMBIOS_MULTIMEDIA_INFO_TABLE: 200771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x38); 201771fe6b9SJerome Glisse if (check_offset) 202771fe6b9SJerome Glisse offset = check_offset; 203771fe6b9SJerome Glisse break; 204771fe6b9SJerome Glisse case COMBIOS_TV_STD_PATCH_TABLE: 205771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x3e); 206771fe6b9SJerome Glisse if (check_offset) 207771fe6b9SJerome Glisse offset = check_offset; 208771fe6b9SJerome Glisse break; 209771fe6b9SJerome Glisse case COMBIOS_LCD_INFO_TABLE: 210771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x40); 211771fe6b9SJerome Glisse if (check_offset) 212771fe6b9SJerome Glisse offset = check_offset; 213771fe6b9SJerome Glisse break; 214771fe6b9SJerome Glisse case COMBIOS_MOBILE_INFO_TABLE: 215771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x42); 216771fe6b9SJerome Glisse if (check_offset) 217771fe6b9SJerome Glisse offset = check_offset; 218771fe6b9SJerome Glisse break; 219771fe6b9SJerome Glisse case COMBIOS_PLL_INIT_TABLE: 220771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x46); 221771fe6b9SJerome Glisse if (check_offset) 222771fe6b9SJerome Glisse offset = check_offset; 223771fe6b9SJerome Glisse break; 224771fe6b9SJerome Glisse case COMBIOS_MEM_CONFIG_TABLE: 225771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x48); 226771fe6b9SJerome Glisse if (check_offset) 227771fe6b9SJerome Glisse offset = check_offset; 228771fe6b9SJerome Glisse break; 229771fe6b9SJerome Glisse case COMBIOS_SAVE_MASK_TABLE: 230771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x4a); 231771fe6b9SJerome Glisse if (check_offset) 232771fe6b9SJerome Glisse offset = check_offset; 233771fe6b9SJerome Glisse break; 234771fe6b9SJerome Glisse case COMBIOS_HARDCODED_EDID_TABLE: 235771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x4c); 236771fe6b9SJerome Glisse if (check_offset) 237771fe6b9SJerome Glisse offset = check_offset; 238771fe6b9SJerome Glisse break; 239771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_2_TABLE: 240771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x4e); 241771fe6b9SJerome Glisse if (check_offset) 242771fe6b9SJerome Glisse offset = check_offset; 243771fe6b9SJerome Glisse break; 244771fe6b9SJerome Glisse case COMBIOS_CONNECTOR_INFO_TABLE: 245771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x50); 246771fe6b9SJerome Glisse if (check_offset) 247771fe6b9SJerome Glisse offset = check_offset; 248771fe6b9SJerome Glisse break; 249771fe6b9SJerome Glisse case COMBIOS_DYN_CLK_1_TABLE: 250771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x52); 251771fe6b9SJerome Glisse if (check_offset) 252771fe6b9SJerome Glisse offset = check_offset; 253771fe6b9SJerome Glisse break; 254771fe6b9SJerome Glisse case COMBIOS_RESERVED_MEM_TABLE: 255771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x54); 256771fe6b9SJerome Glisse if (check_offset) 257771fe6b9SJerome Glisse offset = check_offset; 258771fe6b9SJerome Glisse break; 259771fe6b9SJerome Glisse case COMBIOS_EXT_TMDS_INFO_TABLE: 260771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x58); 261771fe6b9SJerome Glisse if (check_offset) 262771fe6b9SJerome Glisse offset = check_offset; 263771fe6b9SJerome Glisse break; 264771fe6b9SJerome Glisse case COMBIOS_MEM_CLK_INFO_TABLE: 265771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x5a); 266771fe6b9SJerome Glisse if (check_offset) 267771fe6b9SJerome Glisse offset = check_offset; 268771fe6b9SJerome Glisse break; 269771fe6b9SJerome Glisse case COMBIOS_EXT_DAC_INFO_TABLE: 270771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x5c); 271771fe6b9SJerome Glisse if (check_offset) 272771fe6b9SJerome Glisse offset = check_offset; 273771fe6b9SJerome Glisse break; 274771fe6b9SJerome Glisse case COMBIOS_MISC_INFO_TABLE: 275771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x5e); 276771fe6b9SJerome Glisse if (check_offset) 277771fe6b9SJerome Glisse offset = check_offset; 278771fe6b9SJerome Glisse break; 279771fe6b9SJerome Glisse case COMBIOS_CRT_INFO_TABLE: 280771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x60); 281771fe6b9SJerome Glisse if (check_offset) 282771fe6b9SJerome Glisse offset = check_offset; 283771fe6b9SJerome Glisse break; 284771fe6b9SJerome Glisse case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE: 285771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x62); 286771fe6b9SJerome Glisse if (check_offset) 287771fe6b9SJerome Glisse offset = check_offset; 288771fe6b9SJerome Glisse break; 289771fe6b9SJerome Glisse case COMBIOS_COMPONENT_VIDEO_INFO_TABLE: 290771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x64); 291771fe6b9SJerome Glisse if (check_offset) 292771fe6b9SJerome Glisse offset = check_offset; 293771fe6b9SJerome Glisse break; 294771fe6b9SJerome Glisse case COMBIOS_FAN_SPEED_INFO_TABLE: 295771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x66); 296771fe6b9SJerome Glisse if (check_offset) 297771fe6b9SJerome Glisse offset = check_offset; 298771fe6b9SJerome Glisse break; 299771fe6b9SJerome Glisse case COMBIOS_OVERDRIVE_INFO_TABLE: 300771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x68); 301771fe6b9SJerome Glisse if (check_offset) 302771fe6b9SJerome Glisse offset = check_offset; 303771fe6b9SJerome Glisse break; 304771fe6b9SJerome Glisse case COMBIOS_OEM_INFO_TABLE: 305771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x6a); 306771fe6b9SJerome Glisse if (check_offset) 307771fe6b9SJerome Glisse offset = check_offset; 308771fe6b9SJerome Glisse break; 309771fe6b9SJerome Glisse case COMBIOS_DYN_CLK_2_TABLE: 310771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x6c); 311771fe6b9SJerome Glisse if (check_offset) 312771fe6b9SJerome Glisse offset = check_offset; 313771fe6b9SJerome Glisse break; 314771fe6b9SJerome Glisse case COMBIOS_POWER_CONNECTOR_INFO_TABLE: 315771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x6e); 316771fe6b9SJerome Glisse if (check_offset) 317771fe6b9SJerome Glisse offset = check_offset; 318771fe6b9SJerome Glisse break; 319771fe6b9SJerome Glisse case COMBIOS_I2C_INFO_TABLE: 320771fe6b9SJerome Glisse check_offset = RBIOS16(rdev->bios_header_start + 0x70); 321771fe6b9SJerome Glisse if (check_offset) 322771fe6b9SJerome Glisse offset = check_offset; 323771fe6b9SJerome Glisse break; 324771fe6b9SJerome Glisse /* relative offset tables */ 325771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_3_TABLE: /* offset from misc info */ 326771fe6b9SJerome Glisse check_offset = 327771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 328771fe6b9SJerome Glisse if (check_offset) { 329771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 330771fe6b9SJerome Glisse if (rev > 0) { 331771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x3); 332771fe6b9SJerome Glisse if (check_offset) 333771fe6b9SJerome Glisse offset = check_offset; 334771fe6b9SJerome Glisse } 335771fe6b9SJerome Glisse } 336771fe6b9SJerome Glisse break; 337771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_4_TABLE: /* offset from misc info */ 338771fe6b9SJerome Glisse check_offset = 339771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 340771fe6b9SJerome Glisse if (check_offset) { 341771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 342771fe6b9SJerome Glisse if (rev > 0) { 343771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x5); 344771fe6b9SJerome Glisse if (check_offset) 345771fe6b9SJerome Glisse offset = check_offset; 346771fe6b9SJerome Glisse } 347771fe6b9SJerome Glisse } 348771fe6b9SJerome Glisse break; 349771fe6b9SJerome Glisse case COMBIOS_DETECTED_MEM_TABLE: /* offset from misc info */ 350771fe6b9SJerome Glisse check_offset = 351771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 352771fe6b9SJerome Glisse if (check_offset) { 353771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 354771fe6b9SJerome Glisse if (rev > 0) { 355771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x7); 356771fe6b9SJerome Glisse if (check_offset) 357771fe6b9SJerome Glisse offset = check_offset; 358771fe6b9SJerome Glisse } 359771fe6b9SJerome Glisse } 360771fe6b9SJerome Glisse break; 361771fe6b9SJerome Glisse case COMBIOS_ASIC_INIT_5_TABLE: /* offset from misc info */ 362771fe6b9SJerome Glisse check_offset = 363771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE); 364771fe6b9SJerome Glisse if (check_offset) { 365771fe6b9SJerome Glisse rev = RBIOS8(check_offset); 366771fe6b9SJerome Glisse if (rev == 2) { 367771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x9); 368771fe6b9SJerome Glisse if (check_offset) 369771fe6b9SJerome Glisse offset = check_offset; 370771fe6b9SJerome Glisse } 371771fe6b9SJerome Glisse } 372771fe6b9SJerome Glisse break; 373771fe6b9SJerome Glisse case COMBIOS_RAM_RESET_TABLE: /* offset from mem config */ 374771fe6b9SJerome Glisse check_offset = 375771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 376771fe6b9SJerome Glisse if (check_offset) { 377771fe6b9SJerome Glisse while (RBIOS8(check_offset++)); 378771fe6b9SJerome Glisse check_offset += 2; 379771fe6b9SJerome Glisse if (check_offset) 380771fe6b9SJerome Glisse offset = check_offset; 381771fe6b9SJerome Glisse } 382771fe6b9SJerome Glisse break; 383771fe6b9SJerome Glisse case COMBIOS_POWERPLAY_INFO_TABLE: /* offset from mobile info */ 384771fe6b9SJerome Glisse check_offset = 385771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 386771fe6b9SJerome Glisse if (check_offset) { 387771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x11); 388771fe6b9SJerome Glisse if (check_offset) 389771fe6b9SJerome Glisse offset = check_offset; 390771fe6b9SJerome Glisse } 391771fe6b9SJerome Glisse break; 392771fe6b9SJerome Glisse case COMBIOS_GPIO_INFO_TABLE: /* offset from mobile info */ 393771fe6b9SJerome Glisse check_offset = 394771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 395771fe6b9SJerome Glisse if (check_offset) { 396771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x13); 397771fe6b9SJerome Glisse if (check_offset) 398771fe6b9SJerome Glisse offset = check_offset; 399771fe6b9SJerome Glisse } 400771fe6b9SJerome Glisse break; 401771fe6b9SJerome Glisse case COMBIOS_LCD_DDC_INFO_TABLE: /* offset from mobile info */ 402771fe6b9SJerome Glisse check_offset = 403771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 404771fe6b9SJerome Glisse if (check_offset) { 405771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x15); 406771fe6b9SJerome Glisse if (check_offset) 407771fe6b9SJerome Glisse offset = check_offset; 408771fe6b9SJerome Glisse } 409771fe6b9SJerome Glisse break; 410771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_TABLE: /* offset from mobile info */ 411771fe6b9SJerome Glisse check_offset = 412771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE); 413771fe6b9SJerome Glisse if (check_offset) { 414771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x17); 415771fe6b9SJerome Glisse if (check_offset) 416771fe6b9SJerome Glisse offset = check_offset; 417771fe6b9SJerome Glisse } 418771fe6b9SJerome Glisse break; 419771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_ON_TABLE: /* offset from tmds power */ 420771fe6b9SJerome Glisse check_offset = 421771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); 422771fe6b9SJerome Glisse if (check_offset) { 423771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x2); 424771fe6b9SJerome Glisse if (check_offset) 425771fe6b9SJerome Glisse offset = check_offset; 426771fe6b9SJerome Glisse } 427771fe6b9SJerome Glisse break; 428771fe6b9SJerome Glisse case COMBIOS_TMDS_POWER_OFF_TABLE: /* offset from tmds power */ 429771fe6b9SJerome Glisse check_offset = 430771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE); 431771fe6b9SJerome Glisse if (check_offset) { 432771fe6b9SJerome Glisse check_offset = RBIOS16(check_offset + 0x4); 433771fe6b9SJerome Glisse if (check_offset) 434771fe6b9SJerome Glisse offset = check_offset; 435771fe6b9SJerome Glisse } 436771fe6b9SJerome Glisse break; 437771fe6b9SJerome Glisse default: 438771fe6b9SJerome Glisse break; 439771fe6b9SJerome Glisse } 440771fe6b9SJerome Glisse 441771fe6b9SJerome Glisse return offset; 442771fe6b9SJerome Glisse 443771fe6b9SJerome Glisse } 444771fe6b9SJerome Glisse 445*6a93cb25SAlex Deucher static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev, 446*6a93cb25SAlex Deucher int ddc_line) 447771fe6b9SJerome Glisse { 448771fe6b9SJerome Glisse struct radeon_i2c_bus_rec i2c; 449771fe6b9SJerome Glisse 450*6a93cb25SAlex Deucher if (ddc_line == RADEON_GPIOPAD_MASK) { 451*6a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_GPIOPAD_MASK; 452*6a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_GPIOPAD_MASK; 453*6a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_GPIOPAD_A; 454*6a93cb25SAlex Deucher i2c.a_data_reg = RADEON_GPIOPAD_A; 455*6a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_GPIOPAD_EN; 456*6a93cb25SAlex Deucher i2c.en_data_reg = RADEON_GPIOPAD_EN; 457*6a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_GPIOPAD_Y; 458*6a93cb25SAlex Deucher i2c.y_data_reg = RADEON_GPIOPAD_Y; 459*6a93cb25SAlex Deucher } else if (ddc_line == RADEON_MDGPIO_MASK) { 460*6a93cb25SAlex Deucher i2c.mask_clk_reg = RADEON_MDGPIO_MASK; 461*6a93cb25SAlex Deucher i2c.mask_data_reg = RADEON_MDGPIO_MASK; 462*6a93cb25SAlex Deucher i2c.a_clk_reg = RADEON_MDGPIO_A; 463*6a93cb25SAlex Deucher i2c.a_data_reg = RADEON_MDGPIO_A; 464*6a93cb25SAlex Deucher i2c.en_clk_reg = RADEON_MDGPIO_EN; 465*6a93cb25SAlex Deucher i2c.en_data_reg = RADEON_MDGPIO_EN; 466*6a93cb25SAlex Deucher i2c.y_clk_reg = RADEON_MDGPIO_Y; 467*6a93cb25SAlex Deucher i2c.y_data_reg = RADEON_MDGPIO_Y; 468*6a93cb25SAlex Deucher } else { 469771fe6b9SJerome Glisse i2c.mask_clk_mask = RADEON_GPIO_EN_1; 470771fe6b9SJerome Glisse i2c.mask_data_mask = RADEON_GPIO_EN_0; 471771fe6b9SJerome Glisse i2c.a_clk_mask = RADEON_GPIO_A_1; 472771fe6b9SJerome Glisse i2c.a_data_mask = RADEON_GPIO_A_0; 4739b9fe724SAlex Deucher i2c.en_clk_mask = RADEON_GPIO_EN_1; 4749b9fe724SAlex Deucher i2c.en_data_mask = RADEON_GPIO_EN_0; 4759b9fe724SAlex Deucher i2c.y_clk_mask = RADEON_GPIO_Y_1; 4769b9fe724SAlex Deucher i2c.y_data_mask = RADEON_GPIO_Y_0; 477*6a93cb25SAlex Deucher 478771fe6b9SJerome Glisse i2c.mask_clk_reg = ddc_line; 479771fe6b9SJerome Glisse i2c.mask_data_reg = ddc_line; 480771fe6b9SJerome Glisse i2c.a_clk_reg = ddc_line; 481771fe6b9SJerome Glisse i2c.a_data_reg = ddc_line; 4829b9fe724SAlex Deucher i2c.en_clk_reg = ddc_line; 4839b9fe724SAlex Deucher i2c.en_data_reg = ddc_line; 4849b9fe724SAlex Deucher i2c.y_clk_reg = ddc_line; 4859b9fe724SAlex Deucher i2c.y_data_reg = ddc_line; 486771fe6b9SJerome Glisse } 487771fe6b9SJerome Glisse 488*6a93cb25SAlex Deucher if (rdev->family < CHIP_R200) 489*6a93cb25SAlex Deucher i2c.hw_capable = false; 490*6a93cb25SAlex Deucher else { 491*6a93cb25SAlex Deucher switch (ddc_line) { 492*6a93cb25SAlex Deucher case RADEON_GPIO_VGA_DDC: 493*6a93cb25SAlex Deucher case RADEON_GPIO_DVI_DDC: 494*6a93cb25SAlex Deucher i2c.hw_capable = true; 495*6a93cb25SAlex Deucher break; 496*6a93cb25SAlex Deucher case RADEON_GPIO_MONID: 497*6a93cb25SAlex Deucher /* hw i2c on RADEON_GPIO_MONID doesn't seem to work 498*6a93cb25SAlex Deucher * reliably on some pre-r4xx hardware; not sure why. 499*6a93cb25SAlex Deucher */ 500*6a93cb25SAlex Deucher i2c.hw_capable = false; 501*6a93cb25SAlex Deucher break; 502*6a93cb25SAlex Deucher default: 503*6a93cb25SAlex Deucher i2c.hw_capable = false; 504*6a93cb25SAlex Deucher break; 505*6a93cb25SAlex Deucher } 506*6a93cb25SAlex Deucher } 507*6a93cb25SAlex Deucher i2c.mm_i2c = false; 508*6a93cb25SAlex Deucher i2c.i2c_id = 0; 509*6a93cb25SAlex Deucher 510771fe6b9SJerome Glisse if (ddc_line) 511771fe6b9SJerome Glisse i2c.valid = true; 512771fe6b9SJerome Glisse else 513771fe6b9SJerome Glisse i2c.valid = false; 514771fe6b9SJerome Glisse 515771fe6b9SJerome Glisse return i2c; 516771fe6b9SJerome Glisse } 517771fe6b9SJerome Glisse 518771fe6b9SJerome Glisse bool radeon_combios_get_clock_info(struct drm_device *dev) 519771fe6b9SJerome Glisse { 520771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 521771fe6b9SJerome Glisse uint16_t pll_info; 522771fe6b9SJerome Glisse struct radeon_pll *p1pll = &rdev->clock.p1pll; 523771fe6b9SJerome Glisse struct radeon_pll *p2pll = &rdev->clock.p2pll; 524771fe6b9SJerome Glisse struct radeon_pll *spll = &rdev->clock.spll; 525771fe6b9SJerome Glisse struct radeon_pll *mpll = &rdev->clock.mpll; 526771fe6b9SJerome Glisse int8_t rev; 527771fe6b9SJerome Glisse uint16_t sclk, mclk; 528771fe6b9SJerome Glisse 529771fe6b9SJerome Glisse if (rdev->bios == NULL) 5304b30b870SDave Airlie return false; 531771fe6b9SJerome Glisse 532771fe6b9SJerome Glisse pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE); 533771fe6b9SJerome Glisse if (pll_info) { 534771fe6b9SJerome Glisse rev = RBIOS8(pll_info); 535771fe6b9SJerome Glisse 536771fe6b9SJerome Glisse /* pixel clocks */ 537771fe6b9SJerome Glisse p1pll->reference_freq = RBIOS16(pll_info + 0xe); 538771fe6b9SJerome Glisse p1pll->reference_div = RBIOS16(pll_info + 0x10); 539771fe6b9SJerome Glisse p1pll->pll_out_min = RBIOS32(pll_info + 0x12); 540771fe6b9SJerome Glisse p1pll->pll_out_max = RBIOS32(pll_info + 0x16); 541771fe6b9SJerome Glisse 542771fe6b9SJerome Glisse if (rev > 9) { 543771fe6b9SJerome Glisse p1pll->pll_in_min = RBIOS32(pll_info + 0x36); 544771fe6b9SJerome Glisse p1pll->pll_in_max = RBIOS32(pll_info + 0x3a); 545771fe6b9SJerome Glisse } else { 546771fe6b9SJerome Glisse p1pll->pll_in_min = 40; 547771fe6b9SJerome Glisse p1pll->pll_in_max = 500; 548771fe6b9SJerome Glisse } 549771fe6b9SJerome Glisse *p2pll = *p1pll; 550771fe6b9SJerome Glisse 551771fe6b9SJerome Glisse /* system clock */ 552771fe6b9SJerome Glisse spll->reference_freq = RBIOS16(pll_info + 0x1a); 553771fe6b9SJerome Glisse spll->reference_div = RBIOS16(pll_info + 0x1c); 554771fe6b9SJerome Glisse spll->pll_out_min = RBIOS32(pll_info + 0x1e); 555771fe6b9SJerome Glisse spll->pll_out_max = RBIOS32(pll_info + 0x22); 556771fe6b9SJerome Glisse 557771fe6b9SJerome Glisse if (rev > 10) { 558771fe6b9SJerome Glisse spll->pll_in_min = RBIOS32(pll_info + 0x48); 559771fe6b9SJerome Glisse spll->pll_in_max = RBIOS32(pll_info + 0x4c); 560771fe6b9SJerome Glisse } else { 561771fe6b9SJerome Glisse /* ??? */ 562771fe6b9SJerome Glisse spll->pll_in_min = 40; 563771fe6b9SJerome Glisse spll->pll_in_max = 500; 564771fe6b9SJerome Glisse } 565771fe6b9SJerome Glisse 566771fe6b9SJerome Glisse /* memory clock */ 567771fe6b9SJerome Glisse mpll->reference_freq = RBIOS16(pll_info + 0x26); 568771fe6b9SJerome Glisse mpll->reference_div = RBIOS16(pll_info + 0x28); 569771fe6b9SJerome Glisse mpll->pll_out_min = RBIOS32(pll_info + 0x2a); 570771fe6b9SJerome Glisse mpll->pll_out_max = RBIOS32(pll_info + 0x2e); 571771fe6b9SJerome Glisse 572771fe6b9SJerome Glisse if (rev > 10) { 573771fe6b9SJerome Glisse mpll->pll_in_min = RBIOS32(pll_info + 0x5a); 574771fe6b9SJerome Glisse mpll->pll_in_max = RBIOS32(pll_info + 0x5e); 575771fe6b9SJerome Glisse } else { 576771fe6b9SJerome Glisse /* ??? */ 577771fe6b9SJerome Glisse mpll->pll_in_min = 40; 578771fe6b9SJerome Glisse mpll->pll_in_max = 500; 579771fe6b9SJerome Glisse } 580771fe6b9SJerome Glisse 581771fe6b9SJerome Glisse /* default sclk/mclk */ 582771fe6b9SJerome Glisse sclk = RBIOS16(pll_info + 0xa); 583771fe6b9SJerome Glisse mclk = RBIOS16(pll_info + 0x8); 584771fe6b9SJerome Glisse if (sclk == 0) 585771fe6b9SJerome Glisse sclk = 200 * 100; 586771fe6b9SJerome Glisse if (mclk == 0) 587771fe6b9SJerome Glisse mclk = 200 * 100; 588771fe6b9SJerome Glisse 589771fe6b9SJerome Glisse rdev->clock.default_sclk = sclk; 590771fe6b9SJerome Glisse rdev->clock.default_mclk = mclk; 591771fe6b9SJerome Glisse 592771fe6b9SJerome Glisse return true; 593771fe6b9SJerome Glisse } 594771fe6b9SJerome Glisse return false; 595771fe6b9SJerome Glisse } 596771fe6b9SJerome Glisse 597771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct 598771fe6b9SJerome Glisse radeon_encoder 599771fe6b9SJerome Glisse *encoder) 600771fe6b9SJerome Glisse { 601771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 602771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 603771fe6b9SJerome Glisse uint16_t dac_info; 604771fe6b9SJerome Glisse uint8_t rev, bg, dac; 605771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *p_dac = NULL; 606771fe6b9SJerome Glisse 607771fe6b9SJerome Glisse if (rdev->bios == NULL) 608771fe6b9SJerome Glisse return NULL; 609771fe6b9SJerome Glisse 610771fe6b9SJerome Glisse /* check CRT table */ 611771fe6b9SJerome Glisse dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 612771fe6b9SJerome Glisse if (dac_info) { 613771fe6b9SJerome Glisse p_dac = 614771fe6b9SJerome Glisse kzalloc(sizeof(struct radeon_encoder_primary_dac), 615771fe6b9SJerome Glisse GFP_KERNEL); 616771fe6b9SJerome Glisse 617771fe6b9SJerome Glisse if (!p_dac) 618771fe6b9SJerome Glisse return NULL; 619771fe6b9SJerome Glisse 620771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 621771fe6b9SJerome Glisse if (rev < 2) { 622771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 623771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf; 624771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 625771fe6b9SJerome Glisse } else { 626771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 627771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x3) & 0xf; 628771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 629771fe6b9SJerome Glisse } 630771fe6b9SJerome Glisse 631771fe6b9SJerome Glisse } 632771fe6b9SJerome Glisse 633771fe6b9SJerome Glisse return p_dac; 634771fe6b9SJerome Glisse } 635771fe6b9SJerome Glisse 636771fe6b9SJerome Glisse static enum radeon_tv_std 637771fe6b9SJerome Glisse radeon_combios_get_tv_info(struct radeon_encoder *encoder) 638771fe6b9SJerome Glisse { 639771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 640771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 641771fe6b9SJerome Glisse uint16_t tv_info; 642771fe6b9SJerome Glisse enum radeon_tv_std tv_std = TV_STD_NTSC; 643771fe6b9SJerome Glisse 644771fe6b9SJerome Glisse tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 645771fe6b9SJerome Glisse if (tv_info) { 646771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 647771fe6b9SJerome Glisse switch (RBIOS8(tv_info + 7) & 0xf) { 648771fe6b9SJerome Glisse case 1: 649771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 650771fe6b9SJerome Glisse DRM_INFO("Default TV standard: NTSC\n"); 651771fe6b9SJerome Glisse break; 652771fe6b9SJerome Glisse case 2: 653771fe6b9SJerome Glisse tv_std = TV_STD_PAL; 654771fe6b9SJerome Glisse DRM_INFO("Default TV standard: PAL\n"); 655771fe6b9SJerome Glisse break; 656771fe6b9SJerome Glisse case 3: 657771fe6b9SJerome Glisse tv_std = TV_STD_PAL_M; 658771fe6b9SJerome Glisse DRM_INFO("Default TV standard: PAL-M\n"); 659771fe6b9SJerome Glisse break; 660771fe6b9SJerome Glisse case 4: 661771fe6b9SJerome Glisse tv_std = TV_STD_PAL_60; 662771fe6b9SJerome Glisse DRM_INFO("Default TV standard: PAL-60\n"); 663771fe6b9SJerome Glisse break; 664771fe6b9SJerome Glisse case 5: 665771fe6b9SJerome Glisse tv_std = TV_STD_NTSC_J; 666771fe6b9SJerome Glisse DRM_INFO("Default TV standard: NTSC-J\n"); 667771fe6b9SJerome Glisse break; 668771fe6b9SJerome Glisse case 6: 669771fe6b9SJerome Glisse tv_std = TV_STD_SCART_PAL; 670771fe6b9SJerome Glisse DRM_INFO("Default TV standard: SCART-PAL\n"); 671771fe6b9SJerome Glisse break; 672771fe6b9SJerome Glisse default: 673771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 674771fe6b9SJerome Glisse DRM_INFO 675771fe6b9SJerome Glisse ("Unknown TV standard; defaulting to NTSC\n"); 676771fe6b9SJerome Glisse break; 677771fe6b9SJerome Glisse } 678771fe6b9SJerome Glisse 679771fe6b9SJerome Glisse switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) { 680771fe6b9SJerome Glisse case 0: 681771fe6b9SJerome Glisse DRM_INFO("29.498928713 MHz TV ref clk\n"); 682771fe6b9SJerome Glisse break; 683771fe6b9SJerome Glisse case 1: 684771fe6b9SJerome Glisse DRM_INFO("28.636360000 MHz TV ref clk\n"); 685771fe6b9SJerome Glisse break; 686771fe6b9SJerome Glisse case 2: 687771fe6b9SJerome Glisse DRM_INFO("14.318180000 MHz TV ref clk\n"); 688771fe6b9SJerome Glisse break; 689771fe6b9SJerome Glisse case 3: 690771fe6b9SJerome Glisse DRM_INFO("27.000000000 MHz TV ref clk\n"); 691771fe6b9SJerome Glisse break; 692771fe6b9SJerome Glisse default: 693771fe6b9SJerome Glisse break; 694771fe6b9SJerome Glisse } 695771fe6b9SJerome Glisse } 696771fe6b9SJerome Glisse } 697771fe6b9SJerome Glisse return tv_std; 698771fe6b9SJerome Glisse } 699771fe6b9SJerome Glisse 700771fe6b9SJerome Glisse static const uint32_t default_tvdac_adj[CHIP_LAST] = { 701771fe6b9SJerome Glisse 0x00000000, /* r100 */ 702771fe6b9SJerome Glisse 0x00280000, /* rv100 */ 703771fe6b9SJerome Glisse 0x00000000, /* rs100 */ 704771fe6b9SJerome Glisse 0x00880000, /* rv200 */ 705771fe6b9SJerome Glisse 0x00000000, /* rs200 */ 706771fe6b9SJerome Glisse 0x00000000, /* r200 */ 707771fe6b9SJerome Glisse 0x00770000, /* rv250 */ 708771fe6b9SJerome Glisse 0x00290000, /* rs300 */ 709771fe6b9SJerome Glisse 0x00560000, /* rv280 */ 710771fe6b9SJerome Glisse 0x00780000, /* r300 */ 711771fe6b9SJerome Glisse 0x00770000, /* r350 */ 712771fe6b9SJerome Glisse 0x00780000, /* rv350 */ 713771fe6b9SJerome Glisse 0x00780000, /* rv380 */ 714771fe6b9SJerome Glisse 0x01080000, /* r420 */ 715771fe6b9SJerome Glisse 0x01080000, /* r423 */ 716771fe6b9SJerome Glisse 0x01080000, /* rv410 */ 717771fe6b9SJerome Glisse 0x00780000, /* rs400 */ 718771fe6b9SJerome Glisse 0x00780000, /* rs480 */ 719771fe6b9SJerome Glisse }; 720771fe6b9SJerome Glisse 7216a719e05SDave Airlie static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev, 7226a719e05SDave Airlie struct radeon_encoder_tv_dac *tv_dac) 723771fe6b9SJerome Glisse { 724771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; 725771fe6b9SJerome Glisse if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) 726771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 0x00880000; 727771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 728771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 7296a719e05SDave Airlie return; 730771fe6b9SJerome Glisse } 731771fe6b9SJerome Glisse 732771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct 733771fe6b9SJerome Glisse radeon_encoder 734771fe6b9SJerome Glisse *encoder) 735771fe6b9SJerome Glisse { 736771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 737771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 738771fe6b9SJerome Glisse uint16_t dac_info; 739771fe6b9SJerome Glisse uint8_t rev, bg, dac; 740771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *tv_dac = NULL; 7416a719e05SDave Airlie int found = 0; 7426a719e05SDave Airlie 7436a719e05SDave Airlie tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); 7446a719e05SDave Airlie if (!tv_dac) 7456a719e05SDave Airlie return NULL; 746771fe6b9SJerome Glisse 747771fe6b9SJerome Glisse if (rdev->bios == NULL) 7486a719e05SDave Airlie goto out; 749771fe6b9SJerome Glisse 750771fe6b9SJerome Glisse /* first check TV table */ 751771fe6b9SJerome Glisse dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 752771fe6b9SJerome Glisse if (dac_info) { 753771fe6b9SJerome Glisse rev = RBIOS8(dac_info + 0x3); 754771fe6b9SJerome Glisse if (rev > 4) { 755771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 756771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xd) & 0xf; 757771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 758771fe6b9SJerome Glisse 759771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 760771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xf) & 0xf; 761771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 762771fe6b9SJerome Glisse 763771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x10) & 0xf; 764771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x11) & 0xf; 765771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 7666a719e05SDave Airlie found = 1; 767771fe6b9SJerome Glisse } else if (rev > 1) { 768771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 769771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; 770771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 771771fe6b9SJerome Glisse 772771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xd) & 0xf; 773771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf; 774771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 775771fe6b9SJerome Glisse 776771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 777771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; 778771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 7796a719e05SDave Airlie found = 1; 780771fe6b9SJerome Glisse } 781771fe6b9SJerome Glisse tv_dac->tv_std = radeon_combios_get_tv_info(encoder); 7826a719e05SDave Airlie } 7836a719e05SDave Airlie if (!found) { 784771fe6b9SJerome Glisse /* then check CRT table */ 785771fe6b9SJerome Glisse dac_info = 786771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 787771fe6b9SJerome Glisse if (dac_info) { 788771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 789771fe6b9SJerome Glisse if (rev < 2) { 790771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x3) & 0xf; 791771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf; 792771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 793771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 794771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 795771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 7966a719e05SDave Airlie found = 1; 797771fe6b9SJerome Glisse } else { 798771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x4) & 0xf; 799771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x5) & 0xf; 800771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 801771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 802771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 803771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 8046a719e05SDave Airlie found = 1; 805771fe6b9SJerome Glisse } 8066fe7ac3fSAlex Deucher } else { 8076fe7ac3fSAlex Deucher DRM_INFO("No TV DAC info found in BIOS\n"); 808771fe6b9SJerome Glisse } 809771fe6b9SJerome Glisse } 810771fe6b9SJerome Glisse 8116a719e05SDave Airlie out: 8126a719e05SDave Airlie if (!found) /* fallback to defaults */ 8136a719e05SDave Airlie radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac); 8146a719e05SDave Airlie 815771fe6b9SJerome Glisse return tv_dac; 816771fe6b9SJerome Glisse } 817771fe6b9SJerome Glisse 818771fe6b9SJerome Glisse static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct 819771fe6b9SJerome Glisse radeon_device 820771fe6b9SJerome Glisse *rdev) 821771fe6b9SJerome Glisse { 822771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 823771fe6b9SJerome Glisse uint32_t fp_vert_stretch, fp_horz_stretch; 824771fe6b9SJerome Glisse uint32_t ppll_div_sel, ppll_val; 8258b5c7444SMichel Dänzer uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL); 826771fe6b9SJerome Glisse 827771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 828771fe6b9SJerome Glisse 829771fe6b9SJerome Glisse if (!lvds) 830771fe6b9SJerome Glisse return NULL; 831771fe6b9SJerome Glisse 832771fe6b9SJerome Glisse fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH); 833771fe6b9SJerome Glisse fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH); 834771fe6b9SJerome Glisse 8358b5c7444SMichel Dänzer /* These should be fail-safe defaults, fingers crossed */ 8368b5c7444SMichel Dänzer lvds->panel_pwr_delay = 200; 8378b5c7444SMichel Dänzer lvds->panel_vcc_delay = 2000; 8388b5c7444SMichel Dänzer 8398b5c7444SMichel Dänzer lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL); 8408b5c7444SMichel Dänzer lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf; 8418b5c7444SMichel Dänzer lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf; 8428b5c7444SMichel Dänzer 843771fe6b9SJerome Glisse if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE) 844de2103e4SAlex Deucher lvds->native_mode.vdisplay = 845771fe6b9SJerome Glisse ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >> 846771fe6b9SJerome Glisse RADEON_VERT_PANEL_SHIFT) + 1; 847771fe6b9SJerome Glisse else 848de2103e4SAlex Deucher lvds->native_mode.vdisplay = 849771fe6b9SJerome Glisse (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1; 850771fe6b9SJerome Glisse 851771fe6b9SJerome Glisse if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE) 852de2103e4SAlex Deucher lvds->native_mode.hdisplay = 853771fe6b9SJerome Glisse (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >> 854771fe6b9SJerome Glisse RADEON_HORZ_PANEL_SHIFT) + 1) * 8; 855771fe6b9SJerome Glisse else 856de2103e4SAlex Deucher lvds->native_mode.hdisplay = 857771fe6b9SJerome Glisse ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8; 858771fe6b9SJerome Glisse 859de2103e4SAlex Deucher if ((lvds->native_mode.hdisplay < 640) || 860de2103e4SAlex Deucher (lvds->native_mode.vdisplay < 480)) { 861de2103e4SAlex Deucher lvds->native_mode.hdisplay = 640; 862de2103e4SAlex Deucher lvds->native_mode.vdisplay = 480; 863771fe6b9SJerome Glisse } 864771fe6b9SJerome Glisse 865771fe6b9SJerome Glisse ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3; 866771fe6b9SJerome Glisse ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel); 867771fe6b9SJerome Glisse if ((ppll_val & 0x000707ff) == 0x1bb) 868771fe6b9SJerome Glisse lvds->use_bios_dividers = false; 869771fe6b9SJerome Glisse else { 870771fe6b9SJerome Glisse lvds->panel_ref_divider = 871771fe6b9SJerome Glisse RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff; 872771fe6b9SJerome Glisse lvds->panel_post_divider = (ppll_val >> 16) & 0x7; 873771fe6b9SJerome Glisse lvds->panel_fb_divider = ppll_val & 0x7ff; 874771fe6b9SJerome Glisse 875771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 876771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 877771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 878771fe6b9SJerome Glisse } 879771fe6b9SJerome Glisse lvds->panel_vcc_delay = 200; 880771fe6b9SJerome Glisse 881771fe6b9SJerome Glisse DRM_INFO("Panel info derived from registers\n"); 882de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 883de2103e4SAlex Deucher lvds->native_mode.vdisplay); 884771fe6b9SJerome Glisse 885771fe6b9SJerome Glisse return lvds; 886771fe6b9SJerome Glisse } 887771fe6b9SJerome Glisse 888771fe6b9SJerome Glisse struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct 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 lcd_info; 894771fe6b9SJerome Glisse uint32_t panel_setup; 895771fe6b9SJerome Glisse char stmp[30]; 896771fe6b9SJerome Glisse int tmp, i; 897771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 898771fe6b9SJerome Glisse 8998dfaa8a7SMichel Dänzer if (rdev->bios == NULL) { 9008dfaa8a7SMichel Dänzer lvds = radeon_legacy_get_lvds_info_from_regs(rdev); 9018dfaa8a7SMichel Dänzer goto out; 9028dfaa8a7SMichel Dänzer } 903771fe6b9SJerome Glisse 904771fe6b9SJerome Glisse lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 905771fe6b9SJerome Glisse 906771fe6b9SJerome Glisse if (lcd_info) { 907771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 908771fe6b9SJerome Glisse 909771fe6b9SJerome Glisse if (!lvds) 910771fe6b9SJerome Glisse return NULL; 911771fe6b9SJerome Glisse 912771fe6b9SJerome Glisse for (i = 0; i < 24; i++) 913771fe6b9SJerome Glisse stmp[i] = RBIOS8(lcd_info + i + 1); 914771fe6b9SJerome Glisse stmp[24] = 0; 915771fe6b9SJerome Glisse 916771fe6b9SJerome Glisse DRM_INFO("Panel ID String: %s\n", stmp); 917771fe6b9SJerome Glisse 918de2103e4SAlex Deucher lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19); 919de2103e4SAlex Deucher lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b); 920771fe6b9SJerome Glisse 921de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 922de2103e4SAlex Deucher lvds->native_mode.vdisplay); 923771fe6b9SJerome Glisse 924771fe6b9SJerome Glisse lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c); 925771fe6b9SJerome Glisse if (lvds->panel_vcc_delay > 2000 || lvds->panel_vcc_delay < 0) 926771fe6b9SJerome Glisse lvds->panel_vcc_delay = 2000; 927771fe6b9SJerome Glisse 928771fe6b9SJerome Glisse lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24); 929771fe6b9SJerome Glisse lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf; 930771fe6b9SJerome Glisse lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf; 931771fe6b9SJerome Glisse 932771fe6b9SJerome Glisse lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e); 933771fe6b9SJerome Glisse lvds->panel_post_divider = RBIOS8(lcd_info + 0x30); 934771fe6b9SJerome Glisse lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31); 935771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 936771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 937771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 938771fe6b9SJerome Glisse 939771fe6b9SJerome Glisse panel_setup = RBIOS32(lcd_info + 0x39); 940771fe6b9SJerome Glisse lvds->lvds_gen_cntl = 0xff00; 941771fe6b9SJerome Glisse if (panel_setup & 0x1) 942771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT; 943771fe6b9SJerome Glisse 944771fe6b9SJerome Glisse if ((panel_setup >> 4) & 0x1) 945771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE; 946771fe6b9SJerome Glisse 947771fe6b9SJerome Glisse switch ((panel_setup >> 8) & 0x7) { 948771fe6b9SJerome Glisse case 0: 949771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM; 950771fe6b9SJerome Glisse break; 951771fe6b9SJerome Glisse case 1: 952771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY; 953771fe6b9SJerome Glisse break; 954771fe6b9SJerome Glisse case 2: 955771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY; 956771fe6b9SJerome Glisse break; 957771fe6b9SJerome Glisse default: 958771fe6b9SJerome Glisse break; 959771fe6b9SJerome Glisse } 960771fe6b9SJerome Glisse 961771fe6b9SJerome Glisse if ((panel_setup >> 16) & 0x1) 962771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW; 963771fe6b9SJerome Glisse 964771fe6b9SJerome Glisse if ((panel_setup >> 17) & 0x1) 965771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW; 966771fe6b9SJerome Glisse 967771fe6b9SJerome Glisse if ((panel_setup >> 18) & 0x1) 968771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW; 969771fe6b9SJerome Glisse 970771fe6b9SJerome Glisse if ((panel_setup >> 23) & 0x1) 971771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL; 972771fe6b9SJerome Glisse 973771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000); 974771fe6b9SJerome Glisse 975771fe6b9SJerome Glisse for (i = 0; i < 32; i++) { 976771fe6b9SJerome Glisse tmp = RBIOS16(lcd_info + 64 + i * 2); 977771fe6b9SJerome Glisse if (tmp == 0) 978771fe6b9SJerome Glisse break; 979771fe6b9SJerome Glisse 980de2103e4SAlex Deucher if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) && 981771fe6b9SJerome Glisse (RBIOS16(tmp + 2) == 982de2103e4SAlex Deucher lvds->native_mode.vdisplay)) { 983de2103e4SAlex Deucher lvds->native_mode.htotal = RBIOS16(tmp + 17) * 8; 984de2103e4SAlex Deucher lvds->native_mode.hsync_start = RBIOS16(tmp + 21) * 8; 985de2103e4SAlex Deucher lvds->native_mode.hsync_end = (RBIOS8(tmp + 23) + 986de2103e4SAlex Deucher RBIOS16(tmp + 21)) * 8; 987771fe6b9SJerome Glisse 988de2103e4SAlex Deucher lvds->native_mode.vtotal = RBIOS16(tmp + 24); 989de2103e4SAlex Deucher lvds->native_mode.vsync_start = RBIOS16(tmp + 28) & 0x7ff; 990de2103e4SAlex Deucher lvds->native_mode.vsync_end = 991de2103e4SAlex Deucher ((RBIOS16(tmp + 28) & 0xf800) >> 11) + 992de2103e4SAlex Deucher (RBIOS16(tmp + 28) & 0x7ff); 993de2103e4SAlex Deucher 994de2103e4SAlex Deucher lvds->native_mode.clock = RBIOS16(tmp + 9) * 10; 995771fe6b9SJerome Glisse lvds->native_mode.flags = 0; 996de2103e4SAlex Deucher /* set crtc values */ 997de2103e4SAlex Deucher drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V); 998de2103e4SAlex Deucher 999771fe6b9SJerome Glisse } 1000771fe6b9SJerome Glisse } 10016fe7ac3fSAlex Deucher } else { 1002771fe6b9SJerome Glisse DRM_INFO("No panel info found in BIOS\n"); 10038dfaa8a7SMichel Dänzer lvds = radeon_legacy_get_lvds_info_from_regs(rdev); 10046fe7ac3fSAlex Deucher } 10058dfaa8a7SMichel Dänzer out: 10068dfaa8a7SMichel Dänzer if (lvds) 10078dfaa8a7SMichel Dänzer encoder->native_mode = lvds->native_mode; 1008771fe6b9SJerome Glisse return lvds; 1009771fe6b9SJerome Glisse } 1010771fe6b9SJerome Glisse 1011771fe6b9SJerome Glisse static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = { 1012771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */ 1013771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */ 1014771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */ 1015771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */ 1016771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */ 1017771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */ 1018771fe6b9SJerome Glisse {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */ 1019771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */ 1020771fe6b9SJerome Glisse {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */ 1021771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */ 1022771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */ 1023771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */ 1024771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */ 1025771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */ 1026771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */ 1027771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */ 1028fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */ 1029fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */ 1030771fe6b9SJerome Glisse }; 1031771fe6b9SJerome Glisse 1032445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder, 1033445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1034771fe6b9SJerome Glisse { 1035445282dbSDave Airlie struct drm_device *dev = encoder->base.dev; 1036445282dbSDave Airlie struct radeon_device *rdev = dev->dev_private; 1037771fe6b9SJerome Glisse int i; 1038771fe6b9SJerome Glisse 1039771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 1040771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1041771fe6b9SJerome Glisse default_tmds_pll[rdev->family][i].value; 1042771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq; 1043771fe6b9SJerome Glisse } 1044771fe6b9SJerome Glisse 1045445282dbSDave Airlie return true; 1046771fe6b9SJerome Glisse } 1047771fe6b9SJerome Glisse 1048445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder, 1049445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1050771fe6b9SJerome Glisse { 1051771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1052771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1053771fe6b9SJerome Glisse uint16_t tmds_info; 1054771fe6b9SJerome Glisse int i, n; 1055771fe6b9SJerome Glisse uint8_t ver; 1056771fe6b9SJerome Glisse 1057771fe6b9SJerome Glisse if (rdev->bios == NULL) 1058445282dbSDave Airlie return false; 1059771fe6b9SJerome Glisse 1060771fe6b9SJerome Glisse tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 1061771fe6b9SJerome Glisse 1062771fe6b9SJerome Glisse if (tmds_info) { 1063771fe6b9SJerome Glisse ver = RBIOS8(tmds_info); 1064771fe6b9SJerome Glisse DRM_INFO("DFP table revision: %d\n", ver); 1065771fe6b9SJerome Glisse if (ver == 3) { 1066771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1067771fe6b9SJerome Glisse if (n > 4) 1068771fe6b9SJerome Glisse n = 4; 1069771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1070771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1071771fe6b9SJerome Glisse RBIOS32(tmds_info + i * 10 + 0x08); 1072771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1073771fe6b9SJerome Glisse RBIOS16(tmds_info + i * 10 + 0x10); 1074771fe6b9SJerome Glisse DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n", 1075771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1076771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1077771fe6b9SJerome Glisse } 1078771fe6b9SJerome Glisse } else if (ver == 4) { 1079771fe6b9SJerome Glisse int stride = 0; 1080771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1081771fe6b9SJerome Glisse if (n > 4) 1082771fe6b9SJerome Glisse n = 4; 1083771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1084771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1085771fe6b9SJerome Glisse RBIOS32(tmds_info + stride + 0x08); 1086771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1087771fe6b9SJerome Glisse RBIOS16(tmds_info + stride + 0x10); 1088771fe6b9SJerome Glisse if (i == 0) 1089771fe6b9SJerome Glisse stride += 10; 1090771fe6b9SJerome Glisse else 1091771fe6b9SJerome Glisse stride += 6; 1092771fe6b9SJerome Glisse DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n", 1093771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1094771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1095771fe6b9SJerome Glisse } 1096771fe6b9SJerome Glisse } 1097fcec570bSAlex Deucher } else { 1098771fe6b9SJerome Glisse DRM_INFO("No TMDS info found in BIOS\n"); 1099fcec570bSAlex Deucher return false; 1100fcec570bSAlex Deucher } 1101445282dbSDave Airlie return true; 1102445282dbSDave Airlie } 1103445282dbSDave Airlie 1104fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder, 1105fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1106771fe6b9SJerome Glisse { 1107771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1108771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1109fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1110fcec570bSAlex Deucher 1111fcec570bSAlex Deucher /* default for macs */ 1112*6a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1113fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1114fcec570bSAlex Deucher 1115fcec570bSAlex Deucher /* XXX some macs have duallink chips */ 1116fcec570bSAlex Deucher switch (rdev->mode_info.connector_table) { 1117fcec570bSAlex Deucher case CT_POWERBOOK_EXTERNAL: 1118fcec570bSAlex Deucher case CT_MINI_EXTERNAL: 1119fcec570bSAlex Deucher default: 1120fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1121fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1122fcec570bSAlex Deucher break; 1123fcec570bSAlex Deucher } 1124fcec570bSAlex Deucher 1125fcec570bSAlex Deucher return true; 1126fcec570bSAlex Deucher } 1127fcec570bSAlex Deucher 1128fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder, 1129fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1130fcec570bSAlex Deucher { 1131fcec570bSAlex Deucher struct drm_device *dev = encoder->base.dev; 1132fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 1133fcec570bSAlex Deucher uint16_t offset; 1134fcec570bSAlex Deucher uint8_t ver, id, blocks, clk, data; 1135fcec570bSAlex Deucher int i; 1136fcec570bSAlex Deucher enum radeon_combios_ddc gpio; 1137fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1138771fe6b9SJerome Glisse 1139771fe6b9SJerome Glisse if (rdev->bios == NULL) 1140fcec570bSAlex Deucher return false; 1141771fe6b9SJerome Glisse 1142fcec570bSAlex Deucher tmds->i2c_bus = NULL; 1143fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 1144fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE); 1145fcec570bSAlex Deucher if (offset) { 1146fcec570bSAlex Deucher ver = RBIOS8(offset); 1147fcec570bSAlex Deucher DRM_INFO("GPIO Table revision: %d\n", ver); 1148fcec570bSAlex Deucher blocks = RBIOS8(offset + 2); 1149fcec570bSAlex Deucher for (i = 0; i < blocks; i++) { 1150fcec570bSAlex Deucher id = RBIOS8(offset + 3 + (i * 5) + 0); 1151fcec570bSAlex Deucher if (id == 136) { 1152fcec570bSAlex Deucher clk = RBIOS8(offset + 3 + (i * 5) + 3); 1153fcec570bSAlex Deucher data = RBIOS8(offset + 3 + (i * 5) + 4); 1154fcec570bSAlex Deucher i2c_bus.valid = true; 1155fcec570bSAlex Deucher i2c_bus.mask_clk_mask = (1 << clk); 1156fcec570bSAlex Deucher i2c_bus.mask_data_mask = (1 << data); 1157fcec570bSAlex Deucher i2c_bus.a_clk_mask = (1 << clk); 1158fcec570bSAlex Deucher i2c_bus.a_data_mask = (1 << data); 1159fcec570bSAlex Deucher i2c_bus.en_clk_mask = (1 << clk); 1160fcec570bSAlex Deucher i2c_bus.en_data_mask = (1 << data); 1161fcec570bSAlex Deucher i2c_bus.y_clk_mask = (1 << clk); 1162fcec570bSAlex Deucher i2c_bus.y_data_mask = (1 << data); 1163fcec570bSAlex Deucher i2c_bus.mask_clk_reg = RADEON_GPIOPAD_MASK; 1164fcec570bSAlex Deucher i2c_bus.mask_data_reg = RADEON_GPIOPAD_MASK; 1165fcec570bSAlex Deucher i2c_bus.a_clk_reg = RADEON_GPIOPAD_A; 1166fcec570bSAlex Deucher i2c_bus.a_data_reg = RADEON_GPIOPAD_A; 1167fcec570bSAlex Deucher i2c_bus.en_clk_reg = RADEON_GPIOPAD_EN; 1168fcec570bSAlex Deucher i2c_bus.en_data_reg = RADEON_GPIOPAD_EN; 1169fcec570bSAlex Deucher i2c_bus.y_clk_reg = RADEON_GPIOPAD_Y; 1170fcec570bSAlex Deucher i2c_bus.y_data_reg = RADEON_GPIOPAD_Y; 1171fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1172fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1173fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1174fcec570bSAlex Deucher break; 1175771fe6b9SJerome Glisse } 1176771fe6b9SJerome Glisse } 1177fcec570bSAlex Deucher } 1178fcec570bSAlex Deucher } else { 1179fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 1180fcec570bSAlex Deucher if (offset) { 1181fcec570bSAlex Deucher ver = RBIOS8(offset); 1182fcec570bSAlex Deucher DRM_INFO("External TMDS Table revision: %d\n", ver); 1183fcec570bSAlex Deucher tmds->slave_addr = RBIOS8(offset + 4 + 2); 1184fcec570bSAlex Deucher tmds->slave_addr >>= 1; /* 7 bit addressing */ 1185fcec570bSAlex Deucher gpio = RBIOS8(offset + 4 + 3); 1186fcec570bSAlex Deucher switch (gpio) { 1187fcec570bSAlex Deucher case DDC_MONID: 1188*6a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1189fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1190fcec570bSAlex Deucher break; 1191fcec570bSAlex Deucher case DDC_DVI: 1192*6a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1193fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1194fcec570bSAlex Deucher break; 1195fcec570bSAlex Deucher case DDC_VGA: 1196*6a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1197fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1198fcec570bSAlex Deucher break; 1199fcec570bSAlex Deucher case DDC_CRT2: 1200fcec570bSAlex Deucher /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */ 1201fcec570bSAlex Deucher if (rdev->family >= CHIP_R300) 1202*6a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1203fcec570bSAlex Deucher else 1204*6a93cb25SAlex Deucher i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); 1205fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1206fcec570bSAlex Deucher break; 1207fcec570bSAlex Deucher case DDC_LCD: /* MM i2c */ 1208fcec570bSAlex Deucher DRM_ERROR("MM i2c requires hw i2c engine\n"); 1209fcec570bSAlex Deucher break; 1210fcec570bSAlex Deucher default: 1211fcec570bSAlex Deucher DRM_ERROR("Unsupported gpio %d\n", gpio); 1212fcec570bSAlex Deucher break; 1213fcec570bSAlex Deucher } 1214fcec570bSAlex Deucher } 1215fcec570bSAlex Deucher } 1216fcec570bSAlex Deucher 1217fcec570bSAlex Deucher if (!tmds->i2c_bus) { 1218fcec570bSAlex Deucher DRM_INFO("No valid Ext TMDS info found in BIOS\n"); 1219fcec570bSAlex Deucher return false; 1220fcec570bSAlex Deucher } 1221fcec570bSAlex Deucher 1222fcec570bSAlex Deucher return true; 1223fcec570bSAlex Deucher } 1224771fe6b9SJerome Glisse 1225771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) 1226771fe6b9SJerome Glisse { 1227771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1228771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 1229771fe6b9SJerome Glisse 1230771fe6b9SJerome Glisse rdev->mode_info.connector_table = radeon_connector_table; 1231771fe6b9SJerome Glisse if (rdev->mode_info.connector_table == CT_NONE) { 1232771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 1233771fe6b9SJerome Glisse if (machine_is_compatible("PowerBook3,3")) { 1234771fe6b9SJerome Glisse /* powerbook with VGA */ 1235771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_VGA; 1236771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook3,4") || 1237771fe6b9SJerome Glisse machine_is_compatible("PowerBook3,5")) { 1238771fe6b9SJerome Glisse /* powerbook with internal tmds */ 1239771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; 1240771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook5,1") || 1241771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,2") || 1242771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,3") || 1243771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,4") || 1244771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,5")) { 1245771fe6b9SJerome Glisse /* powerbook with external single link tmds (sil164) */ 1246771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 1247771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook5,6")) { 1248771fe6b9SJerome Glisse /* powerbook with external dual or single link tmds */ 1249771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 1250771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook5,7") || 1251771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,8") || 1252771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,9")) { 1253771fe6b9SJerome Glisse /* PowerBook6,2 ? */ 1254771fe6b9SJerome Glisse /* powerbook with external dual link tmds (sil1178?) */ 1255771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 1256771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook4,1") || 1257771fe6b9SJerome Glisse machine_is_compatible("PowerBook4,2") || 1258771fe6b9SJerome Glisse machine_is_compatible("PowerBook4,3") || 1259771fe6b9SJerome Glisse machine_is_compatible("PowerBook6,3") || 1260771fe6b9SJerome Glisse machine_is_compatible("PowerBook6,5") || 1261771fe6b9SJerome Glisse machine_is_compatible("PowerBook6,7")) { 1262771fe6b9SJerome Glisse /* ibook */ 1263771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IBOOK; 1264771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac4,4")) { 1265771fe6b9SJerome Glisse /* emac */ 1266771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_EMAC; 1267771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac10,1")) { 1268771fe6b9SJerome Glisse /* mini with internal tmds */ 1269771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_INTERNAL; 1270771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac10,2")) { 1271771fe6b9SJerome Glisse /* mini with external tmds */ 1272771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_EXTERNAL; 1273771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac12,1")) { 1274771fe6b9SJerome Glisse /* PowerMac8,1 ? */ 1275771fe6b9SJerome Glisse /* imac g5 isight */ 1276771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; 1277771fe6b9SJerome Glisse } else 1278771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 1279771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_GENERIC; 1280771fe6b9SJerome Glisse } 1281771fe6b9SJerome Glisse 1282771fe6b9SJerome Glisse switch (rdev->mode_info.connector_table) { 1283771fe6b9SJerome Glisse case CT_GENERIC: 1284771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (generic)\n", 1285771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1286771fe6b9SJerome Glisse /* these are the most common settings */ 1287771fe6b9SJerome Glisse if (rdev->flags & RADEON_SINGLE_CRTC) { 1288771fe6b9SJerome Glisse /* VGA - primary dac */ 1289*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1290771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1291771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1292771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1293771fe6b9SJerome Glisse 1), 1294771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1295771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1296771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1297771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1298b75fad06SAlex Deucher &ddc_i2c, 1299b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1300771fe6b9SJerome Glisse } else if (rdev->flags & RADEON_IS_MOBILITY) { 1301771fe6b9SJerome Glisse /* LVDS */ 1302*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, 0); 1303771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1304771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1305771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1306771fe6b9SJerome Glisse 0), 1307771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1308771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1309771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1310771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 1311b75fad06SAlex Deucher &ddc_i2c, 1312b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_LVDS); 1313771fe6b9SJerome Glisse 1314771fe6b9SJerome Glisse /* VGA - primary dac */ 1315*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1316771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1317771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1318771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1319771fe6b9SJerome Glisse 1), 1320771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1321771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1322771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1323771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1324b75fad06SAlex Deucher &ddc_i2c, 1325b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1326771fe6b9SJerome Glisse } else { 1327771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1328*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1329771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1330771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1331771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1332771fe6b9SJerome Glisse 0), 1333771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1334771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1335771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1336771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1337771fe6b9SJerome Glisse 2), 1338771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1339771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1340771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1341771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1342771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 1343b75fad06SAlex Deucher &ddc_i2c, 1344b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I); 1345771fe6b9SJerome Glisse 1346771fe6b9SJerome Glisse /* VGA - primary dac */ 1347*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1348771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1349771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1350771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1351771fe6b9SJerome Glisse 1), 1352771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1353771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1354771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1355771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1356b75fad06SAlex Deucher &ddc_i2c, 1357b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1358771fe6b9SJerome Glisse } 1359771fe6b9SJerome Glisse 1360771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 1361771fe6b9SJerome Glisse /* TV - tv dac */ 1362771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1363771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1364771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1365771fe6b9SJerome Glisse 2), 1366771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1367771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, 1368771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1369771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1370b75fad06SAlex Deucher &ddc_i2c, 1371b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1372771fe6b9SJerome Glisse } 1373771fe6b9SJerome Glisse break; 1374771fe6b9SJerome Glisse case CT_IBOOK: 1375771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (ibook)\n", 1376771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1377771fe6b9SJerome Glisse /* LVDS */ 1378*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1379771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1380771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1381771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1382771fe6b9SJerome Glisse 0), 1383771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1384771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1385b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1386b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_LVDS); 1387771fe6b9SJerome Glisse /* VGA - TV DAC */ 1388*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1389771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1390771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1391771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1392771fe6b9SJerome Glisse 2), 1393771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1394771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1395b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1396b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1397771fe6b9SJerome Glisse /* TV - TV DAC */ 1398771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1399771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1400771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1401771fe6b9SJerome Glisse 2), 1402771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1403771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1404771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1405b75fad06SAlex Deucher &ddc_i2c, 1406b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1407771fe6b9SJerome Glisse break; 1408771fe6b9SJerome Glisse case CT_POWERBOOK_EXTERNAL: 1409771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook external tmds)\n", 1410771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1411771fe6b9SJerome Glisse /* LVDS */ 1412*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1413771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1414771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1415771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1416771fe6b9SJerome Glisse 0), 1417771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1418771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1419b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1420b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_LVDS); 1421771fe6b9SJerome Glisse /* DVI-I - primary dac, ext tmds */ 1422*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1423771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1424771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1425771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1426771fe6b9SJerome Glisse 0), 1427771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1428771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1429771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1430771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1431771fe6b9SJerome Glisse 1), 1432771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1433b75fad06SAlex Deucher /* XXX some are SL */ 1434771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1435771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1436771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1437b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1438b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I); 1439771fe6b9SJerome Glisse /* TV - TV DAC */ 1440771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1441771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1442771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1443771fe6b9SJerome Glisse 2), 1444771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1445771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1446771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1447b75fad06SAlex Deucher &ddc_i2c, 1448b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1449771fe6b9SJerome Glisse break; 1450771fe6b9SJerome Glisse case CT_POWERBOOK_INTERNAL: 1451771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook internal tmds)\n", 1452771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1453771fe6b9SJerome Glisse /* LVDS */ 1454*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1455771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1456771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1457771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1458771fe6b9SJerome Glisse 0), 1459771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1460771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1461b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1462b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_LVDS); 1463771fe6b9SJerome Glisse /* DVI-I - primary dac, int tmds */ 1464*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1465771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1466771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1467771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1468771fe6b9SJerome Glisse 0), 1469771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1470771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1471771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1472771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1473771fe6b9SJerome Glisse 1), 1474771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1475771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1476771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1477771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1478b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1479b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I); 1480771fe6b9SJerome Glisse /* TV - TV DAC */ 1481771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1482771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1483771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1484771fe6b9SJerome Glisse 2), 1485771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1486771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1487771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1488b75fad06SAlex Deucher &ddc_i2c, 1489b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1490771fe6b9SJerome Glisse break; 1491771fe6b9SJerome Glisse case CT_POWERBOOK_VGA: 1492771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook vga)\n", 1493771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1494771fe6b9SJerome Glisse /* LVDS */ 1495*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1496771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1497771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1498771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1499771fe6b9SJerome Glisse 0), 1500771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1501771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1502b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1503b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_LVDS); 1504771fe6b9SJerome Glisse /* VGA - primary dac */ 1505*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1506771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1507771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1508771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1509771fe6b9SJerome Glisse 1), 1510771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1511771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT, 1512b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1513b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1514771fe6b9SJerome Glisse /* TV - TV DAC */ 1515771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1516771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1517771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1518771fe6b9SJerome Glisse 2), 1519771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1520771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1521771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1522b75fad06SAlex Deucher &ddc_i2c, 1523b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1524771fe6b9SJerome Glisse break; 1525771fe6b9SJerome Glisse case CT_MINI_EXTERNAL: 1526771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini external tmds)\n", 1527771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1528771fe6b9SJerome Glisse /* DVI-I - tv dac, ext tmds */ 1529*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); 1530771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1531771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1532771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1533771fe6b9SJerome Glisse 0), 1534771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1535771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1536771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1537771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1538771fe6b9SJerome Glisse 2), 1539771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1540b75fad06SAlex Deucher /* XXX are any DL? */ 1541771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1542771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1543771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1544b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1545b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I); 1546771fe6b9SJerome Glisse /* TV - TV DAC */ 1547771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1548771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1549771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1550771fe6b9SJerome Glisse 2), 1551771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1552771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1553771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1554b75fad06SAlex Deucher &ddc_i2c, 1555b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1556771fe6b9SJerome Glisse break; 1557771fe6b9SJerome Glisse case CT_MINI_INTERNAL: 1558771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini internal tmds)\n", 1559771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1560771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1561*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); 1562771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1563771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1564771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1565771fe6b9SJerome Glisse 0), 1566771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1567771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1568771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1569771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1570771fe6b9SJerome Glisse 2), 1571771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1572771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1573771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1574771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1575b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1576b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I); 1577771fe6b9SJerome Glisse /* TV - TV DAC */ 1578771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1579771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1580771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1581771fe6b9SJerome Glisse 2), 1582771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1583771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1584771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1585b75fad06SAlex Deucher &ddc_i2c, 1586b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1587771fe6b9SJerome Glisse break; 1588771fe6b9SJerome Glisse case CT_IMAC_G5_ISIGHT: 1589771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (imac g5 isight)\n", 1590771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1591771fe6b9SJerome Glisse /* DVI-D - int tmds */ 1592*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1593771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1594771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1595771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1596771fe6b9SJerome Glisse 0), 1597771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1598771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT, 1599b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVID, &ddc_i2c, 1600b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D); 1601771fe6b9SJerome Glisse /* VGA - tv dac */ 1602*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1603771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1604771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1605771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1606771fe6b9SJerome Glisse 2), 1607771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1608771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1609b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1610b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1611771fe6b9SJerome Glisse /* TV - TV DAC */ 1612771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1613771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1614771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1615771fe6b9SJerome Glisse 2), 1616771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1617771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1618771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1619b75fad06SAlex Deucher &ddc_i2c, 1620b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1621771fe6b9SJerome Glisse break; 1622771fe6b9SJerome Glisse case CT_EMAC: 1623771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (emac)\n", 1624771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1625771fe6b9SJerome Glisse /* VGA - primary dac */ 1626*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1627771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1628771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1629771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1630771fe6b9SJerome Glisse 1), 1631771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1632771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 1633b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1634b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1635771fe6b9SJerome Glisse /* VGA - tv dac */ 1636*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); 1637771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1638771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1639771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1640771fe6b9SJerome Glisse 2), 1641771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1642771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1643b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1644b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1645771fe6b9SJerome Glisse /* TV - TV DAC */ 1646771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1647771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1648771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1649771fe6b9SJerome Glisse 2), 1650771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1651771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1652771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1653b75fad06SAlex Deucher &ddc_i2c, 1654b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1655771fe6b9SJerome Glisse break; 1656771fe6b9SJerome Glisse default: 1657771fe6b9SJerome Glisse DRM_INFO("Connector table: %d (invalid)\n", 1658771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1659771fe6b9SJerome Glisse return false; 1660771fe6b9SJerome Glisse } 1661771fe6b9SJerome Glisse 1662771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 1663771fe6b9SJerome Glisse 1664771fe6b9SJerome Glisse return true; 1665771fe6b9SJerome Glisse } 1666771fe6b9SJerome Glisse 1667771fe6b9SJerome Glisse static bool radeon_apply_legacy_quirks(struct drm_device *dev, 1668771fe6b9SJerome Glisse int bios_index, 1669771fe6b9SJerome Glisse enum radeon_combios_connector 1670771fe6b9SJerome Glisse *legacy_connector, 1671771fe6b9SJerome Glisse struct radeon_i2c_bus_rec *ddc_i2c) 1672771fe6b9SJerome Glisse { 1673771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1674771fe6b9SJerome Glisse 1675771fe6b9SJerome Glisse /* XPRESS DDC quirks */ 1676771fe6b9SJerome Glisse if ((rdev->family == CHIP_RS400 || 1677771fe6b9SJerome Glisse rdev->family == CHIP_RS480) && 1678771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 1679*6a93cb25SAlex Deucher *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1680771fe6b9SJerome Glisse else if ((rdev->family == CHIP_RS400 || 1681771fe6b9SJerome Glisse rdev->family == CHIP_RS480) && 1682771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_MONID) { 1683*6a93cb25SAlex Deucher *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIOPAD_MASK); 1684771fe6b9SJerome Glisse ddc_i2c->mask_clk_mask = (0x20 << 8); 1685771fe6b9SJerome Glisse ddc_i2c->mask_data_mask = 0x80; 1686771fe6b9SJerome Glisse ddc_i2c->a_clk_mask = (0x20 << 8); 1687771fe6b9SJerome Glisse ddc_i2c->a_data_mask = 0x80; 16889b9fe724SAlex Deucher ddc_i2c->en_clk_mask = (0x20 << 8); 16899b9fe724SAlex Deucher ddc_i2c->en_data_mask = 0x80; 16909b9fe724SAlex Deucher ddc_i2c->y_clk_mask = (0x20 << 8); 16919b9fe724SAlex Deucher ddc_i2c->y_data_mask = 0x80; 1692771fe6b9SJerome Glisse } 1693771fe6b9SJerome Glisse 1694fcec570bSAlex Deucher /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */ 1695fcec570bSAlex Deucher if ((rdev->family >= CHIP_R300) && 1696fcec570bSAlex Deucher ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 1697*6a93cb25SAlex Deucher *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1698fcec570bSAlex Deucher 1699771fe6b9SJerome Glisse /* Certain IBM chipset RN50s have a BIOS reporting two VGAs, 1700771fe6b9SJerome Glisse one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */ 1701771fe6b9SJerome Glisse if (dev->pdev->device == 0x515e && 1702771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x1014) { 1703771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_CRT_LEGACY && 1704771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 1705771fe6b9SJerome Glisse return false; 1706771fe6b9SJerome Glisse } 1707771fe6b9SJerome Glisse 1708771fe6b9SJerome Glisse /* Some RV100 cards with 2 VGA ports show up with DVI+VGA */ 1709771fe6b9SJerome Glisse if (dev->pdev->device == 0x5159 && 1710771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x1002 && 1711771fe6b9SJerome Glisse dev->pdev->subsystem_device == 0x013a) { 1712771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_DVI_I_LEGACY) 1713771fe6b9SJerome Glisse *legacy_connector = CONNECTOR_CRT_LEGACY; 1714771fe6b9SJerome Glisse 1715771fe6b9SJerome Glisse } 1716771fe6b9SJerome Glisse 1717771fe6b9SJerome Glisse /* X300 card with extra non-existent DVI port */ 1718771fe6b9SJerome Glisse if (dev->pdev->device == 0x5B60 && 1719771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x17af && 1720771fe6b9SJerome Glisse dev->pdev->subsystem_device == 0x201e && bios_index == 2) { 1721771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_DVI_I_LEGACY) 1722771fe6b9SJerome Glisse return false; 1723771fe6b9SJerome Glisse } 1724771fe6b9SJerome Glisse 1725771fe6b9SJerome Glisse return true; 1726771fe6b9SJerome Glisse } 1727771fe6b9SJerome Glisse 1728790cfb34SAlex Deucher static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev) 1729790cfb34SAlex Deucher { 1730790cfb34SAlex Deucher /* Acer 5102 has non-existent TV port */ 1731790cfb34SAlex Deucher if (dev->pdev->device == 0x5975 && 1732790cfb34SAlex Deucher dev->pdev->subsystem_vendor == 0x1025 && 1733790cfb34SAlex Deucher dev->pdev->subsystem_device == 0x009f) 1734790cfb34SAlex Deucher return false; 1735790cfb34SAlex Deucher 1736fc7f7119SAlex Deucher /* HP dc5750 has non-existent TV port */ 1737fc7f7119SAlex Deucher if (dev->pdev->device == 0x5974 && 1738fc7f7119SAlex Deucher dev->pdev->subsystem_vendor == 0x103c && 1739fc7f7119SAlex Deucher dev->pdev->subsystem_device == 0x280a) 1740fc7f7119SAlex Deucher return false; 1741fc7f7119SAlex Deucher 1742fd874ad0SAlex Deucher /* MSI S270 has non-existent TV port */ 1743fd874ad0SAlex Deucher if (dev->pdev->device == 0x5955 && 1744fd874ad0SAlex Deucher dev->pdev->subsystem_vendor == 0x1462 && 1745fd874ad0SAlex Deucher dev->pdev->subsystem_device == 0x0131) 1746fd874ad0SAlex Deucher return false; 1747fd874ad0SAlex Deucher 1748790cfb34SAlex Deucher return true; 1749790cfb34SAlex Deucher } 1750790cfb34SAlex Deucher 1751b75fad06SAlex Deucher static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d) 1752b75fad06SAlex Deucher { 1753b75fad06SAlex Deucher struct radeon_device *rdev = dev->dev_private; 1754b75fad06SAlex Deucher uint32_t ext_tmds_info; 1755b75fad06SAlex Deucher 1756b75fad06SAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 1757b75fad06SAlex Deucher if (is_dvi_d) 1758b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 1759b75fad06SAlex Deucher else 1760b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 1761b75fad06SAlex Deucher } 1762b75fad06SAlex Deucher ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 1763b75fad06SAlex Deucher if (ext_tmds_info) { 1764b75fad06SAlex Deucher uint8_t rev = RBIOS8(ext_tmds_info); 1765b75fad06SAlex Deucher uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5); 1766b75fad06SAlex Deucher if (rev >= 3) { 1767b75fad06SAlex Deucher if (is_dvi_d) 1768b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 1769b75fad06SAlex Deucher else 1770b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 1771b75fad06SAlex Deucher } else { 1772b75fad06SAlex Deucher if (flags & 1) { 1773b75fad06SAlex Deucher if (is_dvi_d) 1774b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 1775b75fad06SAlex Deucher else 1776b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 1777b75fad06SAlex Deucher } 1778b75fad06SAlex Deucher } 1779b75fad06SAlex Deucher } 1780b75fad06SAlex Deucher if (is_dvi_d) 1781b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 1782b75fad06SAlex Deucher else 1783b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 1784b75fad06SAlex Deucher } 1785b75fad06SAlex Deucher 1786771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) 1787771fe6b9SJerome Glisse { 1788771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1789771fe6b9SJerome Glisse uint32_t conn_info, entry, devices; 1790b75fad06SAlex Deucher uint16_t tmp, connector_object_id; 1791771fe6b9SJerome Glisse enum radeon_combios_ddc ddc_type; 1792771fe6b9SJerome Glisse enum radeon_combios_connector connector; 1793771fe6b9SJerome Glisse int i = 0; 1794771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 1795771fe6b9SJerome Glisse 1796771fe6b9SJerome Glisse if (rdev->bios == NULL) 1797771fe6b9SJerome Glisse return false; 1798771fe6b9SJerome Glisse 1799771fe6b9SJerome Glisse conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE); 1800771fe6b9SJerome Glisse if (conn_info) { 1801771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 1802771fe6b9SJerome Glisse entry = conn_info + 2 + i * 2; 1803771fe6b9SJerome Glisse 1804771fe6b9SJerome Glisse if (!RBIOS16(entry)) 1805771fe6b9SJerome Glisse break; 1806771fe6b9SJerome Glisse 1807771fe6b9SJerome Glisse tmp = RBIOS16(entry); 1808771fe6b9SJerome Glisse 1809771fe6b9SJerome Glisse connector = (tmp >> 12) & 0xf; 1810771fe6b9SJerome Glisse 1811771fe6b9SJerome Glisse ddc_type = (tmp >> 8) & 0xf; 1812771fe6b9SJerome Glisse switch (ddc_type) { 1813771fe6b9SJerome Glisse case DDC_MONID: 1814771fe6b9SJerome Glisse ddc_i2c = 1815*6a93cb25SAlex Deucher combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); 1816771fe6b9SJerome Glisse break; 1817771fe6b9SJerome Glisse case DDC_DVI: 1818771fe6b9SJerome Glisse ddc_i2c = 1819*6a93cb25SAlex Deucher combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1820771fe6b9SJerome Glisse break; 1821771fe6b9SJerome Glisse case DDC_VGA: 1822771fe6b9SJerome Glisse ddc_i2c = 1823*6a93cb25SAlex Deucher combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 1824771fe6b9SJerome Glisse break; 1825771fe6b9SJerome Glisse case DDC_CRT2: 1826771fe6b9SJerome Glisse ddc_i2c = 1827*6a93cb25SAlex Deucher combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); 1828771fe6b9SJerome Glisse break; 1829771fe6b9SJerome Glisse default: 1830771fe6b9SJerome Glisse break; 1831771fe6b9SJerome Glisse } 1832771fe6b9SJerome Glisse 18332d152c6bSAlex Deucher if (!radeon_apply_legacy_quirks(dev, i, &connector, 18342d152c6bSAlex Deucher &ddc_i2c)) 18352d152c6bSAlex Deucher continue; 1836771fe6b9SJerome Glisse 1837771fe6b9SJerome Glisse switch (connector) { 1838771fe6b9SJerome Glisse case CONNECTOR_PROPRIETARY_LEGACY: 1839771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) 1840771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 1841771fe6b9SJerome Glisse else 1842771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 1843771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1844771fe6b9SJerome Glisse radeon_get_encoder_id 1845771fe6b9SJerome Glisse (dev, devices, 0), 1846771fe6b9SJerome Glisse devices); 1847771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 1848771fe6b9SJerome Glisse legacy_connector_convert 1849771fe6b9SJerome Glisse [connector], 1850b75fad06SAlex Deucher &ddc_i2c, 1851b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D); 1852771fe6b9SJerome Glisse break; 1853771fe6b9SJerome Glisse case CONNECTOR_CRT_LEGACY: 1854771fe6b9SJerome Glisse if (tmp & 0x1) { 1855771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT2_SUPPORT; 1856771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1857771fe6b9SJerome Glisse radeon_get_encoder_id 1858771fe6b9SJerome Glisse (dev, 1859771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1860771fe6b9SJerome Glisse 2), 1861771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1862771fe6b9SJerome Glisse } else { 1863771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT1_SUPPORT; 1864771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1865771fe6b9SJerome Glisse radeon_get_encoder_id 1866771fe6b9SJerome Glisse (dev, 1867771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1868771fe6b9SJerome Glisse 1), 1869771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1870771fe6b9SJerome Glisse } 1871771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1872771fe6b9SJerome Glisse i, 1873771fe6b9SJerome Glisse devices, 1874771fe6b9SJerome Glisse legacy_connector_convert 1875771fe6b9SJerome Glisse [connector], 1876b75fad06SAlex Deucher &ddc_i2c, 1877b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1878771fe6b9SJerome Glisse break; 1879771fe6b9SJerome Glisse case CONNECTOR_DVI_I_LEGACY: 1880771fe6b9SJerome Glisse devices = 0; 1881771fe6b9SJerome Glisse if (tmp & 0x1) { 1882771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT2_SUPPORT; 1883771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1884771fe6b9SJerome Glisse radeon_get_encoder_id 1885771fe6b9SJerome Glisse (dev, 1886771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1887771fe6b9SJerome Glisse 2), 1888771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1889771fe6b9SJerome Glisse } else { 1890771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT1_SUPPORT; 1891771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1892771fe6b9SJerome Glisse radeon_get_encoder_id 1893771fe6b9SJerome Glisse (dev, 1894771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1895771fe6b9SJerome Glisse 1), 1896771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1897771fe6b9SJerome Glisse } 1898771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) { 1899771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP2_SUPPORT; 1900771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1901771fe6b9SJerome Glisse radeon_get_encoder_id 1902771fe6b9SJerome Glisse (dev, 1903771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1904771fe6b9SJerome Glisse 0), 1905771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1906b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 0); 1907771fe6b9SJerome Glisse } else { 1908771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP1_SUPPORT; 1909771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1910771fe6b9SJerome Glisse radeon_get_encoder_id 1911771fe6b9SJerome Glisse (dev, 1912771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1913771fe6b9SJerome Glisse 0), 1914771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1915b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 1916771fe6b9SJerome Glisse } 1917771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1918771fe6b9SJerome Glisse i, 1919771fe6b9SJerome Glisse devices, 1920771fe6b9SJerome Glisse legacy_connector_convert 1921771fe6b9SJerome Glisse [connector], 1922b75fad06SAlex Deucher &ddc_i2c, 1923b75fad06SAlex Deucher connector_object_id); 1924771fe6b9SJerome Glisse break; 1925771fe6b9SJerome Glisse case CONNECTOR_DVI_D_LEGACY: 1926b75fad06SAlex Deucher if ((tmp >> 4) & 0x1) { 1927771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 1928b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 1); 1929b75fad06SAlex Deucher } else { 1930771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 1931b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 1932b75fad06SAlex Deucher } 1933771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1934771fe6b9SJerome Glisse radeon_get_encoder_id 1935771fe6b9SJerome Glisse (dev, devices, 0), 1936771fe6b9SJerome Glisse devices); 1937771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 1938771fe6b9SJerome Glisse legacy_connector_convert 1939771fe6b9SJerome Glisse [connector], 1940b75fad06SAlex Deucher &ddc_i2c, 1941b75fad06SAlex Deucher connector_object_id); 1942771fe6b9SJerome Glisse break; 1943771fe6b9SJerome Glisse case CONNECTOR_CTV_LEGACY: 1944771fe6b9SJerome Glisse case CONNECTOR_STV_LEGACY: 1945771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1946771fe6b9SJerome Glisse radeon_get_encoder_id 1947771fe6b9SJerome Glisse (dev, 1948771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1949771fe6b9SJerome Glisse 2), 1950771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1951771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, 1952771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1953771fe6b9SJerome Glisse legacy_connector_convert 1954771fe6b9SJerome Glisse [connector], 1955b75fad06SAlex Deucher &ddc_i2c, 1956b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1957771fe6b9SJerome Glisse break; 1958771fe6b9SJerome Glisse default: 1959771fe6b9SJerome Glisse DRM_ERROR("Unknown connector type: %d\n", 1960771fe6b9SJerome Glisse connector); 1961771fe6b9SJerome Glisse continue; 1962771fe6b9SJerome Glisse } 1963771fe6b9SJerome Glisse 1964771fe6b9SJerome Glisse } 1965771fe6b9SJerome Glisse } else { 1966771fe6b9SJerome Glisse uint16_t tmds_info = 1967771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 1968771fe6b9SJerome Glisse if (tmds_info) { 1969771fe6b9SJerome Glisse DRM_DEBUG("Found DFP table, assuming DVI connector\n"); 1970771fe6b9SJerome Glisse 1971771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1972771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1973771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1974771fe6b9SJerome Glisse 1), 1975771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1976771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1977771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1978771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1979771fe6b9SJerome Glisse 0), 1980771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1981771fe6b9SJerome Glisse 1982*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); 1983771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1984771fe6b9SJerome Glisse 0, 1985771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT | 1986771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1987771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 1988b75fad06SAlex Deucher &ddc_i2c, 1989b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I); 1990771fe6b9SJerome Glisse } else { 1991d0c403e9SAlex Deucher uint16_t crt_info = 1992d0c403e9SAlex Deucher combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 1993d0c403e9SAlex Deucher DRM_DEBUG("Found CRT table, assuming VGA connector\n"); 1994d0c403e9SAlex Deucher if (crt_info) { 1995d0c403e9SAlex Deucher radeon_add_legacy_encoder(dev, 1996d0c403e9SAlex Deucher radeon_get_encoder_id(dev, 1997d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 1998d0c403e9SAlex Deucher 1), 1999d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 2000*6a93cb25SAlex Deucher ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); 2001d0c403e9SAlex Deucher radeon_add_legacy_connector(dev, 2002d0c403e9SAlex Deucher 0, 2003d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 2004d0c403e9SAlex Deucher DRM_MODE_CONNECTOR_VGA, 2005b75fad06SAlex Deucher &ddc_i2c, 2006b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 2007d0c403e9SAlex Deucher } else { 2008771fe6b9SJerome Glisse DRM_DEBUG("No connector info found\n"); 2009771fe6b9SJerome Glisse return false; 2010771fe6b9SJerome Glisse } 2011771fe6b9SJerome Glisse } 2012d0c403e9SAlex Deucher } 2013771fe6b9SJerome Glisse 2014771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) { 2015771fe6b9SJerome Glisse uint16_t lcd_info = 2016771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 2017771fe6b9SJerome Glisse if (lcd_info) { 2018771fe6b9SJerome Glisse uint16_t lcd_ddc_info = 2019771fe6b9SJerome Glisse combios_get_table_offset(dev, 2020771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE); 2021771fe6b9SJerome Glisse 2022771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2023771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 2024771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2025771fe6b9SJerome Glisse 0), 2026771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 2027771fe6b9SJerome Glisse 2028771fe6b9SJerome Glisse if (lcd_ddc_info) { 2029771fe6b9SJerome Glisse ddc_type = RBIOS8(lcd_ddc_info + 2); 2030771fe6b9SJerome Glisse switch (ddc_type) { 2031771fe6b9SJerome Glisse case DDC_MONID: 2032771fe6b9SJerome Glisse ddc_i2c = 2033771fe6b9SJerome Glisse combios_setup_i2c_bus 2034*6a93cb25SAlex Deucher (rdev, RADEON_GPIO_MONID); 2035771fe6b9SJerome Glisse break; 2036771fe6b9SJerome Glisse case DDC_DVI: 2037771fe6b9SJerome Glisse ddc_i2c = 2038771fe6b9SJerome Glisse combios_setup_i2c_bus 2039*6a93cb25SAlex Deucher (rdev, RADEON_GPIO_DVI_DDC); 2040771fe6b9SJerome Glisse break; 2041771fe6b9SJerome Glisse case DDC_VGA: 2042771fe6b9SJerome Glisse ddc_i2c = 2043771fe6b9SJerome Glisse combios_setup_i2c_bus 2044*6a93cb25SAlex Deucher (rdev, RADEON_GPIO_VGA_DDC); 2045771fe6b9SJerome Glisse break; 2046771fe6b9SJerome Glisse case DDC_CRT2: 2047771fe6b9SJerome Glisse ddc_i2c = 2048771fe6b9SJerome Glisse combios_setup_i2c_bus 2049*6a93cb25SAlex Deucher (rdev, RADEON_GPIO_CRT2_DDC); 2050771fe6b9SJerome Glisse break; 2051771fe6b9SJerome Glisse case DDC_LCD: 2052771fe6b9SJerome Glisse ddc_i2c = 2053771fe6b9SJerome Glisse combios_setup_i2c_bus 2054*6a93cb25SAlex Deucher (rdev, RADEON_GPIOPAD_MASK); 2055771fe6b9SJerome Glisse ddc_i2c.mask_clk_mask = 2056771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2057771fe6b9SJerome Glisse ddc_i2c.mask_data_mask = 2058771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2059771fe6b9SJerome Glisse ddc_i2c.a_clk_mask = 2060771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2061771fe6b9SJerome Glisse ddc_i2c.a_data_mask = 2062771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 20639b9fe724SAlex Deucher ddc_i2c.en_clk_mask = 2064771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 20659b9fe724SAlex Deucher ddc_i2c.en_data_mask = 2066771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 20679b9fe724SAlex Deucher ddc_i2c.y_clk_mask = 2068771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 20699b9fe724SAlex Deucher ddc_i2c.y_data_mask = 2070771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2071771fe6b9SJerome Glisse break; 2072771fe6b9SJerome Glisse case DDC_GPIO: 2073771fe6b9SJerome Glisse ddc_i2c = 2074771fe6b9SJerome Glisse combios_setup_i2c_bus 2075*6a93cb25SAlex Deucher (rdev, RADEON_MDGPIO_MASK); 2076771fe6b9SJerome Glisse ddc_i2c.mask_clk_mask = 2077771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2078771fe6b9SJerome Glisse ddc_i2c.mask_data_mask = 2079771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2080771fe6b9SJerome Glisse ddc_i2c.a_clk_mask = 2081771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2082771fe6b9SJerome Glisse ddc_i2c.a_data_mask = 2083771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 20849b9fe724SAlex Deucher ddc_i2c.en_clk_mask = 2085771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 20869b9fe724SAlex Deucher ddc_i2c.en_data_mask = 2087771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 20889b9fe724SAlex Deucher ddc_i2c.y_clk_mask = 2089771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 20909b9fe724SAlex Deucher ddc_i2c.y_data_mask = 2091771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2092771fe6b9SJerome Glisse break; 2093771fe6b9SJerome Glisse default: 2094771fe6b9SJerome Glisse ddc_i2c.valid = false; 2095771fe6b9SJerome Glisse break; 2096771fe6b9SJerome Glisse } 2097771fe6b9SJerome Glisse DRM_DEBUG("LCD DDC Info Table found!\n"); 2098771fe6b9SJerome Glisse } else 2099771fe6b9SJerome Glisse ddc_i2c.valid = false; 2100771fe6b9SJerome Glisse 2101771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2102771fe6b9SJerome Glisse 5, 2103771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2104771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 2105b75fad06SAlex Deucher &ddc_i2c, 2106b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_LVDS); 2107771fe6b9SJerome Glisse } 2108771fe6b9SJerome Glisse } 2109771fe6b9SJerome Glisse 2110771fe6b9SJerome Glisse /* check TV table */ 2111771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 2112771fe6b9SJerome Glisse uint32_t tv_info = 2113771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 2114771fe6b9SJerome Glisse if (tv_info) { 2115771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 2116790cfb34SAlex Deucher if (radeon_apply_legacy_tv_quirks(dev)) { 2117771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2118771fe6b9SJerome Glisse radeon_get_encoder_id 2119771fe6b9SJerome Glisse (dev, 2120771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2121771fe6b9SJerome Glisse 2), 2122771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2123771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 6, 2124771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2125771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 2126b75fad06SAlex Deucher &ddc_i2c, 2127b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 2128771fe6b9SJerome Glisse } 2129771fe6b9SJerome Glisse } 2130771fe6b9SJerome Glisse } 2131790cfb34SAlex Deucher } 2132771fe6b9SJerome Glisse 2133771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2134771fe6b9SJerome Glisse 2135771fe6b9SJerome Glisse return true; 2136771fe6b9SJerome Glisse } 2137771fe6b9SJerome Glisse 2138fcec570bSAlex Deucher void radeon_external_tmds_setup(struct drm_encoder *encoder) 2139fcec570bSAlex Deucher { 2140fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2141fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2142fcec570bSAlex Deucher 2143fcec570bSAlex Deucher if (!tmds) 2144fcec570bSAlex Deucher return; 2145fcec570bSAlex Deucher 2146fcec570bSAlex Deucher switch (tmds->dvo_chip) { 2147fcec570bSAlex Deucher case DVO_SIL164: 2148fcec570bSAlex Deucher /* sil 164 */ 2149fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 1); 2150fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2151fcec570bSAlex Deucher tmds->slave_addr, 2152fcec570bSAlex Deucher 0x08, 0x30); 2153fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2154fcec570bSAlex Deucher tmds->slave_addr, 2155fcec570bSAlex Deucher 0x09, 0x00); 2156fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2157fcec570bSAlex Deucher tmds->slave_addr, 2158fcec570bSAlex Deucher 0x0a, 0x90); 2159fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2160fcec570bSAlex Deucher tmds->slave_addr, 2161fcec570bSAlex Deucher 0x0c, 0x89); 2162fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2163fcec570bSAlex Deucher tmds->slave_addr, 2164fcec570bSAlex Deucher 0x08, 0x3b); 2165fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 0); 2166fcec570bSAlex Deucher break; 2167fcec570bSAlex Deucher case DVO_SIL1178: 2168fcec570bSAlex Deucher /* sil 1178 - untested */ 2169fcec570bSAlex Deucher /* 2170fcec570bSAlex Deucher * 0x0f, 0x44 2171fcec570bSAlex Deucher * 0x0f, 0x4c 2172fcec570bSAlex Deucher * 0x0e, 0x01 2173fcec570bSAlex Deucher * 0x0a, 0x80 2174fcec570bSAlex Deucher * 0x09, 0x30 2175fcec570bSAlex Deucher * 0x0c, 0xc9 2176fcec570bSAlex Deucher * 0x0d, 0x70 2177fcec570bSAlex Deucher * 0x08, 0x32 2178fcec570bSAlex Deucher * 0x08, 0x33 2179fcec570bSAlex Deucher */ 2180fcec570bSAlex Deucher break; 2181fcec570bSAlex Deucher default: 2182fcec570bSAlex Deucher break; 2183fcec570bSAlex Deucher } 2184fcec570bSAlex Deucher 2185fcec570bSAlex Deucher } 2186fcec570bSAlex Deucher 2187fcec570bSAlex Deucher bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder) 2188fcec570bSAlex Deucher { 2189fcec570bSAlex Deucher struct drm_device *dev = encoder->dev; 2190fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 2191fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2192fcec570bSAlex Deucher uint16_t offset; 2193fcec570bSAlex Deucher uint8_t blocks, slave_addr, rev; 2194fcec570bSAlex Deucher uint32_t index, id; 2195fcec570bSAlex Deucher uint32_t reg, val, and_mask, or_mask; 2196fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2197fcec570bSAlex Deucher 2198fcec570bSAlex Deucher if (rdev->bios == NULL) 2199fcec570bSAlex Deucher return false; 2200fcec570bSAlex Deucher 2201fcec570bSAlex Deucher if (!tmds) 2202fcec570bSAlex Deucher return false; 2203fcec570bSAlex Deucher 2204fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2205fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE); 2206fcec570bSAlex Deucher rev = RBIOS8(offset); 2207fcec570bSAlex Deucher if (offset) { 2208fcec570bSAlex Deucher rev = RBIOS8(offset); 2209fcec570bSAlex Deucher if (rev > 1) { 2210fcec570bSAlex Deucher blocks = RBIOS8(offset + 3); 2211fcec570bSAlex Deucher index = offset + 4; 2212fcec570bSAlex Deucher while (blocks > 0) { 2213fcec570bSAlex Deucher id = RBIOS16(index); 2214fcec570bSAlex Deucher index += 2; 2215fcec570bSAlex Deucher switch (id >> 13) { 2216fcec570bSAlex Deucher case 0: 2217fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2218fcec570bSAlex Deucher val = RBIOS32(index); 2219fcec570bSAlex Deucher index += 4; 2220fcec570bSAlex Deucher WREG32(reg, val); 2221fcec570bSAlex Deucher break; 2222fcec570bSAlex Deucher case 2: 2223fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2224fcec570bSAlex Deucher and_mask = RBIOS32(index); 2225fcec570bSAlex Deucher index += 4; 2226fcec570bSAlex Deucher or_mask = RBIOS32(index); 2227fcec570bSAlex Deucher index += 4; 2228fcec570bSAlex Deucher val = RREG32(reg); 2229fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2230fcec570bSAlex Deucher WREG32(reg, val); 2231fcec570bSAlex Deucher break; 2232fcec570bSAlex Deucher case 3: 2233fcec570bSAlex Deucher val = RBIOS16(index); 2234fcec570bSAlex Deucher index += 2; 2235fcec570bSAlex Deucher udelay(val); 2236fcec570bSAlex Deucher break; 2237fcec570bSAlex Deucher case 4: 2238fcec570bSAlex Deucher val = RBIOS16(index); 2239fcec570bSAlex Deucher index += 2; 2240fcec570bSAlex Deucher udelay(val * 1000); 2241fcec570bSAlex Deucher break; 2242fcec570bSAlex Deucher case 6: 2243fcec570bSAlex Deucher slave_addr = id & 0xff; 2244fcec570bSAlex Deucher slave_addr >>= 1; /* 7 bit addressing */ 2245fcec570bSAlex Deucher index++; 2246fcec570bSAlex Deucher reg = RBIOS8(index); 2247fcec570bSAlex Deucher index++; 2248fcec570bSAlex Deucher val = RBIOS8(index); 2249fcec570bSAlex Deucher index++; 2250fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 1); 2251fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2252fcec570bSAlex Deucher slave_addr, 2253fcec570bSAlex Deucher reg, val); 2254fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 0); 2255fcec570bSAlex Deucher break; 2256fcec570bSAlex Deucher default: 2257fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2258fcec570bSAlex Deucher break; 2259fcec570bSAlex Deucher } 2260fcec570bSAlex Deucher blocks--; 2261fcec570bSAlex Deucher } 2262fcec570bSAlex Deucher return true; 2263fcec570bSAlex Deucher } 2264fcec570bSAlex Deucher } 2265fcec570bSAlex Deucher } else { 2266fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2267fcec570bSAlex Deucher if (offset) { 2268fcec570bSAlex Deucher index = offset + 10; 2269fcec570bSAlex Deucher id = RBIOS16(index); 2270fcec570bSAlex Deucher while (id != 0xffff) { 2271fcec570bSAlex Deucher index += 2; 2272fcec570bSAlex Deucher switch (id >> 13) { 2273fcec570bSAlex Deucher case 0: 2274fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2275fcec570bSAlex Deucher val = RBIOS32(index); 2276fcec570bSAlex Deucher WREG32(reg, val); 2277fcec570bSAlex Deucher break; 2278fcec570bSAlex Deucher case 2: 2279fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2280fcec570bSAlex Deucher and_mask = RBIOS32(index); 2281fcec570bSAlex Deucher index += 4; 2282fcec570bSAlex Deucher or_mask = RBIOS32(index); 2283fcec570bSAlex Deucher index += 4; 2284fcec570bSAlex Deucher val = RREG32(reg); 2285fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2286fcec570bSAlex Deucher WREG32(reg, val); 2287fcec570bSAlex Deucher break; 2288fcec570bSAlex Deucher case 4: 2289fcec570bSAlex Deucher val = RBIOS16(index); 2290fcec570bSAlex Deucher index += 2; 2291fcec570bSAlex Deucher udelay(val); 2292fcec570bSAlex Deucher break; 2293fcec570bSAlex Deucher case 5: 2294fcec570bSAlex Deucher reg = id & 0x1fff; 2295fcec570bSAlex Deucher and_mask = RBIOS32(index); 2296fcec570bSAlex Deucher index += 4; 2297fcec570bSAlex Deucher or_mask = RBIOS32(index); 2298fcec570bSAlex Deucher index += 4; 2299fcec570bSAlex Deucher val = RREG32_PLL(reg); 2300fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2301fcec570bSAlex Deucher WREG32_PLL(reg, val); 2302fcec570bSAlex Deucher break; 2303fcec570bSAlex Deucher case 6: 2304fcec570bSAlex Deucher reg = id & 0x1fff; 2305fcec570bSAlex Deucher val = RBIOS8(index); 2306fcec570bSAlex Deucher index += 1; 2307fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 1); 2308fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2309fcec570bSAlex Deucher tmds->slave_addr, 2310fcec570bSAlex Deucher reg, val); 2311fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 0); 2312fcec570bSAlex Deucher break; 2313fcec570bSAlex Deucher default: 2314fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2315fcec570bSAlex Deucher break; 2316fcec570bSAlex Deucher } 2317fcec570bSAlex Deucher id = RBIOS16(index); 2318fcec570bSAlex Deucher } 2319fcec570bSAlex Deucher return true; 2320fcec570bSAlex Deucher } 2321fcec570bSAlex Deucher } 2322fcec570bSAlex Deucher return false; 2323fcec570bSAlex Deucher } 2324fcec570bSAlex Deucher 2325771fe6b9SJerome Glisse static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset) 2326771fe6b9SJerome Glisse { 2327771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2328771fe6b9SJerome Glisse 2329771fe6b9SJerome Glisse if (offset) { 2330771fe6b9SJerome Glisse while (RBIOS16(offset)) { 2331771fe6b9SJerome Glisse uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13); 2332771fe6b9SJerome Glisse uint32_t addr = (RBIOS16(offset) & 0x1fff); 2333771fe6b9SJerome Glisse uint32_t val, and_mask, or_mask; 2334771fe6b9SJerome Glisse uint32_t tmp; 2335771fe6b9SJerome Glisse 2336771fe6b9SJerome Glisse offset += 2; 2337771fe6b9SJerome Glisse switch (cmd) { 2338771fe6b9SJerome Glisse case 0: 2339771fe6b9SJerome Glisse val = RBIOS32(offset); 2340771fe6b9SJerome Glisse offset += 4; 2341771fe6b9SJerome Glisse WREG32(addr, val); 2342771fe6b9SJerome Glisse break; 2343771fe6b9SJerome Glisse case 1: 2344771fe6b9SJerome Glisse val = RBIOS32(offset); 2345771fe6b9SJerome Glisse offset += 4; 2346771fe6b9SJerome Glisse WREG32(addr, val); 2347771fe6b9SJerome Glisse break; 2348771fe6b9SJerome Glisse case 2: 2349771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2350771fe6b9SJerome Glisse offset += 4; 2351771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2352771fe6b9SJerome Glisse offset += 4; 2353771fe6b9SJerome Glisse tmp = RREG32(addr); 2354771fe6b9SJerome Glisse tmp &= and_mask; 2355771fe6b9SJerome Glisse tmp |= or_mask; 2356771fe6b9SJerome Glisse WREG32(addr, tmp); 2357771fe6b9SJerome Glisse break; 2358771fe6b9SJerome Glisse case 3: 2359771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2360771fe6b9SJerome Glisse offset += 4; 2361771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2362771fe6b9SJerome Glisse offset += 4; 2363771fe6b9SJerome Glisse tmp = RREG32(addr); 2364771fe6b9SJerome Glisse tmp &= and_mask; 2365771fe6b9SJerome Glisse tmp |= or_mask; 2366771fe6b9SJerome Glisse WREG32(addr, tmp); 2367771fe6b9SJerome Glisse break; 2368771fe6b9SJerome Glisse case 4: 2369771fe6b9SJerome Glisse val = RBIOS16(offset); 2370771fe6b9SJerome Glisse offset += 2; 2371771fe6b9SJerome Glisse udelay(val); 2372771fe6b9SJerome Glisse break; 2373771fe6b9SJerome Glisse case 5: 2374771fe6b9SJerome Glisse val = RBIOS16(offset); 2375771fe6b9SJerome Glisse offset += 2; 2376771fe6b9SJerome Glisse switch (addr) { 2377771fe6b9SJerome Glisse case 8: 2378771fe6b9SJerome Glisse while (val--) { 2379771fe6b9SJerome Glisse if (! 2380771fe6b9SJerome Glisse (RREG32_PLL 2381771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2382771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2383771fe6b9SJerome Glisse break; 2384771fe6b9SJerome Glisse } 2385771fe6b9SJerome Glisse break; 2386771fe6b9SJerome Glisse case 9: 2387771fe6b9SJerome Glisse while (val--) { 2388771fe6b9SJerome Glisse if ((RREG32(RADEON_MC_STATUS) & 2389771fe6b9SJerome Glisse RADEON_MC_IDLE)) 2390771fe6b9SJerome Glisse break; 2391771fe6b9SJerome Glisse } 2392771fe6b9SJerome Glisse break; 2393771fe6b9SJerome Glisse default: 2394771fe6b9SJerome Glisse break; 2395771fe6b9SJerome Glisse } 2396771fe6b9SJerome Glisse break; 2397771fe6b9SJerome Glisse default: 2398771fe6b9SJerome Glisse break; 2399771fe6b9SJerome Glisse } 2400771fe6b9SJerome Glisse } 2401771fe6b9SJerome Glisse } 2402771fe6b9SJerome Glisse } 2403771fe6b9SJerome Glisse 2404771fe6b9SJerome Glisse static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset) 2405771fe6b9SJerome Glisse { 2406771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2407771fe6b9SJerome Glisse 2408771fe6b9SJerome Glisse if (offset) { 2409771fe6b9SJerome Glisse while (RBIOS8(offset)) { 2410771fe6b9SJerome Glisse uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6); 2411771fe6b9SJerome Glisse uint8_t addr = (RBIOS8(offset) & 0x3f); 2412771fe6b9SJerome Glisse uint32_t val, shift, tmp; 2413771fe6b9SJerome Glisse uint32_t and_mask, or_mask; 2414771fe6b9SJerome Glisse 2415771fe6b9SJerome Glisse offset++; 2416771fe6b9SJerome Glisse switch (cmd) { 2417771fe6b9SJerome Glisse case 0: 2418771fe6b9SJerome Glisse val = RBIOS32(offset); 2419771fe6b9SJerome Glisse offset += 4; 2420771fe6b9SJerome Glisse WREG32_PLL(addr, val); 2421771fe6b9SJerome Glisse break; 2422771fe6b9SJerome Glisse case 1: 2423771fe6b9SJerome Glisse shift = RBIOS8(offset) * 8; 2424771fe6b9SJerome Glisse offset++; 2425771fe6b9SJerome Glisse and_mask = RBIOS8(offset) << shift; 2426771fe6b9SJerome Glisse and_mask |= ~(0xff << shift); 2427771fe6b9SJerome Glisse offset++; 2428771fe6b9SJerome Glisse or_mask = RBIOS8(offset) << shift; 2429771fe6b9SJerome Glisse offset++; 2430771fe6b9SJerome Glisse tmp = RREG32_PLL(addr); 2431771fe6b9SJerome Glisse tmp &= and_mask; 2432771fe6b9SJerome Glisse tmp |= or_mask; 2433771fe6b9SJerome Glisse WREG32_PLL(addr, tmp); 2434771fe6b9SJerome Glisse break; 2435771fe6b9SJerome Glisse case 2: 2436771fe6b9SJerome Glisse case 3: 2437771fe6b9SJerome Glisse tmp = 1000; 2438771fe6b9SJerome Glisse switch (addr) { 2439771fe6b9SJerome Glisse case 1: 2440771fe6b9SJerome Glisse udelay(150); 2441771fe6b9SJerome Glisse break; 2442771fe6b9SJerome Glisse case 2: 2443771fe6b9SJerome Glisse udelay(1000); 2444771fe6b9SJerome Glisse break; 2445771fe6b9SJerome Glisse case 3: 2446771fe6b9SJerome Glisse while (tmp--) { 2447771fe6b9SJerome Glisse if (! 2448771fe6b9SJerome Glisse (RREG32_PLL 2449771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2450771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2451771fe6b9SJerome Glisse break; 2452771fe6b9SJerome Glisse } 2453771fe6b9SJerome Glisse break; 2454771fe6b9SJerome Glisse case 4: 2455771fe6b9SJerome Glisse while (tmp--) { 2456771fe6b9SJerome Glisse if (RREG32_PLL 2457771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2458771fe6b9SJerome Glisse RADEON_DLL_READY) 2459771fe6b9SJerome Glisse break; 2460771fe6b9SJerome Glisse } 2461771fe6b9SJerome Glisse break; 2462771fe6b9SJerome Glisse case 5: 2463771fe6b9SJerome Glisse tmp = 2464771fe6b9SJerome Glisse RREG32_PLL(RADEON_CLK_PWRMGT_CNTL); 2465771fe6b9SJerome Glisse if (tmp & RADEON_CG_NO1_DEBUG_0) { 2466771fe6b9SJerome Glisse #if 0 2467771fe6b9SJerome Glisse uint32_t mclk_cntl = 2468771fe6b9SJerome Glisse RREG32_PLL 2469771fe6b9SJerome Glisse (RADEON_MCLK_CNTL); 2470771fe6b9SJerome Glisse mclk_cntl &= 0xffff0000; 2471771fe6b9SJerome Glisse /*mclk_cntl |= 0x00001111;*//* ??? */ 2472771fe6b9SJerome Glisse WREG32_PLL(RADEON_MCLK_CNTL, 2473771fe6b9SJerome Glisse mclk_cntl); 2474771fe6b9SJerome Glisse udelay(10000); 2475771fe6b9SJerome Glisse #endif 2476771fe6b9SJerome Glisse WREG32_PLL 2477771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL, 2478771fe6b9SJerome Glisse tmp & 2479771fe6b9SJerome Glisse ~RADEON_CG_NO1_DEBUG_0); 2480771fe6b9SJerome Glisse udelay(10000); 2481771fe6b9SJerome Glisse } 2482771fe6b9SJerome Glisse break; 2483771fe6b9SJerome Glisse default: 2484771fe6b9SJerome Glisse break; 2485771fe6b9SJerome Glisse } 2486771fe6b9SJerome Glisse break; 2487771fe6b9SJerome Glisse default: 2488771fe6b9SJerome Glisse break; 2489771fe6b9SJerome Glisse } 2490771fe6b9SJerome Glisse } 2491771fe6b9SJerome Glisse } 2492771fe6b9SJerome Glisse } 2493771fe6b9SJerome Glisse 2494771fe6b9SJerome Glisse static void combios_parse_ram_reset_table(struct drm_device *dev, 2495771fe6b9SJerome Glisse uint16_t offset) 2496771fe6b9SJerome Glisse { 2497771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2498771fe6b9SJerome Glisse uint32_t tmp; 2499771fe6b9SJerome Glisse 2500771fe6b9SJerome Glisse if (offset) { 2501771fe6b9SJerome Glisse uint8_t val = RBIOS8(offset); 2502771fe6b9SJerome Glisse while (val != 0xff) { 2503771fe6b9SJerome Glisse offset++; 2504771fe6b9SJerome Glisse 2505771fe6b9SJerome Glisse if (val == 0x0f) { 2506771fe6b9SJerome Glisse uint32_t channel_complete_mask; 2507771fe6b9SJerome Glisse 2508771fe6b9SJerome Glisse if (ASIC_IS_R300(rdev)) 2509771fe6b9SJerome Glisse channel_complete_mask = 2510771fe6b9SJerome Glisse R300_MEM_PWRUP_COMPLETE; 2511771fe6b9SJerome Glisse else 2512771fe6b9SJerome Glisse channel_complete_mask = 2513771fe6b9SJerome Glisse RADEON_MEM_PWRUP_COMPLETE; 2514771fe6b9SJerome Glisse tmp = 20000; 2515771fe6b9SJerome Glisse while (tmp--) { 2516771fe6b9SJerome Glisse if ((RREG32(RADEON_MEM_STR_CNTL) & 2517771fe6b9SJerome Glisse channel_complete_mask) == 2518771fe6b9SJerome Glisse channel_complete_mask) 2519771fe6b9SJerome Glisse break; 2520771fe6b9SJerome Glisse } 2521771fe6b9SJerome Glisse } else { 2522771fe6b9SJerome Glisse uint32_t or_mask = RBIOS16(offset); 2523771fe6b9SJerome Glisse offset += 2; 2524771fe6b9SJerome Glisse 2525771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 2526771fe6b9SJerome Glisse tmp &= RADEON_SDRAM_MODE_MASK; 2527771fe6b9SJerome Glisse tmp |= or_mask; 2528771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 2529771fe6b9SJerome Glisse 2530771fe6b9SJerome Glisse or_mask = val << 24; 2531771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 2532771fe6b9SJerome Glisse tmp &= RADEON_B3MEM_RESET_MASK; 2533771fe6b9SJerome Glisse tmp |= or_mask; 2534771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 2535771fe6b9SJerome Glisse } 2536771fe6b9SJerome Glisse val = RBIOS8(offset); 2537771fe6b9SJerome Glisse } 2538771fe6b9SJerome Glisse } 2539771fe6b9SJerome Glisse } 2540771fe6b9SJerome Glisse 2541771fe6b9SJerome Glisse static uint32_t combios_detect_ram(struct drm_device *dev, int ram, 2542771fe6b9SJerome Glisse int mem_addr_mapping) 2543771fe6b9SJerome Glisse { 2544771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2545771fe6b9SJerome Glisse uint32_t mem_cntl; 2546771fe6b9SJerome Glisse uint32_t mem_size; 2547771fe6b9SJerome Glisse uint32_t addr = 0; 2548771fe6b9SJerome Glisse 2549771fe6b9SJerome Glisse mem_cntl = RREG32(RADEON_MEM_CNTL); 2550771fe6b9SJerome Glisse if (mem_cntl & RV100_HALF_MODE) 2551771fe6b9SJerome Glisse ram /= 2; 2552771fe6b9SJerome Glisse mem_size = ram; 2553771fe6b9SJerome Glisse mem_cntl &= ~(0xff << 8); 2554771fe6b9SJerome Glisse mem_cntl |= (mem_addr_mapping & 0xff) << 8; 2555771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 2556771fe6b9SJerome Glisse RREG32(RADEON_MEM_CNTL); 2557771fe6b9SJerome Glisse 2558771fe6b9SJerome Glisse /* sdram reset ? */ 2559771fe6b9SJerome Glisse 2560771fe6b9SJerome Glisse /* something like this???? */ 2561771fe6b9SJerome Glisse while (ram--) { 2562771fe6b9SJerome Glisse addr = ram * 1024 * 1024; 2563771fe6b9SJerome Glisse /* write to each page */ 2564771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 2565771fe6b9SJerome Glisse WREG32(RADEON_MM_DATA, 0xdeadbeef); 2566771fe6b9SJerome Glisse /* read back and verify */ 2567771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 2568771fe6b9SJerome Glisse if (RREG32(RADEON_MM_DATA) != 0xdeadbeef) 2569771fe6b9SJerome Glisse return 0; 2570771fe6b9SJerome Glisse } 2571771fe6b9SJerome Glisse 2572771fe6b9SJerome Glisse return mem_size; 2573771fe6b9SJerome Glisse } 2574771fe6b9SJerome Glisse 2575771fe6b9SJerome Glisse static void combios_write_ram_size(struct drm_device *dev) 2576771fe6b9SJerome Glisse { 2577771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2578771fe6b9SJerome Glisse uint8_t rev; 2579771fe6b9SJerome Glisse uint16_t offset; 2580771fe6b9SJerome Glisse uint32_t mem_size = 0; 2581771fe6b9SJerome Glisse uint32_t mem_cntl = 0; 2582771fe6b9SJerome Glisse 2583771fe6b9SJerome Glisse /* should do something smarter here I guess... */ 2584771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_IGP) 2585771fe6b9SJerome Glisse return; 2586771fe6b9SJerome Glisse 2587771fe6b9SJerome Glisse /* first check detected mem table */ 2588771fe6b9SJerome Glisse offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE); 2589771fe6b9SJerome Glisse if (offset) { 2590771fe6b9SJerome Glisse rev = RBIOS8(offset); 2591771fe6b9SJerome Glisse if (rev < 3) { 2592771fe6b9SJerome Glisse mem_cntl = RBIOS32(offset + 1); 2593771fe6b9SJerome Glisse mem_size = RBIOS16(offset + 5); 2594771fe6b9SJerome Glisse if (((rdev->flags & RADEON_FAMILY_MASK) < CHIP_R200) && 2595771fe6b9SJerome Glisse ((dev->pdev->device != 0x515e) 2596771fe6b9SJerome Glisse && (dev->pdev->device != 0x5969))) 2597771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 2598771fe6b9SJerome Glisse } 2599771fe6b9SJerome Glisse } 2600771fe6b9SJerome Glisse 2601771fe6b9SJerome Glisse if (!mem_size) { 2602771fe6b9SJerome Glisse offset = 2603771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 2604771fe6b9SJerome Glisse if (offset) { 2605771fe6b9SJerome Glisse rev = RBIOS8(offset - 1); 2606771fe6b9SJerome Glisse if (rev < 1) { 2607771fe6b9SJerome Glisse if (((rdev->flags & RADEON_FAMILY_MASK) < 2608771fe6b9SJerome Glisse CHIP_R200) 2609771fe6b9SJerome Glisse && ((dev->pdev->device != 0x515e) 2610771fe6b9SJerome Glisse && (dev->pdev->device != 0x5969))) { 2611771fe6b9SJerome Glisse int ram = 0; 2612771fe6b9SJerome Glisse int mem_addr_mapping = 0; 2613771fe6b9SJerome Glisse 2614771fe6b9SJerome Glisse while (RBIOS8(offset)) { 2615771fe6b9SJerome Glisse ram = RBIOS8(offset); 2616771fe6b9SJerome Glisse mem_addr_mapping = 2617771fe6b9SJerome Glisse RBIOS8(offset + 1); 2618771fe6b9SJerome Glisse if (mem_addr_mapping != 0x25) 2619771fe6b9SJerome Glisse ram *= 2; 2620771fe6b9SJerome Glisse mem_size = 2621771fe6b9SJerome Glisse combios_detect_ram(dev, ram, 2622771fe6b9SJerome Glisse mem_addr_mapping); 2623771fe6b9SJerome Glisse if (mem_size) 2624771fe6b9SJerome Glisse break; 2625771fe6b9SJerome Glisse offset += 2; 2626771fe6b9SJerome Glisse } 2627771fe6b9SJerome Glisse } else 2628771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 2629771fe6b9SJerome Glisse } else { 2630771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 2631771fe6b9SJerome Glisse mem_size *= 2; /* convert to MB */ 2632771fe6b9SJerome Glisse } 2633771fe6b9SJerome Glisse } 2634771fe6b9SJerome Glisse } 2635771fe6b9SJerome Glisse 2636771fe6b9SJerome Glisse mem_size *= (1024 * 1024); /* convert to bytes */ 2637771fe6b9SJerome Glisse WREG32(RADEON_CONFIG_MEMSIZE, mem_size); 2638771fe6b9SJerome Glisse } 2639771fe6b9SJerome Glisse 2640771fe6b9SJerome Glisse void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable) 2641771fe6b9SJerome Glisse { 2642771fe6b9SJerome Glisse uint16_t dyn_clk_info = 2643771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 2644771fe6b9SJerome Glisse 2645771fe6b9SJerome Glisse if (dyn_clk_info) 2646771fe6b9SJerome Glisse combios_parse_pll_table(dev, dyn_clk_info); 2647771fe6b9SJerome Glisse } 2648771fe6b9SJerome Glisse 2649771fe6b9SJerome Glisse void radeon_combios_asic_init(struct drm_device *dev) 2650771fe6b9SJerome Glisse { 2651771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2652771fe6b9SJerome Glisse uint16_t table; 2653771fe6b9SJerome Glisse 2654771fe6b9SJerome Glisse /* port hardcoded mac stuff from radeonfb */ 2655771fe6b9SJerome Glisse if (rdev->bios == NULL) 2656771fe6b9SJerome Glisse return; 2657771fe6b9SJerome Glisse 2658771fe6b9SJerome Glisse /* ASIC INIT 1 */ 2659771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE); 2660771fe6b9SJerome Glisse if (table) 2661771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 2662771fe6b9SJerome Glisse 2663771fe6b9SJerome Glisse /* PLL INIT */ 2664771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE); 2665771fe6b9SJerome Glisse if (table) 2666771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 2667771fe6b9SJerome Glisse 2668771fe6b9SJerome Glisse /* ASIC INIT 2 */ 2669771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE); 2670771fe6b9SJerome Glisse if (table) 2671771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 2672771fe6b9SJerome Glisse 2673771fe6b9SJerome Glisse if (!(rdev->flags & RADEON_IS_IGP)) { 2674771fe6b9SJerome Glisse /* ASIC INIT 4 */ 2675771fe6b9SJerome Glisse table = 2676771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE); 2677771fe6b9SJerome Glisse if (table) 2678771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 2679771fe6b9SJerome Glisse 2680771fe6b9SJerome Glisse /* RAM RESET */ 2681771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE); 2682771fe6b9SJerome Glisse if (table) 2683771fe6b9SJerome Glisse combios_parse_ram_reset_table(dev, table); 2684771fe6b9SJerome Glisse 2685771fe6b9SJerome Glisse /* ASIC INIT 3 */ 2686771fe6b9SJerome Glisse table = 2687771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE); 2688771fe6b9SJerome Glisse if (table) 2689771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 2690771fe6b9SJerome Glisse 2691771fe6b9SJerome Glisse /* write CONFIG_MEMSIZE */ 2692771fe6b9SJerome Glisse combios_write_ram_size(dev); 2693771fe6b9SJerome Glisse } 2694771fe6b9SJerome Glisse 2695771fe6b9SJerome Glisse /* DYN CLK 1 */ 2696771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 2697771fe6b9SJerome Glisse if (table) 2698771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 2699771fe6b9SJerome Glisse 2700771fe6b9SJerome Glisse } 2701771fe6b9SJerome Glisse 2702771fe6b9SJerome Glisse void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev) 2703771fe6b9SJerome Glisse { 2704771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2705771fe6b9SJerome Glisse uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch; 2706771fe6b9SJerome Glisse 2707771fe6b9SJerome Glisse bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); 2708771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 2709771fe6b9SJerome Glisse bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH); 2710771fe6b9SJerome Glisse 2711771fe6b9SJerome Glisse /* let the bios control the backlight */ 2712771fe6b9SJerome Glisse bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN; 2713771fe6b9SJerome Glisse 2714771fe6b9SJerome Glisse /* tell the bios not to handle mode switching */ 2715771fe6b9SJerome Glisse bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS | 2716771fe6b9SJerome Glisse RADEON_ACC_MODE_CHANGE); 2717771fe6b9SJerome Glisse 2718771fe6b9SJerome Glisse /* tell the bios a driver is loaded */ 2719771fe6b9SJerome Glisse bios_7_scratch |= RADEON_DRV_LOADED; 2720771fe6b9SJerome Glisse 2721771fe6b9SJerome Glisse WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch); 2722771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 2723771fe6b9SJerome Glisse WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch); 2724771fe6b9SJerome Glisse } 2725771fe6b9SJerome Glisse 2726771fe6b9SJerome Glisse void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock) 2727771fe6b9SJerome Glisse { 2728771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 2729771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2730771fe6b9SJerome Glisse uint32_t bios_6_scratch; 2731771fe6b9SJerome Glisse 2732771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 2733771fe6b9SJerome Glisse 2734771fe6b9SJerome Glisse if (lock) 2735771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DRIVER_CRITICAL; 2736771fe6b9SJerome Glisse else 2737771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DRIVER_CRITICAL; 2738771fe6b9SJerome Glisse 2739771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 2740771fe6b9SJerome Glisse } 2741771fe6b9SJerome Glisse 2742771fe6b9SJerome Glisse void 2743771fe6b9SJerome Glisse radeon_combios_connected_scratch_regs(struct drm_connector *connector, 2744771fe6b9SJerome Glisse struct drm_encoder *encoder, 2745771fe6b9SJerome Glisse bool connected) 2746771fe6b9SJerome Glisse { 2747771fe6b9SJerome Glisse struct drm_device *dev = connector->dev; 2748771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2749771fe6b9SJerome Glisse struct radeon_connector *radeon_connector = 2750771fe6b9SJerome Glisse to_radeon_connector(connector); 2751771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2752771fe6b9SJerome Glisse uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH); 2753771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 2754771fe6b9SJerome Glisse 2755771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) && 2756771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) { 2757771fe6b9SJerome Glisse if (connected) { 2758771fe6b9SJerome Glisse DRM_DEBUG("TV1 connected\n"); 2759771fe6b9SJerome Glisse /* fix me */ 2760771fe6b9SJerome Glisse bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO; 2761771fe6b9SJerome Glisse /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */ 2762771fe6b9SJerome Glisse bios_5_scratch |= RADEON_TV1_ON; 2763771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_TV1; 2764771fe6b9SJerome Glisse } else { 2765771fe6b9SJerome Glisse DRM_DEBUG("TV1 disconnected\n"); 2766771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK; 2767771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_ON; 2768771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_TV1; 2769771fe6b9SJerome Glisse } 2770771fe6b9SJerome Glisse } 2771771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) && 2772771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) { 2773771fe6b9SJerome Glisse if (connected) { 2774771fe6b9SJerome Glisse DRM_DEBUG("LCD1 connected\n"); 2775771fe6b9SJerome Glisse bios_4_scratch |= RADEON_LCD1_ATTACHED; 2776771fe6b9SJerome Glisse bios_5_scratch |= RADEON_LCD1_ON; 2777771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_LCD1; 2778771fe6b9SJerome Glisse } else { 2779771fe6b9SJerome Glisse DRM_DEBUG("LCD1 disconnected\n"); 2780771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_LCD1_ATTACHED; 2781771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_ON; 2782771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_LCD1; 2783771fe6b9SJerome Glisse } 2784771fe6b9SJerome Glisse } 2785771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) && 2786771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) { 2787771fe6b9SJerome Glisse if (connected) { 2788771fe6b9SJerome Glisse DRM_DEBUG("CRT1 connected\n"); 2789771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR; 2790771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT1_ON; 2791771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT1; 2792771fe6b9SJerome Glisse } else { 2793771fe6b9SJerome Glisse DRM_DEBUG("CRT1 disconnected\n"); 2794771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK; 2795771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_ON; 2796771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT1; 2797771fe6b9SJerome Glisse } 2798771fe6b9SJerome Glisse } 2799771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) && 2800771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) { 2801771fe6b9SJerome Glisse if (connected) { 2802771fe6b9SJerome Glisse DRM_DEBUG("CRT2 connected\n"); 2803771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR; 2804771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT2_ON; 2805771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT2; 2806771fe6b9SJerome Glisse } else { 2807771fe6b9SJerome Glisse DRM_DEBUG("CRT2 disconnected\n"); 2808771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK; 2809771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_ON; 2810771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT2; 2811771fe6b9SJerome Glisse } 2812771fe6b9SJerome Glisse } 2813771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) && 2814771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) { 2815771fe6b9SJerome Glisse if (connected) { 2816771fe6b9SJerome Glisse DRM_DEBUG("DFP1 connected\n"); 2817771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP1_ATTACHED; 2818771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP1_ON; 2819771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP1; 2820771fe6b9SJerome Glisse } else { 2821771fe6b9SJerome Glisse DRM_DEBUG("DFP1 disconnected\n"); 2822771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP1_ATTACHED; 2823771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_ON; 2824771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP1; 2825771fe6b9SJerome Glisse } 2826771fe6b9SJerome Glisse } 2827771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) && 2828771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) { 2829771fe6b9SJerome Glisse if (connected) { 2830771fe6b9SJerome Glisse DRM_DEBUG("DFP2 connected\n"); 2831771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP2_ATTACHED; 2832771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP2_ON; 2833771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP2; 2834771fe6b9SJerome Glisse } else { 2835771fe6b9SJerome Glisse DRM_DEBUG("DFP2 disconnected\n"); 2836771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP2_ATTACHED; 2837771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_ON; 2838771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP2; 2839771fe6b9SJerome Glisse } 2840771fe6b9SJerome Glisse } 2841771fe6b9SJerome Glisse WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch); 2842771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 2843771fe6b9SJerome Glisse } 2844771fe6b9SJerome Glisse 2845771fe6b9SJerome Glisse void 2846771fe6b9SJerome Glisse radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc) 2847771fe6b9SJerome Glisse { 2848771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 2849771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2850771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2851771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 2852771fe6b9SJerome Glisse 2853771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { 2854771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_CRTC_MASK; 2855771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT); 2856771fe6b9SJerome Glisse } 2857771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { 2858771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK; 2859771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT); 2860771fe6b9SJerome Glisse } 2861771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { 2862771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK; 2863771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT); 2864771fe6b9SJerome Glisse } 2865771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { 2866771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK; 2867771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT); 2868771fe6b9SJerome Glisse } 2869771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { 2870771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK; 2871771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT); 2872771fe6b9SJerome Glisse } 2873771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { 2874771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK; 2875771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT); 2876771fe6b9SJerome Glisse } 2877771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 2878771fe6b9SJerome Glisse } 2879771fe6b9SJerome Glisse 2880771fe6b9SJerome Glisse void 2881771fe6b9SJerome Glisse radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on) 2882771fe6b9SJerome Glisse { 2883771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 2884771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2885771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2886771fe6b9SJerome Glisse uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 2887771fe6b9SJerome Glisse 2888771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { 2889771fe6b9SJerome Glisse if (on) 2890771fe6b9SJerome Glisse bios_6_scratch |= RADEON_TV_DPMS_ON; 2891771fe6b9SJerome Glisse else 2892771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_TV_DPMS_ON; 2893771fe6b9SJerome Glisse } 2894771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) { 2895771fe6b9SJerome Glisse if (on) 2896771fe6b9SJerome Glisse bios_6_scratch |= RADEON_CRT_DPMS_ON; 2897771fe6b9SJerome Glisse else 2898771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_CRT_DPMS_ON; 2899771fe6b9SJerome Glisse } 2900771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 2901771fe6b9SJerome Glisse if (on) 2902771fe6b9SJerome Glisse bios_6_scratch |= RADEON_LCD_DPMS_ON; 2903771fe6b9SJerome Glisse else 2904771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_LCD_DPMS_ON; 2905771fe6b9SJerome Glisse } 2906771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 2907771fe6b9SJerome Glisse if (on) 2908771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DFP_DPMS_ON; 2909771fe6b9SJerome Glisse else 2910771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DFP_DPMS_ON; 2911771fe6b9SJerome Glisse } 2912771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 2913771fe6b9SJerome Glisse } 2914