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 445771fe6b9SJerome Glisse struct radeon_i2c_bus_rec combios_setup_i2c_bus(int ddc_line) 446771fe6b9SJerome Glisse { 447771fe6b9SJerome Glisse struct radeon_i2c_bus_rec i2c; 448771fe6b9SJerome Glisse 449771fe6b9SJerome Glisse i2c.mask_clk_mask = RADEON_GPIO_EN_1; 450771fe6b9SJerome Glisse i2c.mask_data_mask = RADEON_GPIO_EN_0; 451771fe6b9SJerome Glisse i2c.a_clk_mask = RADEON_GPIO_A_1; 452771fe6b9SJerome Glisse i2c.a_data_mask = RADEON_GPIO_A_0; 4539b9fe724SAlex Deucher i2c.en_clk_mask = RADEON_GPIO_EN_1; 4549b9fe724SAlex Deucher i2c.en_data_mask = RADEON_GPIO_EN_0; 4559b9fe724SAlex Deucher i2c.y_clk_mask = RADEON_GPIO_Y_1; 4569b9fe724SAlex Deucher i2c.y_data_mask = RADEON_GPIO_Y_0; 457771fe6b9SJerome Glisse if ((ddc_line == RADEON_LCD_GPIO_MASK) || 458771fe6b9SJerome Glisse (ddc_line == RADEON_MDGPIO_EN_REG)) { 459771fe6b9SJerome Glisse i2c.mask_clk_reg = ddc_line; 460771fe6b9SJerome Glisse i2c.mask_data_reg = ddc_line; 461771fe6b9SJerome Glisse i2c.a_clk_reg = ddc_line; 462771fe6b9SJerome Glisse i2c.a_data_reg = ddc_line; 4639b9fe724SAlex Deucher i2c.en_clk_reg = ddc_line; 4649b9fe724SAlex Deucher i2c.en_data_reg = ddc_line; 4659b9fe724SAlex Deucher i2c.y_clk_reg = ddc_line + 4; 4669b9fe724SAlex Deucher i2c.y_data_reg = ddc_line + 4; 467771fe6b9SJerome Glisse } else { 468771fe6b9SJerome Glisse i2c.mask_clk_reg = ddc_line; 469771fe6b9SJerome Glisse i2c.mask_data_reg = ddc_line; 470771fe6b9SJerome Glisse i2c.a_clk_reg = ddc_line; 471771fe6b9SJerome Glisse i2c.a_data_reg = ddc_line; 4729b9fe724SAlex Deucher i2c.en_clk_reg = ddc_line; 4739b9fe724SAlex Deucher i2c.en_data_reg = ddc_line; 4749b9fe724SAlex Deucher i2c.y_clk_reg = ddc_line; 4759b9fe724SAlex Deucher i2c.y_data_reg = ddc_line; 476771fe6b9SJerome Glisse } 477771fe6b9SJerome Glisse 478771fe6b9SJerome Glisse if (ddc_line) 479771fe6b9SJerome Glisse i2c.valid = true; 480771fe6b9SJerome Glisse else 481771fe6b9SJerome Glisse i2c.valid = false; 482771fe6b9SJerome Glisse 483771fe6b9SJerome Glisse return i2c; 484771fe6b9SJerome Glisse } 485771fe6b9SJerome Glisse 486771fe6b9SJerome Glisse bool radeon_combios_get_clock_info(struct drm_device *dev) 487771fe6b9SJerome Glisse { 488771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 489771fe6b9SJerome Glisse uint16_t pll_info; 490771fe6b9SJerome Glisse struct radeon_pll *p1pll = &rdev->clock.p1pll; 491771fe6b9SJerome Glisse struct radeon_pll *p2pll = &rdev->clock.p2pll; 492771fe6b9SJerome Glisse struct radeon_pll *spll = &rdev->clock.spll; 493771fe6b9SJerome Glisse struct radeon_pll *mpll = &rdev->clock.mpll; 494771fe6b9SJerome Glisse int8_t rev; 495771fe6b9SJerome Glisse uint16_t sclk, mclk; 496771fe6b9SJerome Glisse 497771fe6b9SJerome Glisse if (rdev->bios == NULL) 498771fe6b9SJerome Glisse return NULL; 499771fe6b9SJerome Glisse 500771fe6b9SJerome Glisse pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE); 501771fe6b9SJerome Glisse if (pll_info) { 502771fe6b9SJerome Glisse rev = RBIOS8(pll_info); 503771fe6b9SJerome Glisse 504771fe6b9SJerome Glisse /* pixel clocks */ 505771fe6b9SJerome Glisse p1pll->reference_freq = RBIOS16(pll_info + 0xe); 506771fe6b9SJerome Glisse p1pll->reference_div = RBIOS16(pll_info + 0x10); 507771fe6b9SJerome Glisse p1pll->pll_out_min = RBIOS32(pll_info + 0x12); 508771fe6b9SJerome Glisse p1pll->pll_out_max = RBIOS32(pll_info + 0x16); 509771fe6b9SJerome Glisse 510771fe6b9SJerome Glisse if (rev > 9) { 511771fe6b9SJerome Glisse p1pll->pll_in_min = RBIOS32(pll_info + 0x36); 512771fe6b9SJerome Glisse p1pll->pll_in_max = RBIOS32(pll_info + 0x3a); 513771fe6b9SJerome Glisse } else { 514771fe6b9SJerome Glisse p1pll->pll_in_min = 40; 515771fe6b9SJerome Glisse p1pll->pll_in_max = 500; 516771fe6b9SJerome Glisse } 517771fe6b9SJerome Glisse *p2pll = *p1pll; 518771fe6b9SJerome Glisse 519771fe6b9SJerome Glisse /* system clock */ 520771fe6b9SJerome Glisse spll->reference_freq = RBIOS16(pll_info + 0x1a); 521771fe6b9SJerome Glisse spll->reference_div = RBIOS16(pll_info + 0x1c); 522771fe6b9SJerome Glisse spll->pll_out_min = RBIOS32(pll_info + 0x1e); 523771fe6b9SJerome Glisse spll->pll_out_max = RBIOS32(pll_info + 0x22); 524771fe6b9SJerome Glisse 525771fe6b9SJerome Glisse if (rev > 10) { 526771fe6b9SJerome Glisse spll->pll_in_min = RBIOS32(pll_info + 0x48); 527771fe6b9SJerome Glisse spll->pll_in_max = RBIOS32(pll_info + 0x4c); 528771fe6b9SJerome Glisse } else { 529771fe6b9SJerome Glisse /* ??? */ 530771fe6b9SJerome Glisse spll->pll_in_min = 40; 531771fe6b9SJerome Glisse spll->pll_in_max = 500; 532771fe6b9SJerome Glisse } 533771fe6b9SJerome Glisse 534771fe6b9SJerome Glisse /* memory clock */ 535771fe6b9SJerome Glisse mpll->reference_freq = RBIOS16(pll_info + 0x26); 536771fe6b9SJerome Glisse mpll->reference_div = RBIOS16(pll_info + 0x28); 537771fe6b9SJerome Glisse mpll->pll_out_min = RBIOS32(pll_info + 0x2a); 538771fe6b9SJerome Glisse mpll->pll_out_max = RBIOS32(pll_info + 0x2e); 539771fe6b9SJerome Glisse 540771fe6b9SJerome Glisse if (rev > 10) { 541771fe6b9SJerome Glisse mpll->pll_in_min = RBIOS32(pll_info + 0x5a); 542771fe6b9SJerome Glisse mpll->pll_in_max = RBIOS32(pll_info + 0x5e); 543771fe6b9SJerome Glisse } else { 544771fe6b9SJerome Glisse /* ??? */ 545771fe6b9SJerome Glisse mpll->pll_in_min = 40; 546771fe6b9SJerome Glisse mpll->pll_in_max = 500; 547771fe6b9SJerome Glisse } 548771fe6b9SJerome Glisse 549771fe6b9SJerome Glisse /* default sclk/mclk */ 550771fe6b9SJerome Glisse sclk = RBIOS16(pll_info + 0xa); 551771fe6b9SJerome Glisse mclk = RBIOS16(pll_info + 0x8); 552771fe6b9SJerome Glisse if (sclk == 0) 553771fe6b9SJerome Glisse sclk = 200 * 100; 554771fe6b9SJerome Glisse if (mclk == 0) 555771fe6b9SJerome Glisse mclk = 200 * 100; 556771fe6b9SJerome Glisse 557771fe6b9SJerome Glisse rdev->clock.default_sclk = sclk; 558771fe6b9SJerome Glisse rdev->clock.default_mclk = mclk; 559771fe6b9SJerome Glisse 560771fe6b9SJerome Glisse return true; 561771fe6b9SJerome Glisse } 562771fe6b9SJerome Glisse return false; 563771fe6b9SJerome Glisse } 564771fe6b9SJerome Glisse 565771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct 566771fe6b9SJerome Glisse radeon_encoder 567771fe6b9SJerome Glisse *encoder) 568771fe6b9SJerome Glisse { 569771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 570771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 571771fe6b9SJerome Glisse uint16_t dac_info; 572771fe6b9SJerome Glisse uint8_t rev, bg, dac; 573771fe6b9SJerome Glisse struct radeon_encoder_primary_dac *p_dac = NULL; 574771fe6b9SJerome Glisse 575771fe6b9SJerome Glisse if (rdev->bios == NULL) 576771fe6b9SJerome Glisse return NULL; 577771fe6b9SJerome Glisse 578771fe6b9SJerome Glisse /* check CRT table */ 579771fe6b9SJerome Glisse dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 580771fe6b9SJerome Glisse if (dac_info) { 581771fe6b9SJerome Glisse p_dac = 582771fe6b9SJerome Glisse kzalloc(sizeof(struct radeon_encoder_primary_dac), 583771fe6b9SJerome Glisse GFP_KERNEL); 584771fe6b9SJerome Glisse 585771fe6b9SJerome Glisse if (!p_dac) 586771fe6b9SJerome Glisse return NULL; 587771fe6b9SJerome Glisse 588771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 589771fe6b9SJerome Glisse if (rev < 2) { 590771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 591771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf; 592771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 593771fe6b9SJerome Glisse } else { 594771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x2) & 0xf; 595771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x3) & 0xf; 596771fe6b9SJerome Glisse p_dac->ps2_pdac_adj = (bg << 8) | (dac); 597771fe6b9SJerome Glisse } 598771fe6b9SJerome Glisse 599771fe6b9SJerome Glisse } 600771fe6b9SJerome Glisse 601771fe6b9SJerome Glisse return p_dac; 602771fe6b9SJerome Glisse } 603771fe6b9SJerome Glisse 604771fe6b9SJerome Glisse static enum radeon_tv_std 605771fe6b9SJerome Glisse radeon_combios_get_tv_info(struct radeon_encoder *encoder) 606771fe6b9SJerome Glisse { 607771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 608771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 609771fe6b9SJerome Glisse uint16_t tv_info; 610771fe6b9SJerome Glisse enum radeon_tv_std tv_std = TV_STD_NTSC; 611771fe6b9SJerome Glisse 612771fe6b9SJerome Glisse tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 613771fe6b9SJerome Glisse if (tv_info) { 614771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 615771fe6b9SJerome Glisse switch (RBIOS8(tv_info + 7) & 0xf) { 616771fe6b9SJerome Glisse case 1: 617771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 618771fe6b9SJerome Glisse DRM_INFO("Default TV standard: NTSC\n"); 619771fe6b9SJerome Glisse break; 620771fe6b9SJerome Glisse case 2: 621771fe6b9SJerome Glisse tv_std = TV_STD_PAL; 622771fe6b9SJerome Glisse DRM_INFO("Default TV standard: PAL\n"); 623771fe6b9SJerome Glisse break; 624771fe6b9SJerome Glisse case 3: 625771fe6b9SJerome Glisse tv_std = TV_STD_PAL_M; 626771fe6b9SJerome Glisse DRM_INFO("Default TV standard: PAL-M\n"); 627771fe6b9SJerome Glisse break; 628771fe6b9SJerome Glisse case 4: 629771fe6b9SJerome Glisse tv_std = TV_STD_PAL_60; 630771fe6b9SJerome Glisse DRM_INFO("Default TV standard: PAL-60\n"); 631771fe6b9SJerome Glisse break; 632771fe6b9SJerome Glisse case 5: 633771fe6b9SJerome Glisse tv_std = TV_STD_NTSC_J; 634771fe6b9SJerome Glisse DRM_INFO("Default TV standard: NTSC-J\n"); 635771fe6b9SJerome Glisse break; 636771fe6b9SJerome Glisse case 6: 637771fe6b9SJerome Glisse tv_std = TV_STD_SCART_PAL; 638771fe6b9SJerome Glisse DRM_INFO("Default TV standard: SCART-PAL\n"); 639771fe6b9SJerome Glisse break; 640771fe6b9SJerome Glisse default: 641771fe6b9SJerome Glisse tv_std = TV_STD_NTSC; 642771fe6b9SJerome Glisse DRM_INFO 643771fe6b9SJerome Glisse ("Unknown TV standard; defaulting to NTSC\n"); 644771fe6b9SJerome Glisse break; 645771fe6b9SJerome Glisse } 646771fe6b9SJerome Glisse 647771fe6b9SJerome Glisse switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) { 648771fe6b9SJerome Glisse case 0: 649771fe6b9SJerome Glisse DRM_INFO("29.498928713 MHz TV ref clk\n"); 650771fe6b9SJerome Glisse break; 651771fe6b9SJerome Glisse case 1: 652771fe6b9SJerome Glisse DRM_INFO("28.636360000 MHz TV ref clk\n"); 653771fe6b9SJerome Glisse break; 654771fe6b9SJerome Glisse case 2: 655771fe6b9SJerome Glisse DRM_INFO("14.318180000 MHz TV ref clk\n"); 656771fe6b9SJerome Glisse break; 657771fe6b9SJerome Glisse case 3: 658771fe6b9SJerome Glisse DRM_INFO("27.000000000 MHz TV ref clk\n"); 659771fe6b9SJerome Glisse break; 660771fe6b9SJerome Glisse default: 661771fe6b9SJerome Glisse break; 662771fe6b9SJerome Glisse } 663771fe6b9SJerome Glisse } 664771fe6b9SJerome Glisse } 665771fe6b9SJerome Glisse return tv_std; 666771fe6b9SJerome Glisse } 667771fe6b9SJerome Glisse 668771fe6b9SJerome Glisse static const uint32_t default_tvdac_adj[CHIP_LAST] = { 669771fe6b9SJerome Glisse 0x00000000, /* r100 */ 670771fe6b9SJerome Glisse 0x00280000, /* rv100 */ 671771fe6b9SJerome Glisse 0x00000000, /* rs100 */ 672771fe6b9SJerome Glisse 0x00880000, /* rv200 */ 673771fe6b9SJerome Glisse 0x00000000, /* rs200 */ 674771fe6b9SJerome Glisse 0x00000000, /* r200 */ 675771fe6b9SJerome Glisse 0x00770000, /* rv250 */ 676771fe6b9SJerome Glisse 0x00290000, /* rs300 */ 677771fe6b9SJerome Glisse 0x00560000, /* rv280 */ 678771fe6b9SJerome Glisse 0x00780000, /* r300 */ 679771fe6b9SJerome Glisse 0x00770000, /* r350 */ 680771fe6b9SJerome Glisse 0x00780000, /* rv350 */ 681771fe6b9SJerome Glisse 0x00780000, /* rv380 */ 682771fe6b9SJerome Glisse 0x01080000, /* r420 */ 683771fe6b9SJerome Glisse 0x01080000, /* r423 */ 684771fe6b9SJerome Glisse 0x01080000, /* rv410 */ 685771fe6b9SJerome Glisse 0x00780000, /* rs400 */ 686771fe6b9SJerome Glisse 0x00780000, /* rs480 */ 687771fe6b9SJerome Glisse }; 688771fe6b9SJerome Glisse 6896a719e05SDave Airlie static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev, 6906a719e05SDave Airlie struct radeon_encoder_tv_dac *tv_dac) 691771fe6b9SJerome Glisse { 692771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; 693771fe6b9SJerome Glisse if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) 694771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 0x00880000; 695771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 696771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 6976a719e05SDave Airlie return; 698771fe6b9SJerome Glisse } 699771fe6b9SJerome Glisse 700771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct 701771fe6b9SJerome Glisse radeon_encoder 702771fe6b9SJerome Glisse *encoder) 703771fe6b9SJerome Glisse { 704771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 705771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 706771fe6b9SJerome Glisse uint16_t dac_info; 707771fe6b9SJerome Glisse uint8_t rev, bg, dac; 708771fe6b9SJerome Glisse struct radeon_encoder_tv_dac *tv_dac = NULL; 7096a719e05SDave Airlie int found = 0; 7106a719e05SDave Airlie 7116a719e05SDave Airlie tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); 7126a719e05SDave Airlie if (!tv_dac) 7136a719e05SDave Airlie return NULL; 714771fe6b9SJerome Glisse 715771fe6b9SJerome Glisse if (rdev->bios == NULL) 7166a719e05SDave Airlie goto out; 717771fe6b9SJerome Glisse 718771fe6b9SJerome Glisse /* first check TV table */ 719771fe6b9SJerome Glisse dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 720771fe6b9SJerome Glisse if (dac_info) { 721771fe6b9SJerome Glisse rev = RBIOS8(dac_info + 0x3); 722771fe6b9SJerome Glisse if (rev > 4) { 723771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 724771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xd) & 0xf; 725771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 726771fe6b9SJerome Glisse 727771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 728771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0xf) & 0xf; 729771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 730771fe6b9SJerome Glisse 731771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x10) & 0xf; 732771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x11) & 0xf; 733771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 7346a719e05SDave Airlie found = 1; 735771fe6b9SJerome Glisse } else if (rev > 1) { 736771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xc) & 0xf; 737771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; 738771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); 739771fe6b9SJerome Glisse 740771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xd) & 0xf; 741771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf; 742771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); 743771fe6b9SJerome Glisse 744771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0xe) & 0xf; 745771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; 746771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 7476a719e05SDave Airlie found = 1; 748771fe6b9SJerome Glisse } 749771fe6b9SJerome Glisse tv_dac->tv_std = radeon_combios_get_tv_info(encoder); 7506a719e05SDave Airlie } 7516a719e05SDave Airlie if (!found) { 752771fe6b9SJerome Glisse /* then check CRT table */ 753771fe6b9SJerome Glisse dac_info = 754771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 755771fe6b9SJerome Glisse if (dac_info) { 756771fe6b9SJerome Glisse rev = RBIOS8(dac_info) & 0x3; 757771fe6b9SJerome Glisse if (rev < 2) { 758771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x3) & 0xf; 759771fe6b9SJerome Glisse dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf; 760771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 761771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 762771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 763771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 7646a719e05SDave Airlie found = 1; 765771fe6b9SJerome Glisse } else { 766771fe6b9SJerome Glisse bg = RBIOS8(dac_info + 0x4) & 0xf; 767771fe6b9SJerome Glisse dac = RBIOS8(dac_info + 0x5) & 0xf; 768771fe6b9SJerome Glisse tv_dac->ps2_tvdac_adj = 769771fe6b9SJerome Glisse (bg << 16) | (dac << 20); 770771fe6b9SJerome Glisse tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 771771fe6b9SJerome Glisse tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 7726a719e05SDave Airlie found = 1; 773771fe6b9SJerome Glisse } 7746fe7ac3fSAlex Deucher } else { 7756fe7ac3fSAlex Deucher DRM_INFO("No TV DAC info found in BIOS\n"); 776771fe6b9SJerome Glisse } 777771fe6b9SJerome Glisse } 778771fe6b9SJerome Glisse 7796a719e05SDave Airlie out: 7806a719e05SDave Airlie if (!found) /* fallback to defaults */ 7816a719e05SDave Airlie radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac); 7826a719e05SDave Airlie 783771fe6b9SJerome Glisse return tv_dac; 784771fe6b9SJerome Glisse } 785771fe6b9SJerome Glisse 786771fe6b9SJerome Glisse static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct 787771fe6b9SJerome Glisse radeon_device 788771fe6b9SJerome Glisse *rdev) 789771fe6b9SJerome Glisse { 790771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 791771fe6b9SJerome Glisse uint32_t fp_vert_stretch, fp_horz_stretch; 792771fe6b9SJerome Glisse uint32_t ppll_div_sel, ppll_val; 7938b5c7444SMichel Dänzer uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL); 794771fe6b9SJerome Glisse 795771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 796771fe6b9SJerome Glisse 797771fe6b9SJerome Glisse if (!lvds) 798771fe6b9SJerome Glisse return NULL; 799771fe6b9SJerome Glisse 800771fe6b9SJerome Glisse fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH); 801771fe6b9SJerome Glisse fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH); 802771fe6b9SJerome Glisse 8038b5c7444SMichel Dänzer /* These should be fail-safe defaults, fingers crossed */ 8048b5c7444SMichel Dänzer lvds->panel_pwr_delay = 200; 8058b5c7444SMichel Dänzer lvds->panel_vcc_delay = 2000; 8068b5c7444SMichel Dänzer 8078b5c7444SMichel Dänzer lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL); 8088b5c7444SMichel Dänzer lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf; 8098b5c7444SMichel Dänzer lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf; 8108b5c7444SMichel Dänzer 811771fe6b9SJerome Glisse if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE) 812de2103e4SAlex Deucher lvds->native_mode.vdisplay = 813771fe6b9SJerome Glisse ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >> 814771fe6b9SJerome Glisse RADEON_VERT_PANEL_SHIFT) + 1; 815771fe6b9SJerome Glisse else 816de2103e4SAlex Deucher lvds->native_mode.vdisplay = 817771fe6b9SJerome Glisse (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1; 818771fe6b9SJerome Glisse 819771fe6b9SJerome Glisse if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE) 820de2103e4SAlex Deucher lvds->native_mode.hdisplay = 821771fe6b9SJerome Glisse (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >> 822771fe6b9SJerome Glisse RADEON_HORZ_PANEL_SHIFT) + 1) * 8; 823771fe6b9SJerome Glisse else 824de2103e4SAlex Deucher lvds->native_mode.hdisplay = 825771fe6b9SJerome Glisse ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8; 826771fe6b9SJerome Glisse 827de2103e4SAlex Deucher if ((lvds->native_mode.hdisplay < 640) || 828de2103e4SAlex Deucher (lvds->native_mode.vdisplay < 480)) { 829de2103e4SAlex Deucher lvds->native_mode.hdisplay = 640; 830de2103e4SAlex Deucher lvds->native_mode.vdisplay = 480; 831771fe6b9SJerome Glisse } 832771fe6b9SJerome Glisse 833771fe6b9SJerome Glisse ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3; 834771fe6b9SJerome Glisse ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel); 835771fe6b9SJerome Glisse if ((ppll_val & 0x000707ff) == 0x1bb) 836771fe6b9SJerome Glisse lvds->use_bios_dividers = false; 837771fe6b9SJerome Glisse else { 838771fe6b9SJerome Glisse lvds->panel_ref_divider = 839771fe6b9SJerome Glisse RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff; 840771fe6b9SJerome Glisse lvds->panel_post_divider = (ppll_val >> 16) & 0x7; 841771fe6b9SJerome Glisse lvds->panel_fb_divider = ppll_val & 0x7ff; 842771fe6b9SJerome Glisse 843771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 844771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 845771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 846771fe6b9SJerome Glisse } 847771fe6b9SJerome Glisse lvds->panel_vcc_delay = 200; 848771fe6b9SJerome Glisse 849771fe6b9SJerome Glisse DRM_INFO("Panel info derived from registers\n"); 850de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 851de2103e4SAlex Deucher lvds->native_mode.vdisplay); 852771fe6b9SJerome Glisse 853771fe6b9SJerome Glisse return lvds; 854771fe6b9SJerome Glisse } 855771fe6b9SJerome Glisse 856771fe6b9SJerome Glisse struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder 857771fe6b9SJerome Glisse *encoder) 858771fe6b9SJerome Glisse { 859771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 860771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 861771fe6b9SJerome Glisse uint16_t lcd_info; 862771fe6b9SJerome Glisse uint32_t panel_setup; 863771fe6b9SJerome Glisse char stmp[30]; 864771fe6b9SJerome Glisse int tmp, i; 865771fe6b9SJerome Glisse struct radeon_encoder_lvds *lvds = NULL; 866771fe6b9SJerome Glisse 8678dfaa8a7SMichel Dänzer if (rdev->bios == NULL) { 8688dfaa8a7SMichel Dänzer lvds = radeon_legacy_get_lvds_info_from_regs(rdev); 8698dfaa8a7SMichel Dänzer goto out; 8708dfaa8a7SMichel Dänzer } 871771fe6b9SJerome Glisse 872771fe6b9SJerome Glisse lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 873771fe6b9SJerome Glisse 874771fe6b9SJerome Glisse if (lcd_info) { 875771fe6b9SJerome Glisse lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL); 876771fe6b9SJerome Glisse 877771fe6b9SJerome Glisse if (!lvds) 878771fe6b9SJerome Glisse return NULL; 879771fe6b9SJerome Glisse 880771fe6b9SJerome Glisse for (i = 0; i < 24; i++) 881771fe6b9SJerome Glisse stmp[i] = RBIOS8(lcd_info + i + 1); 882771fe6b9SJerome Glisse stmp[24] = 0; 883771fe6b9SJerome Glisse 884771fe6b9SJerome Glisse DRM_INFO("Panel ID String: %s\n", stmp); 885771fe6b9SJerome Glisse 886de2103e4SAlex Deucher lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19); 887de2103e4SAlex Deucher lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b); 888771fe6b9SJerome Glisse 889de2103e4SAlex Deucher DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay, 890de2103e4SAlex Deucher lvds->native_mode.vdisplay); 891771fe6b9SJerome Glisse 892771fe6b9SJerome Glisse lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c); 893771fe6b9SJerome Glisse if (lvds->panel_vcc_delay > 2000 || lvds->panel_vcc_delay < 0) 894771fe6b9SJerome Glisse lvds->panel_vcc_delay = 2000; 895771fe6b9SJerome Glisse 896771fe6b9SJerome Glisse lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24); 897771fe6b9SJerome Glisse lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf; 898771fe6b9SJerome Glisse lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf; 899771fe6b9SJerome Glisse 900771fe6b9SJerome Glisse lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e); 901771fe6b9SJerome Glisse lvds->panel_post_divider = RBIOS8(lcd_info + 0x30); 902771fe6b9SJerome Glisse lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31); 903771fe6b9SJerome Glisse if ((lvds->panel_ref_divider != 0) && 904771fe6b9SJerome Glisse (lvds->panel_fb_divider > 3)) 905771fe6b9SJerome Glisse lvds->use_bios_dividers = true; 906771fe6b9SJerome Glisse 907771fe6b9SJerome Glisse panel_setup = RBIOS32(lcd_info + 0x39); 908771fe6b9SJerome Glisse lvds->lvds_gen_cntl = 0xff00; 909771fe6b9SJerome Glisse if (panel_setup & 0x1) 910771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT; 911771fe6b9SJerome Glisse 912771fe6b9SJerome Glisse if ((panel_setup >> 4) & 0x1) 913771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE; 914771fe6b9SJerome Glisse 915771fe6b9SJerome Glisse switch ((panel_setup >> 8) & 0x7) { 916771fe6b9SJerome Glisse case 0: 917771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM; 918771fe6b9SJerome Glisse break; 919771fe6b9SJerome Glisse case 1: 920771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY; 921771fe6b9SJerome Glisse break; 922771fe6b9SJerome Glisse case 2: 923771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY; 924771fe6b9SJerome Glisse break; 925771fe6b9SJerome Glisse default: 926771fe6b9SJerome Glisse break; 927771fe6b9SJerome Glisse } 928771fe6b9SJerome Glisse 929771fe6b9SJerome Glisse if ((panel_setup >> 16) & 0x1) 930771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW; 931771fe6b9SJerome Glisse 932771fe6b9SJerome Glisse if ((panel_setup >> 17) & 0x1) 933771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW; 934771fe6b9SJerome Glisse 935771fe6b9SJerome Glisse if ((panel_setup >> 18) & 0x1) 936771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW; 937771fe6b9SJerome Glisse 938771fe6b9SJerome Glisse if ((panel_setup >> 23) & 0x1) 939771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL; 940771fe6b9SJerome Glisse 941771fe6b9SJerome Glisse lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000); 942771fe6b9SJerome Glisse 943771fe6b9SJerome Glisse for (i = 0; i < 32; i++) { 944771fe6b9SJerome Glisse tmp = RBIOS16(lcd_info + 64 + i * 2); 945771fe6b9SJerome Glisse if (tmp == 0) 946771fe6b9SJerome Glisse break; 947771fe6b9SJerome Glisse 948de2103e4SAlex Deucher if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) && 949771fe6b9SJerome Glisse (RBIOS16(tmp + 2) == 950de2103e4SAlex Deucher lvds->native_mode.vdisplay)) { 951de2103e4SAlex Deucher lvds->native_mode.htotal = RBIOS16(tmp + 17) * 8; 952de2103e4SAlex Deucher lvds->native_mode.hsync_start = RBIOS16(tmp + 21) * 8; 953de2103e4SAlex Deucher lvds->native_mode.hsync_end = (RBIOS8(tmp + 23) + 954de2103e4SAlex Deucher RBIOS16(tmp + 21)) * 8; 955771fe6b9SJerome Glisse 956de2103e4SAlex Deucher lvds->native_mode.vtotal = RBIOS16(tmp + 24); 957de2103e4SAlex Deucher lvds->native_mode.vsync_start = RBIOS16(tmp + 28) & 0x7ff; 958de2103e4SAlex Deucher lvds->native_mode.vsync_end = 959de2103e4SAlex Deucher ((RBIOS16(tmp + 28) & 0xf800) >> 11) + 960de2103e4SAlex Deucher (RBIOS16(tmp + 28) & 0x7ff); 961de2103e4SAlex Deucher 962de2103e4SAlex Deucher lvds->native_mode.clock = RBIOS16(tmp + 9) * 10; 963771fe6b9SJerome Glisse lvds->native_mode.flags = 0; 964de2103e4SAlex Deucher /* set crtc values */ 965de2103e4SAlex Deucher drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V); 966de2103e4SAlex Deucher 967771fe6b9SJerome Glisse } 968771fe6b9SJerome Glisse } 9696fe7ac3fSAlex Deucher } else { 970771fe6b9SJerome Glisse DRM_INFO("No panel info found in BIOS\n"); 9718dfaa8a7SMichel Dänzer lvds = radeon_legacy_get_lvds_info_from_regs(rdev); 9726fe7ac3fSAlex Deucher } 9738dfaa8a7SMichel Dänzer out: 9748dfaa8a7SMichel Dänzer if (lvds) 9758dfaa8a7SMichel Dänzer encoder->native_mode = lvds->native_mode; 976771fe6b9SJerome Glisse return lvds; 977771fe6b9SJerome Glisse } 978771fe6b9SJerome Glisse 979771fe6b9SJerome Glisse static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = { 980771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */ 981771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */ 982771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */ 983771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */ 984771fe6b9SJerome Glisse {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */ 985771fe6b9SJerome Glisse {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */ 986771fe6b9SJerome Glisse {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */ 987771fe6b9SJerome Glisse {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */ 988771fe6b9SJerome Glisse {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */ 989771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */ 990771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */ 991771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */ 992771fe6b9SJerome Glisse {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */ 993771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */ 994771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */ 995771fe6b9SJerome Glisse {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */ 996*fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */ 997*fcec570bSAlex Deucher { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */ 998771fe6b9SJerome Glisse }; 999771fe6b9SJerome Glisse 1000445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder, 1001445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1002771fe6b9SJerome Glisse { 1003445282dbSDave Airlie struct drm_device *dev = encoder->base.dev; 1004445282dbSDave Airlie struct radeon_device *rdev = dev->dev_private; 1005771fe6b9SJerome Glisse int i; 1006771fe6b9SJerome Glisse 1007771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 1008771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1009771fe6b9SJerome Glisse default_tmds_pll[rdev->family][i].value; 1010771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq; 1011771fe6b9SJerome Glisse } 1012771fe6b9SJerome Glisse 1013445282dbSDave Airlie return true; 1014771fe6b9SJerome Glisse } 1015771fe6b9SJerome Glisse 1016445282dbSDave Airlie bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder, 1017445282dbSDave Airlie struct radeon_encoder_int_tmds *tmds) 1018771fe6b9SJerome Glisse { 1019771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1020771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1021771fe6b9SJerome Glisse uint16_t tmds_info; 1022771fe6b9SJerome Glisse int i, n; 1023771fe6b9SJerome Glisse uint8_t ver; 1024771fe6b9SJerome Glisse 1025771fe6b9SJerome Glisse if (rdev->bios == NULL) 1026445282dbSDave Airlie return false; 1027771fe6b9SJerome Glisse 1028771fe6b9SJerome Glisse tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 1029771fe6b9SJerome Glisse 1030771fe6b9SJerome Glisse if (tmds_info) { 1031771fe6b9SJerome Glisse ver = RBIOS8(tmds_info); 1032771fe6b9SJerome Glisse DRM_INFO("DFP table revision: %d\n", ver); 1033771fe6b9SJerome Glisse if (ver == 3) { 1034771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1035771fe6b9SJerome Glisse if (n > 4) 1036771fe6b9SJerome Glisse n = 4; 1037771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1038771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1039771fe6b9SJerome Glisse RBIOS32(tmds_info + i * 10 + 0x08); 1040771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1041771fe6b9SJerome Glisse RBIOS16(tmds_info + i * 10 + 0x10); 1042771fe6b9SJerome Glisse DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n", 1043771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1044771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1045771fe6b9SJerome Glisse } 1046771fe6b9SJerome Glisse } else if (ver == 4) { 1047771fe6b9SJerome Glisse int stride = 0; 1048771fe6b9SJerome Glisse n = RBIOS8(tmds_info + 5) + 1; 1049771fe6b9SJerome Glisse if (n > 4) 1050771fe6b9SJerome Glisse n = 4; 1051771fe6b9SJerome Glisse for (i = 0; i < n; i++) { 1052771fe6b9SJerome Glisse tmds->tmds_pll[i].value = 1053771fe6b9SJerome Glisse RBIOS32(tmds_info + stride + 0x08); 1054771fe6b9SJerome Glisse tmds->tmds_pll[i].freq = 1055771fe6b9SJerome Glisse RBIOS16(tmds_info + stride + 0x10); 1056771fe6b9SJerome Glisse if (i == 0) 1057771fe6b9SJerome Glisse stride += 10; 1058771fe6b9SJerome Glisse else 1059771fe6b9SJerome Glisse stride += 6; 1060771fe6b9SJerome Glisse DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n", 1061771fe6b9SJerome Glisse tmds->tmds_pll[i].freq, 1062771fe6b9SJerome Glisse tmds->tmds_pll[i].value); 1063771fe6b9SJerome Glisse } 1064771fe6b9SJerome Glisse } 1065*fcec570bSAlex Deucher } else { 1066771fe6b9SJerome Glisse DRM_INFO("No TMDS info found in BIOS\n"); 1067*fcec570bSAlex Deucher return false; 1068*fcec570bSAlex Deucher } 1069445282dbSDave Airlie return true; 1070445282dbSDave Airlie } 1071445282dbSDave Airlie 1072*fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder, 1073*fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1074771fe6b9SJerome Glisse { 1075771fe6b9SJerome Glisse struct drm_device *dev = encoder->base.dev; 1076771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1077*fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1078*fcec570bSAlex Deucher 1079*fcec570bSAlex Deucher /* default for macs */ 1080*fcec570bSAlex Deucher i2c_bus = combios_setup_i2c_bus(RADEON_GPIO_MONID); 1081*fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1082*fcec570bSAlex Deucher 1083*fcec570bSAlex Deucher /* XXX some macs have duallink chips */ 1084*fcec570bSAlex Deucher switch (rdev->mode_info.connector_table) { 1085*fcec570bSAlex Deucher case CT_POWERBOOK_EXTERNAL: 1086*fcec570bSAlex Deucher case CT_MINI_EXTERNAL: 1087*fcec570bSAlex Deucher default: 1088*fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1089*fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1090*fcec570bSAlex Deucher break; 1091*fcec570bSAlex Deucher } 1092*fcec570bSAlex Deucher 1093*fcec570bSAlex Deucher return true; 1094*fcec570bSAlex Deucher } 1095*fcec570bSAlex Deucher 1096*fcec570bSAlex Deucher bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder, 1097*fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds) 1098*fcec570bSAlex Deucher { 1099*fcec570bSAlex Deucher struct drm_device *dev = encoder->base.dev; 1100*fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 1101*fcec570bSAlex Deucher uint16_t offset; 1102*fcec570bSAlex Deucher uint8_t ver, id, blocks, clk, data; 1103*fcec570bSAlex Deucher int i; 1104*fcec570bSAlex Deucher enum radeon_combios_ddc gpio; 1105*fcec570bSAlex Deucher struct radeon_i2c_bus_rec i2c_bus; 1106771fe6b9SJerome Glisse 1107771fe6b9SJerome Glisse if (rdev->bios == NULL) 1108*fcec570bSAlex Deucher return false; 1109771fe6b9SJerome Glisse 1110*fcec570bSAlex Deucher tmds->i2c_bus = NULL; 1111*fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 1112*fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE); 1113*fcec570bSAlex Deucher if (offset) { 1114*fcec570bSAlex Deucher ver = RBIOS8(offset); 1115*fcec570bSAlex Deucher DRM_INFO("GPIO Table revision: %d\n", ver); 1116*fcec570bSAlex Deucher blocks = RBIOS8(offset + 2); 1117*fcec570bSAlex Deucher for (i = 0; i < blocks; i++) { 1118*fcec570bSAlex Deucher id = RBIOS8(offset + 3 + (i * 5) + 0); 1119*fcec570bSAlex Deucher if (id == 136) { 1120*fcec570bSAlex Deucher clk = RBIOS8(offset + 3 + (i * 5) + 3); 1121*fcec570bSAlex Deucher data = RBIOS8(offset + 3 + (i * 5) + 4); 1122*fcec570bSAlex Deucher i2c_bus.valid = true; 1123*fcec570bSAlex Deucher i2c_bus.mask_clk_mask = (1 << clk); 1124*fcec570bSAlex Deucher i2c_bus.mask_data_mask = (1 << data); 1125*fcec570bSAlex Deucher i2c_bus.a_clk_mask = (1 << clk); 1126*fcec570bSAlex Deucher i2c_bus.a_data_mask = (1 << data); 1127*fcec570bSAlex Deucher i2c_bus.en_clk_mask = (1 << clk); 1128*fcec570bSAlex Deucher i2c_bus.en_data_mask = (1 << data); 1129*fcec570bSAlex Deucher i2c_bus.y_clk_mask = (1 << clk); 1130*fcec570bSAlex Deucher i2c_bus.y_data_mask = (1 << data); 1131*fcec570bSAlex Deucher i2c_bus.mask_clk_reg = RADEON_GPIOPAD_MASK; 1132*fcec570bSAlex Deucher i2c_bus.mask_data_reg = RADEON_GPIOPAD_MASK; 1133*fcec570bSAlex Deucher i2c_bus.a_clk_reg = RADEON_GPIOPAD_A; 1134*fcec570bSAlex Deucher i2c_bus.a_data_reg = RADEON_GPIOPAD_A; 1135*fcec570bSAlex Deucher i2c_bus.en_clk_reg = RADEON_GPIOPAD_EN; 1136*fcec570bSAlex Deucher i2c_bus.en_data_reg = RADEON_GPIOPAD_EN; 1137*fcec570bSAlex Deucher i2c_bus.y_clk_reg = RADEON_GPIOPAD_Y; 1138*fcec570bSAlex Deucher i2c_bus.y_data_reg = RADEON_GPIOPAD_Y; 1139*fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1140*fcec570bSAlex Deucher tmds->dvo_chip = DVO_SIL164; 1141*fcec570bSAlex Deucher tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ 1142*fcec570bSAlex Deucher break; 1143771fe6b9SJerome Glisse } 1144771fe6b9SJerome Glisse } 1145*fcec570bSAlex Deucher } 1146*fcec570bSAlex Deucher } else { 1147*fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 1148*fcec570bSAlex Deucher if (offset) { 1149*fcec570bSAlex Deucher ver = RBIOS8(offset); 1150*fcec570bSAlex Deucher DRM_INFO("External TMDS Table revision: %d\n", ver); 1151*fcec570bSAlex Deucher tmds->slave_addr = RBIOS8(offset + 4 + 2); 1152*fcec570bSAlex Deucher tmds->slave_addr >>= 1; /* 7 bit addressing */ 1153*fcec570bSAlex Deucher gpio = RBIOS8(offset + 4 + 3); 1154*fcec570bSAlex Deucher switch (gpio) { 1155*fcec570bSAlex Deucher case DDC_MONID: 1156*fcec570bSAlex Deucher i2c_bus = combios_setup_i2c_bus(RADEON_GPIO_MONID); 1157*fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1158*fcec570bSAlex Deucher break; 1159*fcec570bSAlex Deucher case DDC_DVI: 1160*fcec570bSAlex Deucher i2c_bus = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1161*fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1162*fcec570bSAlex Deucher break; 1163*fcec570bSAlex Deucher case DDC_VGA: 1164*fcec570bSAlex Deucher i2c_bus = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1165*fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1166*fcec570bSAlex Deucher break; 1167*fcec570bSAlex Deucher case DDC_CRT2: 1168*fcec570bSAlex Deucher /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */ 1169*fcec570bSAlex Deucher if (rdev->family >= CHIP_R300) 1170*fcec570bSAlex Deucher i2c_bus = combios_setup_i2c_bus(RADEON_GPIO_MONID); 1171*fcec570bSAlex Deucher else 1172*fcec570bSAlex Deucher i2c_bus = combios_setup_i2c_bus(RADEON_GPIO_CRT2_DDC); 1173*fcec570bSAlex Deucher tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); 1174*fcec570bSAlex Deucher break; 1175*fcec570bSAlex Deucher case DDC_LCD: /* MM i2c */ 1176*fcec570bSAlex Deucher DRM_ERROR("MM i2c requires hw i2c engine\n"); 1177*fcec570bSAlex Deucher break; 1178*fcec570bSAlex Deucher default: 1179*fcec570bSAlex Deucher DRM_ERROR("Unsupported gpio %d\n", gpio); 1180*fcec570bSAlex Deucher break; 1181*fcec570bSAlex Deucher } 1182*fcec570bSAlex Deucher } 1183*fcec570bSAlex Deucher } 1184*fcec570bSAlex Deucher 1185*fcec570bSAlex Deucher if (!tmds->i2c_bus) { 1186*fcec570bSAlex Deucher DRM_INFO("No valid Ext TMDS info found in BIOS\n"); 1187*fcec570bSAlex Deucher return false; 1188*fcec570bSAlex Deucher } 1189*fcec570bSAlex Deucher 1190*fcec570bSAlex Deucher return true; 1191*fcec570bSAlex Deucher } 1192771fe6b9SJerome Glisse 1193771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) 1194771fe6b9SJerome Glisse { 1195771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1196771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 1197771fe6b9SJerome Glisse 1198771fe6b9SJerome Glisse rdev->mode_info.connector_table = radeon_connector_table; 1199771fe6b9SJerome Glisse if (rdev->mode_info.connector_table == CT_NONE) { 1200771fe6b9SJerome Glisse #ifdef CONFIG_PPC_PMAC 1201771fe6b9SJerome Glisse if (machine_is_compatible("PowerBook3,3")) { 1202771fe6b9SJerome Glisse /* powerbook with VGA */ 1203771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_VGA; 1204771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook3,4") || 1205771fe6b9SJerome Glisse machine_is_compatible("PowerBook3,5")) { 1206771fe6b9SJerome Glisse /* powerbook with internal tmds */ 1207771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; 1208771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook5,1") || 1209771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,2") || 1210771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,3") || 1211771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,4") || 1212771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,5")) { 1213771fe6b9SJerome Glisse /* powerbook with external single link tmds (sil164) */ 1214771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 1215771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook5,6")) { 1216771fe6b9SJerome Glisse /* powerbook with external dual or single link tmds */ 1217771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 1218771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook5,7") || 1219771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,8") || 1220771fe6b9SJerome Glisse machine_is_compatible("PowerBook5,9")) { 1221771fe6b9SJerome Glisse /* PowerBook6,2 ? */ 1222771fe6b9SJerome Glisse /* powerbook with external dual link tmds (sil1178?) */ 1223771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 1224771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerBook4,1") || 1225771fe6b9SJerome Glisse machine_is_compatible("PowerBook4,2") || 1226771fe6b9SJerome Glisse machine_is_compatible("PowerBook4,3") || 1227771fe6b9SJerome Glisse machine_is_compatible("PowerBook6,3") || 1228771fe6b9SJerome Glisse machine_is_compatible("PowerBook6,5") || 1229771fe6b9SJerome Glisse machine_is_compatible("PowerBook6,7")) { 1230771fe6b9SJerome Glisse /* ibook */ 1231771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IBOOK; 1232771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac4,4")) { 1233771fe6b9SJerome Glisse /* emac */ 1234771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_EMAC; 1235771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac10,1")) { 1236771fe6b9SJerome Glisse /* mini with internal tmds */ 1237771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_INTERNAL; 1238771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac10,2")) { 1239771fe6b9SJerome Glisse /* mini with external tmds */ 1240771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_MINI_EXTERNAL; 1241771fe6b9SJerome Glisse } else if (machine_is_compatible("PowerMac12,1")) { 1242771fe6b9SJerome Glisse /* PowerMac8,1 ? */ 1243771fe6b9SJerome Glisse /* imac g5 isight */ 1244771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; 1245771fe6b9SJerome Glisse } else 1246771fe6b9SJerome Glisse #endif /* CONFIG_PPC_PMAC */ 1247771fe6b9SJerome Glisse rdev->mode_info.connector_table = CT_GENERIC; 1248771fe6b9SJerome Glisse } 1249771fe6b9SJerome Glisse 1250771fe6b9SJerome Glisse switch (rdev->mode_info.connector_table) { 1251771fe6b9SJerome Glisse case CT_GENERIC: 1252771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (generic)\n", 1253771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1254771fe6b9SJerome Glisse /* these are the most common settings */ 1255771fe6b9SJerome Glisse if (rdev->flags & RADEON_SINGLE_CRTC) { 1256771fe6b9SJerome Glisse /* VGA - primary dac */ 1257771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1258771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1259771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1260771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1261771fe6b9SJerome Glisse 1), 1262771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1263771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1264771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1265771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1266b75fad06SAlex Deucher &ddc_i2c, 1267b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1268771fe6b9SJerome Glisse } else if (rdev->flags & RADEON_IS_MOBILITY) { 1269771fe6b9SJerome Glisse /* LVDS */ 1270771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_LCD_GPIO_MASK); 1271771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1272771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1273771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1274771fe6b9SJerome Glisse 0), 1275771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1276771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1277771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1278771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 1279b75fad06SAlex Deucher &ddc_i2c, 1280b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_LVDS); 1281771fe6b9SJerome Glisse 1282771fe6b9SJerome Glisse /* VGA - primary dac */ 1283771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1284771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1285771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1286771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1287771fe6b9SJerome Glisse 1), 1288771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1289771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1290771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1291771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_VGA, 1292b75fad06SAlex Deucher &ddc_i2c, 1293b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1294771fe6b9SJerome Glisse } else { 1295771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1296771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1297771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1298771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1299771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1300771fe6b9SJerome Glisse 0), 1301771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1302771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1303771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1304771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1305771fe6b9SJerome Glisse 2), 1306771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1307771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1308771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1309771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1310771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 1311b75fad06SAlex Deucher &ddc_i2c, 1312b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I); 1313771fe6b9SJerome Glisse 1314771fe6b9SJerome Glisse /* VGA - primary dac */ 1315771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(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 } 1327771fe6b9SJerome Glisse 1328771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 1329771fe6b9SJerome Glisse /* TV - tv dac */ 1330771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1331771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1332771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1333771fe6b9SJerome Glisse 2), 1334771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1335771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, 1336771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1337771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1338b75fad06SAlex Deucher &ddc_i2c, 1339b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1340771fe6b9SJerome Glisse } 1341771fe6b9SJerome Glisse break; 1342771fe6b9SJerome Glisse case CT_IBOOK: 1343771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (ibook)\n", 1344771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1345771fe6b9SJerome Glisse /* LVDS */ 1346771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1347771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1348771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1349771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1350771fe6b9SJerome Glisse 0), 1351771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1352771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1353b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1354b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_LVDS); 1355771fe6b9SJerome Glisse /* VGA - TV DAC */ 1356771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1357771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1358771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1359771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1360771fe6b9SJerome Glisse 2), 1361771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1362771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1363b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1364b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1365771fe6b9SJerome Glisse /* TV - TV DAC */ 1366771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1367771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1368771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1369771fe6b9SJerome Glisse 2), 1370771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1371771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1372771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1373b75fad06SAlex Deucher &ddc_i2c, 1374b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1375771fe6b9SJerome Glisse break; 1376771fe6b9SJerome Glisse case CT_POWERBOOK_EXTERNAL: 1377771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook external tmds)\n", 1378771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1379771fe6b9SJerome Glisse /* LVDS */ 1380771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1381771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1382771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1383771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1384771fe6b9SJerome Glisse 0), 1385771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1386771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1387b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1388b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_LVDS); 1389771fe6b9SJerome Glisse /* DVI-I - primary dac, ext tmds */ 1390771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1391771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1392771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1393771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1394771fe6b9SJerome Glisse 0), 1395771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1396771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1397771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1398771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1399771fe6b9SJerome Glisse 1), 1400771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1401b75fad06SAlex Deucher /* XXX some are SL */ 1402771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1403771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1404771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1405b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1406b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I); 1407771fe6b9SJerome Glisse /* TV - TV DAC */ 1408771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1409771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1410771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1411771fe6b9SJerome Glisse 2), 1412771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1413771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1414771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1415b75fad06SAlex Deucher &ddc_i2c, 1416b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1417771fe6b9SJerome Glisse break; 1418771fe6b9SJerome Glisse case CT_POWERBOOK_INTERNAL: 1419771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook internal tmds)\n", 1420771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1421771fe6b9SJerome Glisse /* LVDS */ 1422771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1423771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1424771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1425771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1426771fe6b9SJerome Glisse 0), 1427771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1428771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1429b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1430b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_LVDS); 1431771fe6b9SJerome Glisse /* DVI-I - primary dac, int tmds */ 1432771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1433771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1434771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1435771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1436771fe6b9SJerome Glisse 0), 1437771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1438771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1439771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1440771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1441771fe6b9SJerome Glisse 1), 1442771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1443771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, 1444771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1445771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1446b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1447b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I); 1448771fe6b9SJerome Glisse /* TV - TV DAC */ 1449771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1450771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1451771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1452771fe6b9SJerome Glisse 2), 1453771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1454771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1455771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1456b75fad06SAlex Deucher &ddc_i2c, 1457b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1458771fe6b9SJerome Glisse break; 1459771fe6b9SJerome Glisse case CT_POWERBOOK_VGA: 1460771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (powerbook vga)\n", 1461771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1462771fe6b9SJerome Glisse /* LVDS */ 1463771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1464771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1465771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1466771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1467771fe6b9SJerome Glisse 0), 1468771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1469771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT, 1470b75fad06SAlex Deucher DRM_MODE_CONNECTOR_LVDS, &ddc_i2c, 1471b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_LVDS); 1472771fe6b9SJerome Glisse /* VGA - primary dac */ 1473771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1474771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1475771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1476771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1477771fe6b9SJerome Glisse 1), 1478771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1479771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT, 1480b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1481b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1482771fe6b9SJerome Glisse /* TV - TV DAC */ 1483771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1484771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1485771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1486771fe6b9SJerome Glisse 2), 1487771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1488771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1489771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1490b75fad06SAlex Deucher &ddc_i2c, 1491b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1492771fe6b9SJerome Glisse break; 1493771fe6b9SJerome Glisse case CT_MINI_EXTERNAL: 1494771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini external tmds)\n", 1495771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1496771fe6b9SJerome Glisse /* DVI-I - tv dac, ext tmds */ 1497771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_CRT2_DDC); 1498771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1499771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1500771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1501771fe6b9SJerome Glisse 0), 1502771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1503771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1504771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1505771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1506771fe6b9SJerome Glisse 2), 1507771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1508b75fad06SAlex Deucher /* XXX are any DL? */ 1509771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1510771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT | 1511771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1512b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1513b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I); 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, 1, 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_INTERNAL: 1526771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (mini internal tmds)\n", 1527771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1528771fe6b9SJerome Glisse /* DVI-I - tv dac, int tmds */ 1529771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_CRT2_DDC); 1530771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1531771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1532771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1533771fe6b9SJerome Glisse 0), 1534771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_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); 1540771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, 1541771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT | 1542771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1543b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVII, &ddc_i2c, 1544b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I); 1545771fe6b9SJerome Glisse /* TV - TV DAC */ 1546771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1547771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1548771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1549771fe6b9SJerome Glisse 2), 1550771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1551771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT, 1552771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1553b75fad06SAlex Deucher &ddc_i2c, 1554b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1555771fe6b9SJerome Glisse break; 1556771fe6b9SJerome Glisse case CT_IMAC_G5_ISIGHT: 1557771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (imac g5 isight)\n", 1558771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1559771fe6b9SJerome Glisse /* DVI-D - int tmds */ 1560771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_MONID); 1561771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1562771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1563771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1564771fe6b9SJerome Glisse 0), 1565771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1566771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT, 1567b75fad06SAlex Deucher DRM_MODE_CONNECTOR_DVID, &ddc_i2c, 1568b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D); 1569771fe6b9SJerome Glisse /* VGA - tv dac */ 1570771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1571771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1572771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1573771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1574771fe6b9SJerome Glisse 2), 1575771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1576771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1577b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1578b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1579771fe6b9SJerome Glisse /* TV - TV DAC */ 1580771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1581771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1582771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1583771fe6b9SJerome Glisse 2), 1584771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1585771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1586771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1587b75fad06SAlex Deucher &ddc_i2c, 1588b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1589771fe6b9SJerome Glisse break; 1590771fe6b9SJerome Glisse case CT_EMAC: 1591771fe6b9SJerome Glisse DRM_INFO("Connector Table: %d (emac)\n", 1592771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1593771fe6b9SJerome Glisse /* VGA - primary dac */ 1594771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1595771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1596771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1597771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1598771fe6b9SJerome Glisse 1), 1599771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1600771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT, 1601b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1602b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1603771fe6b9SJerome Glisse /* VGA - tv dac */ 1604771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_CRT2_DDC); 1605771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1606771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1607771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1608771fe6b9SJerome Glisse 2), 1609771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1610771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT, 1611b75fad06SAlex Deucher DRM_MODE_CONNECTOR_VGA, &ddc_i2c, 1612b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1613771fe6b9SJerome Glisse /* TV - TV DAC */ 1614771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1615771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1616771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1617771fe6b9SJerome Glisse 2), 1618771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1619771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT, 1620771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 1621b75fad06SAlex Deucher &ddc_i2c, 1622b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1623771fe6b9SJerome Glisse break; 1624771fe6b9SJerome Glisse default: 1625771fe6b9SJerome Glisse DRM_INFO("Connector table: %d (invalid)\n", 1626771fe6b9SJerome Glisse rdev->mode_info.connector_table); 1627771fe6b9SJerome Glisse return false; 1628771fe6b9SJerome Glisse } 1629771fe6b9SJerome Glisse 1630771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 1631771fe6b9SJerome Glisse 1632771fe6b9SJerome Glisse return true; 1633771fe6b9SJerome Glisse } 1634771fe6b9SJerome Glisse 1635771fe6b9SJerome Glisse static bool radeon_apply_legacy_quirks(struct drm_device *dev, 1636771fe6b9SJerome Glisse int bios_index, 1637771fe6b9SJerome Glisse enum radeon_combios_connector 1638771fe6b9SJerome Glisse *legacy_connector, 1639771fe6b9SJerome Glisse struct radeon_i2c_bus_rec *ddc_i2c) 1640771fe6b9SJerome Glisse { 1641771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1642771fe6b9SJerome Glisse 1643771fe6b9SJerome Glisse /* XPRESS DDC quirks */ 1644771fe6b9SJerome Glisse if ((rdev->family == CHIP_RS400 || 1645771fe6b9SJerome Glisse rdev->family == CHIP_RS480) && 1646771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 1647771fe6b9SJerome Glisse *ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_MONID); 1648771fe6b9SJerome Glisse else if ((rdev->family == CHIP_RS400 || 1649771fe6b9SJerome Glisse rdev->family == CHIP_RS480) && 1650771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_MONID) { 1651771fe6b9SJerome Glisse ddc_i2c->valid = true; 1652771fe6b9SJerome Glisse ddc_i2c->mask_clk_mask = (0x20 << 8); 1653771fe6b9SJerome Glisse ddc_i2c->mask_data_mask = 0x80; 1654771fe6b9SJerome Glisse ddc_i2c->a_clk_mask = (0x20 << 8); 1655771fe6b9SJerome Glisse ddc_i2c->a_data_mask = 0x80; 16569b9fe724SAlex Deucher ddc_i2c->en_clk_mask = (0x20 << 8); 16579b9fe724SAlex Deucher ddc_i2c->en_data_mask = 0x80; 16589b9fe724SAlex Deucher ddc_i2c->y_clk_mask = (0x20 << 8); 16599b9fe724SAlex Deucher ddc_i2c->y_data_mask = 0x80; 1660771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg = RADEON_GPIOPAD_MASK; 1661771fe6b9SJerome Glisse ddc_i2c->mask_data_reg = RADEON_GPIOPAD_MASK; 1662771fe6b9SJerome Glisse ddc_i2c->a_clk_reg = RADEON_GPIOPAD_A; 1663771fe6b9SJerome Glisse ddc_i2c->a_data_reg = RADEON_GPIOPAD_A; 16649b9fe724SAlex Deucher ddc_i2c->en_clk_reg = RADEON_GPIOPAD_EN; 16659b9fe724SAlex Deucher ddc_i2c->en_data_reg = RADEON_GPIOPAD_EN; 1666*fcec570bSAlex Deucher ddc_i2c->y_clk_reg = RADEON_GPIOPAD_Y; 1667*fcec570bSAlex Deucher ddc_i2c->y_data_reg = RADEON_GPIOPAD_Y; 1668771fe6b9SJerome Glisse } 1669771fe6b9SJerome Glisse 1670*fcec570bSAlex Deucher /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */ 1671*fcec570bSAlex Deucher if ((rdev->family >= CHIP_R300) && 1672*fcec570bSAlex Deucher ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 1673*fcec570bSAlex Deucher *ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1674*fcec570bSAlex Deucher 1675771fe6b9SJerome Glisse /* Certain IBM chipset RN50s have a BIOS reporting two VGAs, 1676771fe6b9SJerome Glisse one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */ 1677771fe6b9SJerome Glisse if (dev->pdev->device == 0x515e && 1678771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x1014) { 1679771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_CRT_LEGACY && 1680771fe6b9SJerome Glisse ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) 1681771fe6b9SJerome Glisse return false; 1682771fe6b9SJerome Glisse } 1683771fe6b9SJerome Glisse 1684771fe6b9SJerome Glisse /* Some RV100 cards with 2 VGA ports show up with DVI+VGA */ 1685771fe6b9SJerome Glisse if (dev->pdev->device == 0x5159 && 1686771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x1002 && 1687771fe6b9SJerome Glisse dev->pdev->subsystem_device == 0x013a) { 1688771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_DVI_I_LEGACY) 1689771fe6b9SJerome Glisse *legacy_connector = CONNECTOR_CRT_LEGACY; 1690771fe6b9SJerome Glisse 1691771fe6b9SJerome Glisse } 1692771fe6b9SJerome Glisse 1693771fe6b9SJerome Glisse /* X300 card with extra non-existent DVI port */ 1694771fe6b9SJerome Glisse if (dev->pdev->device == 0x5B60 && 1695771fe6b9SJerome Glisse dev->pdev->subsystem_vendor == 0x17af && 1696771fe6b9SJerome Glisse dev->pdev->subsystem_device == 0x201e && bios_index == 2) { 1697771fe6b9SJerome Glisse if (*legacy_connector == CONNECTOR_DVI_I_LEGACY) 1698771fe6b9SJerome Glisse return false; 1699771fe6b9SJerome Glisse } 1700771fe6b9SJerome Glisse 1701771fe6b9SJerome Glisse return true; 1702771fe6b9SJerome Glisse } 1703771fe6b9SJerome Glisse 1704790cfb34SAlex Deucher static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev) 1705790cfb34SAlex Deucher { 1706790cfb34SAlex Deucher /* Acer 5102 has non-existent TV port */ 1707790cfb34SAlex Deucher if (dev->pdev->device == 0x5975 && 1708790cfb34SAlex Deucher dev->pdev->subsystem_vendor == 0x1025 && 1709790cfb34SAlex Deucher dev->pdev->subsystem_device == 0x009f) 1710790cfb34SAlex Deucher return false; 1711790cfb34SAlex Deucher 1712fc7f7119SAlex Deucher /* HP dc5750 has non-existent TV port */ 1713fc7f7119SAlex Deucher if (dev->pdev->device == 0x5974 && 1714fc7f7119SAlex Deucher dev->pdev->subsystem_vendor == 0x103c && 1715fc7f7119SAlex Deucher dev->pdev->subsystem_device == 0x280a) 1716fc7f7119SAlex Deucher return false; 1717fc7f7119SAlex Deucher 1718790cfb34SAlex Deucher return true; 1719790cfb34SAlex Deucher } 1720790cfb34SAlex Deucher 1721b75fad06SAlex Deucher static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d) 1722b75fad06SAlex Deucher { 1723b75fad06SAlex Deucher struct radeon_device *rdev = dev->dev_private; 1724b75fad06SAlex Deucher uint32_t ext_tmds_info; 1725b75fad06SAlex Deucher 1726b75fad06SAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 1727b75fad06SAlex Deucher if (is_dvi_d) 1728b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 1729b75fad06SAlex Deucher else 1730b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 1731b75fad06SAlex Deucher } 1732b75fad06SAlex Deucher ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 1733b75fad06SAlex Deucher if (ext_tmds_info) { 1734b75fad06SAlex Deucher uint8_t rev = RBIOS8(ext_tmds_info); 1735b75fad06SAlex Deucher uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5); 1736b75fad06SAlex Deucher if (rev >= 3) { 1737b75fad06SAlex Deucher if (is_dvi_d) 1738b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 1739b75fad06SAlex Deucher else 1740b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 1741b75fad06SAlex Deucher } else { 1742b75fad06SAlex Deucher if (flags & 1) { 1743b75fad06SAlex Deucher if (is_dvi_d) 1744b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 1745b75fad06SAlex Deucher else 1746b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 1747b75fad06SAlex Deucher } 1748b75fad06SAlex Deucher } 1749b75fad06SAlex Deucher } 1750b75fad06SAlex Deucher if (is_dvi_d) 1751b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 1752b75fad06SAlex Deucher else 1753b75fad06SAlex Deucher return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 1754b75fad06SAlex Deucher } 1755b75fad06SAlex Deucher 1756771fe6b9SJerome Glisse bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) 1757771fe6b9SJerome Glisse { 1758771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 1759771fe6b9SJerome Glisse uint32_t conn_info, entry, devices; 1760b75fad06SAlex Deucher uint16_t tmp, connector_object_id; 1761771fe6b9SJerome Glisse enum radeon_combios_ddc ddc_type; 1762771fe6b9SJerome Glisse enum radeon_combios_connector connector; 1763771fe6b9SJerome Glisse int i = 0; 1764771fe6b9SJerome Glisse struct radeon_i2c_bus_rec ddc_i2c; 1765771fe6b9SJerome Glisse 1766771fe6b9SJerome Glisse if (rdev->bios == NULL) 1767771fe6b9SJerome Glisse return false; 1768771fe6b9SJerome Glisse 1769771fe6b9SJerome Glisse conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE); 1770771fe6b9SJerome Glisse if (conn_info) { 1771771fe6b9SJerome Glisse for (i = 0; i < 4; i++) { 1772771fe6b9SJerome Glisse entry = conn_info + 2 + i * 2; 1773771fe6b9SJerome Glisse 1774771fe6b9SJerome Glisse if (!RBIOS16(entry)) 1775771fe6b9SJerome Glisse break; 1776771fe6b9SJerome Glisse 1777771fe6b9SJerome Glisse tmp = RBIOS16(entry); 1778771fe6b9SJerome Glisse 1779771fe6b9SJerome Glisse connector = (tmp >> 12) & 0xf; 1780771fe6b9SJerome Glisse 1781771fe6b9SJerome Glisse ddc_type = (tmp >> 8) & 0xf; 1782771fe6b9SJerome Glisse switch (ddc_type) { 1783771fe6b9SJerome Glisse case DDC_MONID: 1784771fe6b9SJerome Glisse ddc_i2c = 1785771fe6b9SJerome Glisse combios_setup_i2c_bus(RADEON_GPIO_MONID); 1786771fe6b9SJerome Glisse break; 1787771fe6b9SJerome Glisse case DDC_DVI: 1788771fe6b9SJerome Glisse ddc_i2c = 1789771fe6b9SJerome Glisse combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1790771fe6b9SJerome Glisse break; 1791771fe6b9SJerome Glisse case DDC_VGA: 1792771fe6b9SJerome Glisse ddc_i2c = 1793771fe6b9SJerome Glisse combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1794771fe6b9SJerome Glisse break; 1795771fe6b9SJerome Glisse case DDC_CRT2: 1796771fe6b9SJerome Glisse ddc_i2c = 1797771fe6b9SJerome Glisse combios_setup_i2c_bus(RADEON_GPIO_CRT2_DDC); 1798771fe6b9SJerome Glisse break; 1799771fe6b9SJerome Glisse default: 1800771fe6b9SJerome Glisse break; 1801771fe6b9SJerome Glisse } 1802771fe6b9SJerome Glisse 18032d152c6bSAlex Deucher if (!radeon_apply_legacy_quirks(dev, i, &connector, 18042d152c6bSAlex Deucher &ddc_i2c)) 18052d152c6bSAlex Deucher continue; 1806771fe6b9SJerome Glisse 1807771fe6b9SJerome Glisse switch (connector) { 1808771fe6b9SJerome Glisse case CONNECTOR_PROPRIETARY_LEGACY: 1809771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) 1810771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 1811771fe6b9SJerome Glisse else 1812771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 1813771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1814771fe6b9SJerome Glisse radeon_get_encoder_id 1815771fe6b9SJerome Glisse (dev, devices, 0), 1816771fe6b9SJerome Glisse devices); 1817771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 1818771fe6b9SJerome Glisse legacy_connector_convert 1819771fe6b9SJerome Glisse [connector], 1820b75fad06SAlex Deucher &ddc_i2c, 1821b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D); 1822771fe6b9SJerome Glisse break; 1823771fe6b9SJerome Glisse case CONNECTOR_CRT_LEGACY: 1824771fe6b9SJerome Glisse if (tmp & 0x1) { 1825771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT2_SUPPORT; 1826771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1827771fe6b9SJerome Glisse radeon_get_encoder_id 1828771fe6b9SJerome Glisse (dev, 1829771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1830771fe6b9SJerome Glisse 2), 1831771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1832771fe6b9SJerome Glisse } else { 1833771fe6b9SJerome Glisse devices = ATOM_DEVICE_CRT1_SUPPORT; 1834771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1835771fe6b9SJerome Glisse radeon_get_encoder_id 1836771fe6b9SJerome Glisse (dev, 1837771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1838771fe6b9SJerome Glisse 1), 1839771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1840771fe6b9SJerome Glisse } 1841771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1842771fe6b9SJerome Glisse i, 1843771fe6b9SJerome Glisse devices, 1844771fe6b9SJerome Glisse legacy_connector_convert 1845771fe6b9SJerome Glisse [connector], 1846b75fad06SAlex Deucher &ddc_i2c, 1847b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1848771fe6b9SJerome Glisse break; 1849771fe6b9SJerome Glisse case CONNECTOR_DVI_I_LEGACY: 1850771fe6b9SJerome Glisse devices = 0; 1851771fe6b9SJerome Glisse if (tmp & 0x1) { 1852771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT2_SUPPORT; 1853771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1854771fe6b9SJerome Glisse radeon_get_encoder_id 1855771fe6b9SJerome Glisse (dev, 1856771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT, 1857771fe6b9SJerome Glisse 2), 1858771fe6b9SJerome Glisse ATOM_DEVICE_CRT2_SUPPORT); 1859771fe6b9SJerome Glisse } else { 1860771fe6b9SJerome Glisse devices |= ATOM_DEVICE_CRT1_SUPPORT; 1861771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1862771fe6b9SJerome Glisse radeon_get_encoder_id 1863771fe6b9SJerome Glisse (dev, 1864771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1865771fe6b9SJerome Glisse 1), 1866771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1867771fe6b9SJerome Glisse } 1868771fe6b9SJerome Glisse if ((tmp >> 4) & 0x1) { 1869771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP2_SUPPORT; 1870771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1871771fe6b9SJerome Glisse radeon_get_encoder_id 1872771fe6b9SJerome Glisse (dev, 1873771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT, 1874771fe6b9SJerome Glisse 0), 1875771fe6b9SJerome Glisse ATOM_DEVICE_DFP2_SUPPORT); 1876b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 0); 1877771fe6b9SJerome Glisse } else { 1878771fe6b9SJerome Glisse devices |= ATOM_DEVICE_DFP1_SUPPORT; 1879771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1880771fe6b9SJerome Glisse radeon_get_encoder_id 1881771fe6b9SJerome Glisse (dev, 1882771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1883771fe6b9SJerome Glisse 0), 1884771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1885b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 1886771fe6b9SJerome Glisse } 1887771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1888771fe6b9SJerome Glisse i, 1889771fe6b9SJerome Glisse devices, 1890771fe6b9SJerome Glisse legacy_connector_convert 1891771fe6b9SJerome Glisse [connector], 1892b75fad06SAlex Deucher &ddc_i2c, 1893b75fad06SAlex Deucher connector_object_id); 1894771fe6b9SJerome Glisse break; 1895771fe6b9SJerome Glisse case CONNECTOR_DVI_D_LEGACY: 1896b75fad06SAlex Deucher if ((tmp >> 4) & 0x1) { 1897771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP2_SUPPORT; 1898b75fad06SAlex Deucher connector_object_id = combios_check_dl_dvi(dev, 1); 1899b75fad06SAlex Deucher } else { 1900771fe6b9SJerome Glisse devices = ATOM_DEVICE_DFP1_SUPPORT; 1901b75fad06SAlex Deucher connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 1902b75fad06SAlex Deucher } 1903771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1904771fe6b9SJerome Glisse radeon_get_encoder_id 1905771fe6b9SJerome Glisse (dev, devices, 0), 1906771fe6b9SJerome Glisse devices); 1907771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, devices, 1908771fe6b9SJerome Glisse legacy_connector_convert 1909771fe6b9SJerome Glisse [connector], 1910b75fad06SAlex Deucher &ddc_i2c, 1911b75fad06SAlex Deucher connector_object_id); 1912771fe6b9SJerome Glisse break; 1913771fe6b9SJerome Glisse case CONNECTOR_CTV_LEGACY: 1914771fe6b9SJerome Glisse case CONNECTOR_STV_LEGACY: 1915771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1916771fe6b9SJerome Glisse radeon_get_encoder_id 1917771fe6b9SJerome Glisse (dev, 1918771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1919771fe6b9SJerome Glisse 2), 1920771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 1921771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, i, 1922771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 1923771fe6b9SJerome Glisse legacy_connector_convert 1924771fe6b9SJerome Glisse [connector], 1925b75fad06SAlex Deucher &ddc_i2c, 1926b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 1927771fe6b9SJerome Glisse break; 1928771fe6b9SJerome Glisse default: 1929771fe6b9SJerome Glisse DRM_ERROR("Unknown connector type: %d\n", 1930771fe6b9SJerome Glisse connector); 1931771fe6b9SJerome Glisse continue; 1932771fe6b9SJerome Glisse } 1933771fe6b9SJerome Glisse 1934771fe6b9SJerome Glisse } 1935771fe6b9SJerome Glisse } else { 1936771fe6b9SJerome Glisse uint16_t tmds_info = 1937771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); 1938771fe6b9SJerome Glisse if (tmds_info) { 1939771fe6b9SJerome Glisse DRM_DEBUG("Found DFP table, assuming DVI connector\n"); 1940771fe6b9SJerome Glisse 1941771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1942771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1943771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT, 1944771fe6b9SJerome Glisse 1), 1945771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT); 1946771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1947771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1948771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1949771fe6b9SJerome Glisse 0), 1950771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT); 1951771fe6b9SJerome Glisse 1952771fe6b9SJerome Glisse ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_DVI_DDC); 1953771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 1954771fe6b9SJerome Glisse 0, 1955771fe6b9SJerome Glisse ATOM_DEVICE_CRT1_SUPPORT | 1956771fe6b9SJerome Glisse ATOM_DEVICE_DFP1_SUPPORT, 1957771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_DVII, 1958b75fad06SAlex Deucher &ddc_i2c, 1959b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I); 1960771fe6b9SJerome Glisse } else { 1961d0c403e9SAlex Deucher uint16_t crt_info = 1962d0c403e9SAlex Deucher combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 1963d0c403e9SAlex Deucher DRM_DEBUG("Found CRT table, assuming VGA connector\n"); 1964d0c403e9SAlex Deucher if (crt_info) { 1965d0c403e9SAlex Deucher radeon_add_legacy_encoder(dev, 1966d0c403e9SAlex Deucher radeon_get_encoder_id(dev, 1967d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 1968d0c403e9SAlex Deucher 1), 1969d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT); 1970d0c403e9SAlex Deucher ddc_i2c = combios_setup_i2c_bus(RADEON_GPIO_VGA_DDC); 1971d0c403e9SAlex Deucher radeon_add_legacy_connector(dev, 1972d0c403e9SAlex Deucher 0, 1973d0c403e9SAlex Deucher ATOM_DEVICE_CRT1_SUPPORT, 1974d0c403e9SAlex Deucher DRM_MODE_CONNECTOR_VGA, 1975b75fad06SAlex Deucher &ddc_i2c, 1976b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_VGA); 1977d0c403e9SAlex Deucher } else { 1978771fe6b9SJerome Glisse DRM_DEBUG("No connector info found\n"); 1979771fe6b9SJerome Glisse return false; 1980771fe6b9SJerome Glisse } 1981771fe6b9SJerome Glisse } 1982d0c403e9SAlex Deucher } 1983771fe6b9SJerome Glisse 1984771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) { 1985771fe6b9SJerome Glisse uint16_t lcd_info = 1986771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); 1987771fe6b9SJerome Glisse if (lcd_info) { 1988771fe6b9SJerome Glisse uint16_t lcd_ddc_info = 1989771fe6b9SJerome Glisse combios_get_table_offset(dev, 1990771fe6b9SJerome Glisse COMBIOS_LCD_DDC_INFO_TABLE); 1991771fe6b9SJerome Glisse 1992771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 1993771fe6b9SJerome Glisse radeon_get_encoder_id(dev, 1994771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 1995771fe6b9SJerome Glisse 0), 1996771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT); 1997771fe6b9SJerome Glisse 1998771fe6b9SJerome Glisse if (lcd_ddc_info) { 1999771fe6b9SJerome Glisse ddc_type = RBIOS8(lcd_ddc_info + 2); 2000771fe6b9SJerome Glisse switch (ddc_type) { 2001771fe6b9SJerome Glisse case DDC_MONID: 2002771fe6b9SJerome Glisse ddc_i2c = 2003771fe6b9SJerome Glisse combios_setup_i2c_bus 2004771fe6b9SJerome Glisse (RADEON_GPIO_MONID); 2005771fe6b9SJerome Glisse break; 2006771fe6b9SJerome Glisse case DDC_DVI: 2007771fe6b9SJerome Glisse ddc_i2c = 2008771fe6b9SJerome Glisse combios_setup_i2c_bus 2009771fe6b9SJerome Glisse (RADEON_GPIO_DVI_DDC); 2010771fe6b9SJerome Glisse break; 2011771fe6b9SJerome Glisse case DDC_VGA: 2012771fe6b9SJerome Glisse ddc_i2c = 2013771fe6b9SJerome Glisse combios_setup_i2c_bus 2014771fe6b9SJerome Glisse (RADEON_GPIO_VGA_DDC); 2015771fe6b9SJerome Glisse break; 2016771fe6b9SJerome Glisse case DDC_CRT2: 2017771fe6b9SJerome Glisse ddc_i2c = 2018771fe6b9SJerome Glisse combios_setup_i2c_bus 2019771fe6b9SJerome Glisse (RADEON_GPIO_CRT2_DDC); 2020771fe6b9SJerome Glisse break; 2021771fe6b9SJerome Glisse case DDC_LCD: 2022771fe6b9SJerome Glisse ddc_i2c = 2023771fe6b9SJerome Glisse combios_setup_i2c_bus 2024771fe6b9SJerome Glisse (RADEON_LCD_GPIO_MASK); 2025771fe6b9SJerome Glisse ddc_i2c.mask_clk_mask = 2026771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2027771fe6b9SJerome Glisse ddc_i2c.mask_data_mask = 2028771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2029771fe6b9SJerome Glisse ddc_i2c.a_clk_mask = 2030771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2031771fe6b9SJerome Glisse ddc_i2c.a_data_mask = 2032771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 20339b9fe724SAlex Deucher ddc_i2c.en_clk_mask = 2034771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 20359b9fe724SAlex Deucher ddc_i2c.en_data_mask = 2036771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 20379b9fe724SAlex Deucher ddc_i2c.y_clk_mask = 2038771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 20399b9fe724SAlex Deucher ddc_i2c.y_data_mask = 2040771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2041771fe6b9SJerome Glisse break; 2042771fe6b9SJerome Glisse case DDC_GPIO: 2043771fe6b9SJerome Glisse ddc_i2c = 2044771fe6b9SJerome Glisse combios_setup_i2c_bus 2045771fe6b9SJerome Glisse (RADEON_MDGPIO_EN_REG); 2046771fe6b9SJerome Glisse ddc_i2c.mask_clk_mask = 2047771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2048771fe6b9SJerome Glisse ddc_i2c.mask_data_mask = 2049771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2050771fe6b9SJerome Glisse ddc_i2c.a_clk_mask = 2051771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 2052771fe6b9SJerome Glisse ddc_i2c.a_data_mask = 2053771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 20549b9fe724SAlex Deucher ddc_i2c.en_clk_mask = 2055771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 20569b9fe724SAlex Deucher ddc_i2c.en_data_mask = 2057771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 20589b9fe724SAlex Deucher ddc_i2c.y_clk_mask = 2059771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 3); 20609b9fe724SAlex Deucher ddc_i2c.y_data_mask = 2061771fe6b9SJerome Glisse RBIOS32(lcd_ddc_info + 7); 2062771fe6b9SJerome Glisse break; 2063771fe6b9SJerome Glisse default: 2064771fe6b9SJerome Glisse ddc_i2c.valid = false; 2065771fe6b9SJerome Glisse break; 2066771fe6b9SJerome Glisse } 2067771fe6b9SJerome Glisse DRM_DEBUG("LCD DDC Info Table found!\n"); 2068771fe6b9SJerome Glisse } else 2069771fe6b9SJerome Glisse ddc_i2c.valid = false; 2070771fe6b9SJerome Glisse 2071771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 2072771fe6b9SJerome Glisse 5, 2073771fe6b9SJerome Glisse ATOM_DEVICE_LCD1_SUPPORT, 2074771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_LVDS, 2075b75fad06SAlex Deucher &ddc_i2c, 2076b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_LVDS); 2077771fe6b9SJerome Glisse } 2078771fe6b9SJerome Glisse } 2079771fe6b9SJerome Glisse 2080771fe6b9SJerome Glisse /* check TV table */ 2081771fe6b9SJerome Glisse if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) { 2082771fe6b9SJerome Glisse uint32_t tv_info = 2083771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 2084771fe6b9SJerome Glisse if (tv_info) { 2085771fe6b9SJerome Glisse if (RBIOS8(tv_info + 6) == 'T') { 2086790cfb34SAlex Deucher if (radeon_apply_legacy_tv_quirks(dev)) { 2087771fe6b9SJerome Glisse radeon_add_legacy_encoder(dev, 2088771fe6b9SJerome Glisse radeon_get_encoder_id 2089771fe6b9SJerome Glisse (dev, 2090771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2091771fe6b9SJerome Glisse 2), 2092771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT); 2093771fe6b9SJerome Glisse radeon_add_legacy_connector(dev, 6, 2094771fe6b9SJerome Glisse ATOM_DEVICE_TV1_SUPPORT, 2095771fe6b9SJerome Glisse DRM_MODE_CONNECTOR_SVIDEO, 2096b75fad06SAlex Deucher &ddc_i2c, 2097b75fad06SAlex Deucher CONNECTOR_OBJECT_ID_SVIDEO); 2098771fe6b9SJerome Glisse } 2099771fe6b9SJerome Glisse } 2100771fe6b9SJerome Glisse } 2101790cfb34SAlex Deucher } 2102771fe6b9SJerome Glisse 2103771fe6b9SJerome Glisse radeon_link_encoder_connector(dev); 2104771fe6b9SJerome Glisse 2105771fe6b9SJerome Glisse return true; 2106771fe6b9SJerome Glisse } 2107771fe6b9SJerome Glisse 2108*fcec570bSAlex Deucher void radeon_external_tmds_setup(struct drm_encoder *encoder) 2109*fcec570bSAlex Deucher { 2110*fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2111*fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2112*fcec570bSAlex Deucher 2113*fcec570bSAlex Deucher if (!tmds) 2114*fcec570bSAlex Deucher return; 2115*fcec570bSAlex Deucher 2116*fcec570bSAlex Deucher switch (tmds->dvo_chip) { 2117*fcec570bSAlex Deucher case DVO_SIL164: 2118*fcec570bSAlex Deucher /* sil 164 */ 2119*fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 1); 2120*fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2121*fcec570bSAlex Deucher tmds->slave_addr, 2122*fcec570bSAlex Deucher 0x08, 0x30); 2123*fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2124*fcec570bSAlex Deucher tmds->slave_addr, 2125*fcec570bSAlex Deucher 0x09, 0x00); 2126*fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2127*fcec570bSAlex Deucher tmds->slave_addr, 2128*fcec570bSAlex Deucher 0x0a, 0x90); 2129*fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2130*fcec570bSAlex Deucher tmds->slave_addr, 2131*fcec570bSAlex Deucher 0x0c, 0x89); 2132*fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2133*fcec570bSAlex Deucher tmds->slave_addr, 2134*fcec570bSAlex Deucher 0x08, 0x3b); 2135*fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 0); 2136*fcec570bSAlex Deucher break; 2137*fcec570bSAlex Deucher case DVO_SIL1178: 2138*fcec570bSAlex Deucher /* sil 1178 - untested */ 2139*fcec570bSAlex Deucher /* 2140*fcec570bSAlex Deucher * 0x0f, 0x44 2141*fcec570bSAlex Deucher * 0x0f, 0x4c 2142*fcec570bSAlex Deucher * 0x0e, 0x01 2143*fcec570bSAlex Deucher * 0x0a, 0x80 2144*fcec570bSAlex Deucher * 0x09, 0x30 2145*fcec570bSAlex Deucher * 0x0c, 0xc9 2146*fcec570bSAlex Deucher * 0x0d, 0x70 2147*fcec570bSAlex Deucher * 0x08, 0x32 2148*fcec570bSAlex Deucher * 0x08, 0x33 2149*fcec570bSAlex Deucher */ 2150*fcec570bSAlex Deucher break; 2151*fcec570bSAlex Deucher default: 2152*fcec570bSAlex Deucher break; 2153*fcec570bSAlex Deucher } 2154*fcec570bSAlex Deucher 2155*fcec570bSAlex Deucher } 2156*fcec570bSAlex Deucher 2157*fcec570bSAlex Deucher bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder) 2158*fcec570bSAlex Deucher { 2159*fcec570bSAlex Deucher struct drm_device *dev = encoder->dev; 2160*fcec570bSAlex Deucher struct radeon_device *rdev = dev->dev_private; 2161*fcec570bSAlex Deucher struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2162*fcec570bSAlex Deucher uint16_t offset; 2163*fcec570bSAlex Deucher uint8_t blocks, slave_addr, rev; 2164*fcec570bSAlex Deucher uint32_t index, id; 2165*fcec570bSAlex Deucher uint32_t reg, val, and_mask, or_mask; 2166*fcec570bSAlex Deucher struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 2167*fcec570bSAlex Deucher 2168*fcec570bSAlex Deucher if (rdev->bios == NULL) 2169*fcec570bSAlex Deucher return false; 2170*fcec570bSAlex Deucher 2171*fcec570bSAlex Deucher if (!tmds) 2172*fcec570bSAlex Deucher return false; 2173*fcec570bSAlex Deucher 2174*fcec570bSAlex Deucher if (rdev->flags & RADEON_IS_IGP) { 2175*fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE); 2176*fcec570bSAlex Deucher rev = RBIOS8(offset); 2177*fcec570bSAlex Deucher if (offset) { 2178*fcec570bSAlex Deucher rev = RBIOS8(offset); 2179*fcec570bSAlex Deucher if (rev > 1) { 2180*fcec570bSAlex Deucher blocks = RBIOS8(offset + 3); 2181*fcec570bSAlex Deucher index = offset + 4; 2182*fcec570bSAlex Deucher while (blocks > 0) { 2183*fcec570bSAlex Deucher id = RBIOS16(index); 2184*fcec570bSAlex Deucher index += 2; 2185*fcec570bSAlex Deucher switch (id >> 13) { 2186*fcec570bSAlex Deucher case 0: 2187*fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2188*fcec570bSAlex Deucher val = RBIOS32(index); 2189*fcec570bSAlex Deucher index += 4; 2190*fcec570bSAlex Deucher WREG32(reg, val); 2191*fcec570bSAlex Deucher break; 2192*fcec570bSAlex Deucher case 2: 2193*fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2194*fcec570bSAlex Deucher and_mask = RBIOS32(index); 2195*fcec570bSAlex Deucher index += 4; 2196*fcec570bSAlex Deucher or_mask = RBIOS32(index); 2197*fcec570bSAlex Deucher index += 4; 2198*fcec570bSAlex Deucher val = RREG32(reg); 2199*fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2200*fcec570bSAlex Deucher WREG32(reg, val); 2201*fcec570bSAlex Deucher break; 2202*fcec570bSAlex Deucher case 3: 2203*fcec570bSAlex Deucher val = RBIOS16(index); 2204*fcec570bSAlex Deucher index += 2; 2205*fcec570bSAlex Deucher udelay(val); 2206*fcec570bSAlex Deucher break; 2207*fcec570bSAlex Deucher case 4: 2208*fcec570bSAlex Deucher val = RBIOS16(index); 2209*fcec570bSAlex Deucher index += 2; 2210*fcec570bSAlex Deucher udelay(val * 1000); 2211*fcec570bSAlex Deucher break; 2212*fcec570bSAlex Deucher case 6: 2213*fcec570bSAlex Deucher slave_addr = id & 0xff; 2214*fcec570bSAlex Deucher slave_addr >>= 1; /* 7 bit addressing */ 2215*fcec570bSAlex Deucher index++; 2216*fcec570bSAlex Deucher reg = RBIOS8(index); 2217*fcec570bSAlex Deucher index++; 2218*fcec570bSAlex Deucher val = RBIOS8(index); 2219*fcec570bSAlex Deucher index++; 2220*fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 1); 2221*fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2222*fcec570bSAlex Deucher slave_addr, 2223*fcec570bSAlex Deucher reg, val); 2224*fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 0); 2225*fcec570bSAlex Deucher break; 2226*fcec570bSAlex Deucher default: 2227*fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2228*fcec570bSAlex Deucher break; 2229*fcec570bSAlex Deucher } 2230*fcec570bSAlex Deucher blocks--; 2231*fcec570bSAlex Deucher } 2232*fcec570bSAlex Deucher return true; 2233*fcec570bSAlex Deucher } 2234*fcec570bSAlex Deucher } 2235*fcec570bSAlex Deucher } else { 2236*fcec570bSAlex Deucher offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); 2237*fcec570bSAlex Deucher if (offset) { 2238*fcec570bSAlex Deucher index = offset + 10; 2239*fcec570bSAlex Deucher id = RBIOS16(index); 2240*fcec570bSAlex Deucher while (id != 0xffff) { 2241*fcec570bSAlex Deucher index += 2; 2242*fcec570bSAlex Deucher switch (id >> 13) { 2243*fcec570bSAlex Deucher case 0: 2244*fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2245*fcec570bSAlex Deucher val = RBIOS32(index); 2246*fcec570bSAlex Deucher WREG32(reg, val); 2247*fcec570bSAlex Deucher break; 2248*fcec570bSAlex Deucher case 2: 2249*fcec570bSAlex Deucher reg = (id & 0x1fff) * 4; 2250*fcec570bSAlex Deucher and_mask = RBIOS32(index); 2251*fcec570bSAlex Deucher index += 4; 2252*fcec570bSAlex Deucher or_mask = RBIOS32(index); 2253*fcec570bSAlex Deucher index += 4; 2254*fcec570bSAlex Deucher val = RREG32(reg); 2255*fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2256*fcec570bSAlex Deucher WREG32(reg, val); 2257*fcec570bSAlex Deucher break; 2258*fcec570bSAlex Deucher case 4: 2259*fcec570bSAlex Deucher val = RBIOS16(index); 2260*fcec570bSAlex Deucher index += 2; 2261*fcec570bSAlex Deucher udelay(val); 2262*fcec570bSAlex Deucher break; 2263*fcec570bSAlex Deucher case 5: 2264*fcec570bSAlex Deucher reg = id & 0x1fff; 2265*fcec570bSAlex Deucher and_mask = RBIOS32(index); 2266*fcec570bSAlex Deucher index += 4; 2267*fcec570bSAlex Deucher or_mask = RBIOS32(index); 2268*fcec570bSAlex Deucher index += 4; 2269*fcec570bSAlex Deucher val = RREG32_PLL(reg); 2270*fcec570bSAlex Deucher val = (val & and_mask) | or_mask; 2271*fcec570bSAlex Deucher WREG32_PLL(reg, val); 2272*fcec570bSAlex Deucher break; 2273*fcec570bSAlex Deucher case 6: 2274*fcec570bSAlex Deucher reg = id & 0x1fff; 2275*fcec570bSAlex Deucher val = RBIOS8(index); 2276*fcec570bSAlex Deucher index += 1; 2277*fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 1); 2278*fcec570bSAlex Deucher radeon_i2c_sw_put_byte(tmds->i2c_bus, 2279*fcec570bSAlex Deucher tmds->slave_addr, 2280*fcec570bSAlex Deucher reg, val); 2281*fcec570bSAlex Deucher radeon_i2c_do_lock(tmds->i2c_bus, 0); 2282*fcec570bSAlex Deucher break; 2283*fcec570bSAlex Deucher default: 2284*fcec570bSAlex Deucher DRM_ERROR("Unknown id %d\n", id >> 13); 2285*fcec570bSAlex Deucher break; 2286*fcec570bSAlex Deucher } 2287*fcec570bSAlex Deucher id = RBIOS16(index); 2288*fcec570bSAlex Deucher } 2289*fcec570bSAlex Deucher return true; 2290*fcec570bSAlex Deucher } 2291*fcec570bSAlex Deucher } 2292*fcec570bSAlex Deucher return false; 2293*fcec570bSAlex Deucher } 2294*fcec570bSAlex Deucher 2295771fe6b9SJerome Glisse static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset) 2296771fe6b9SJerome Glisse { 2297771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2298771fe6b9SJerome Glisse 2299771fe6b9SJerome Glisse if (offset) { 2300771fe6b9SJerome Glisse while (RBIOS16(offset)) { 2301771fe6b9SJerome Glisse uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13); 2302771fe6b9SJerome Glisse uint32_t addr = (RBIOS16(offset) & 0x1fff); 2303771fe6b9SJerome Glisse uint32_t val, and_mask, or_mask; 2304771fe6b9SJerome Glisse uint32_t tmp; 2305771fe6b9SJerome Glisse 2306771fe6b9SJerome Glisse offset += 2; 2307771fe6b9SJerome Glisse switch (cmd) { 2308771fe6b9SJerome Glisse case 0: 2309771fe6b9SJerome Glisse val = RBIOS32(offset); 2310771fe6b9SJerome Glisse offset += 4; 2311771fe6b9SJerome Glisse WREG32(addr, val); 2312771fe6b9SJerome Glisse break; 2313771fe6b9SJerome Glisse case 1: 2314771fe6b9SJerome Glisse val = RBIOS32(offset); 2315771fe6b9SJerome Glisse offset += 4; 2316771fe6b9SJerome Glisse WREG32(addr, val); 2317771fe6b9SJerome Glisse break; 2318771fe6b9SJerome Glisse case 2: 2319771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2320771fe6b9SJerome Glisse offset += 4; 2321771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2322771fe6b9SJerome Glisse offset += 4; 2323771fe6b9SJerome Glisse tmp = RREG32(addr); 2324771fe6b9SJerome Glisse tmp &= and_mask; 2325771fe6b9SJerome Glisse tmp |= or_mask; 2326771fe6b9SJerome Glisse WREG32(addr, tmp); 2327771fe6b9SJerome Glisse break; 2328771fe6b9SJerome Glisse case 3: 2329771fe6b9SJerome Glisse and_mask = RBIOS32(offset); 2330771fe6b9SJerome Glisse offset += 4; 2331771fe6b9SJerome Glisse or_mask = RBIOS32(offset); 2332771fe6b9SJerome Glisse offset += 4; 2333771fe6b9SJerome Glisse tmp = RREG32(addr); 2334771fe6b9SJerome Glisse tmp &= and_mask; 2335771fe6b9SJerome Glisse tmp |= or_mask; 2336771fe6b9SJerome Glisse WREG32(addr, tmp); 2337771fe6b9SJerome Glisse break; 2338771fe6b9SJerome Glisse case 4: 2339771fe6b9SJerome Glisse val = RBIOS16(offset); 2340771fe6b9SJerome Glisse offset += 2; 2341771fe6b9SJerome Glisse udelay(val); 2342771fe6b9SJerome Glisse break; 2343771fe6b9SJerome Glisse case 5: 2344771fe6b9SJerome Glisse val = RBIOS16(offset); 2345771fe6b9SJerome Glisse offset += 2; 2346771fe6b9SJerome Glisse switch (addr) { 2347771fe6b9SJerome Glisse case 8: 2348771fe6b9SJerome Glisse while (val--) { 2349771fe6b9SJerome Glisse if (! 2350771fe6b9SJerome Glisse (RREG32_PLL 2351771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2352771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2353771fe6b9SJerome Glisse break; 2354771fe6b9SJerome Glisse } 2355771fe6b9SJerome Glisse break; 2356771fe6b9SJerome Glisse case 9: 2357771fe6b9SJerome Glisse while (val--) { 2358771fe6b9SJerome Glisse if ((RREG32(RADEON_MC_STATUS) & 2359771fe6b9SJerome Glisse RADEON_MC_IDLE)) 2360771fe6b9SJerome Glisse break; 2361771fe6b9SJerome Glisse } 2362771fe6b9SJerome Glisse break; 2363771fe6b9SJerome Glisse default: 2364771fe6b9SJerome Glisse break; 2365771fe6b9SJerome Glisse } 2366771fe6b9SJerome Glisse break; 2367771fe6b9SJerome Glisse default: 2368771fe6b9SJerome Glisse break; 2369771fe6b9SJerome Glisse } 2370771fe6b9SJerome Glisse } 2371771fe6b9SJerome Glisse } 2372771fe6b9SJerome Glisse } 2373771fe6b9SJerome Glisse 2374771fe6b9SJerome Glisse static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset) 2375771fe6b9SJerome Glisse { 2376771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2377771fe6b9SJerome Glisse 2378771fe6b9SJerome Glisse if (offset) { 2379771fe6b9SJerome Glisse while (RBIOS8(offset)) { 2380771fe6b9SJerome Glisse uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6); 2381771fe6b9SJerome Glisse uint8_t addr = (RBIOS8(offset) & 0x3f); 2382771fe6b9SJerome Glisse uint32_t val, shift, tmp; 2383771fe6b9SJerome Glisse uint32_t and_mask, or_mask; 2384771fe6b9SJerome Glisse 2385771fe6b9SJerome Glisse offset++; 2386771fe6b9SJerome Glisse switch (cmd) { 2387771fe6b9SJerome Glisse case 0: 2388771fe6b9SJerome Glisse val = RBIOS32(offset); 2389771fe6b9SJerome Glisse offset += 4; 2390771fe6b9SJerome Glisse WREG32_PLL(addr, val); 2391771fe6b9SJerome Glisse break; 2392771fe6b9SJerome Glisse case 1: 2393771fe6b9SJerome Glisse shift = RBIOS8(offset) * 8; 2394771fe6b9SJerome Glisse offset++; 2395771fe6b9SJerome Glisse and_mask = RBIOS8(offset) << shift; 2396771fe6b9SJerome Glisse and_mask |= ~(0xff << shift); 2397771fe6b9SJerome Glisse offset++; 2398771fe6b9SJerome Glisse or_mask = RBIOS8(offset) << shift; 2399771fe6b9SJerome Glisse offset++; 2400771fe6b9SJerome Glisse tmp = RREG32_PLL(addr); 2401771fe6b9SJerome Glisse tmp &= and_mask; 2402771fe6b9SJerome Glisse tmp |= or_mask; 2403771fe6b9SJerome Glisse WREG32_PLL(addr, tmp); 2404771fe6b9SJerome Glisse break; 2405771fe6b9SJerome Glisse case 2: 2406771fe6b9SJerome Glisse case 3: 2407771fe6b9SJerome Glisse tmp = 1000; 2408771fe6b9SJerome Glisse switch (addr) { 2409771fe6b9SJerome Glisse case 1: 2410771fe6b9SJerome Glisse udelay(150); 2411771fe6b9SJerome Glisse break; 2412771fe6b9SJerome Glisse case 2: 2413771fe6b9SJerome Glisse udelay(1000); 2414771fe6b9SJerome Glisse break; 2415771fe6b9SJerome Glisse case 3: 2416771fe6b9SJerome Glisse while (tmp--) { 2417771fe6b9SJerome Glisse if (! 2418771fe6b9SJerome Glisse (RREG32_PLL 2419771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2420771fe6b9SJerome Glisse RADEON_MC_BUSY)) 2421771fe6b9SJerome Glisse break; 2422771fe6b9SJerome Glisse } 2423771fe6b9SJerome Glisse break; 2424771fe6b9SJerome Glisse case 4: 2425771fe6b9SJerome Glisse while (tmp--) { 2426771fe6b9SJerome Glisse if (RREG32_PLL 2427771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL) & 2428771fe6b9SJerome Glisse RADEON_DLL_READY) 2429771fe6b9SJerome Glisse break; 2430771fe6b9SJerome Glisse } 2431771fe6b9SJerome Glisse break; 2432771fe6b9SJerome Glisse case 5: 2433771fe6b9SJerome Glisse tmp = 2434771fe6b9SJerome Glisse RREG32_PLL(RADEON_CLK_PWRMGT_CNTL); 2435771fe6b9SJerome Glisse if (tmp & RADEON_CG_NO1_DEBUG_0) { 2436771fe6b9SJerome Glisse #if 0 2437771fe6b9SJerome Glisse uint32_t mclk_cntl = 2438771fe6b9SJerome Glisse RREG32_PLL 2439771fe6b9SJerome Glisse (RADEON_MCLK_CNTL); 2440771fe6b9SJerome Glisse mclk_cntl &= 0xffff0000; 2441771fe6b9SJerome Glisse /*mclk_cntl |= 0x00001111;*//* ??? */ 2442771fe6b9SJerome Glisse WREG32_PLL(RADEON_MCLK_CNTL, 2443771fe6b9SJerome Glisse mclk_cntl); 2444771fe6b9SJerome Glisse udelay(10000); 2445771fe6b9SJerome Glisse #endif 2446771fe6b9SJerome Glisse WREG32_PLL 2447771fe6b9SJerome Glisse (RADEON_CLK_PWRMGT_CNTL, 2448771fe6b9SJerome Glisse tmp & 2449771fe6b9SJerome Glisse ~RADEON_CG_NO1_DEBUG_0); 2450771fe6b9SJerome Glisse udelay(10000); 2451771fe6b9SJerome Glisse } 2452771fe6b9SJerome Glisse break; 2453771fe6b9SJerome Glisse default: 2454771fe6b9SJerome Glisse break; 2455771fe6b9SJerome Glisse } 2456771fe6b9SJerome Glisse break; 2457771fe6b9SJerome Glisse default: 2458771fe6b9SJerome Glisse break; 2459771fe6b9SJerome Glisse } 2460771fe6b9SJerome Glisse } 2461771fe6b9SJerome Glisse } 2462771fe6b9SJerome Glisse } 2463771fe6b9SJerome Glisse 2464771fe6b9SJerome Glisse static void combios_parse_ram_reset_table(struct drm_device *dev, 2465771fe6b9SJerome Glisse uint16_t offset) 2466771fe6b9SJerome Glisse { 2467771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2468771fe6b9SJerome Glisse uint32_t tmp; 2469771fe6b9SJerome Glisse 2470771fe6b9SJerome Glisse if (offset) { 2471771fe6b9SJerome Glisse uint8_t val = RBIOS8(offset); 2472771fe6b9SJerome Glisse while (val != 0xff) { 2473771fe6b9SJerome Glisse offset++; 2474771fe6b9SJerome Glisse 2475771fe6b9SJerome Glisse if (val == 0x0f) { 2476771fe6b9SJerome Glisse uint32_t channel_complete_mask; 2477771fe6b9SJerome Glisse 2478771fe6b9SJerome Glisse if (ASIC_IS_R300(rdev)) 2479771fe6b9SJerome Glisse channel_complete_mask = 2480771fe6b9SJerome Glisse R300_MEM_PWRUP_COMPLETE; 2481771fe6b9SJerome Glisse else 2482771fe6b9SJerome Glisse channel_complete_mask = 2483771fe6b9SJerome Glisse RADEON_MEM_PWRUP_COMPLETE; 2484771fe6b9SJerome Glisse tmp = 20000; 2485771fe6b9SJerome Glisse while (tmp--) { 2486771fe6b9SJerome Glisse if ((RREG32(RADEON_MEM_STR_CNTL) & 2487771fe6b9SJerome Glisse channel_complete_mask) == 2488771fe6b9SJerome Glisse channel_complete_mask) 2489771fe6b9SJerome Glisse break; 2490771fe6b9SJerome Glisse } 2491771fe6b9SJerome Glisse } else { 2492771fe6b9SJerome Glisse uint32_t or_mask = RBIOS16(offset); 2493771fe6b9SJerome Glisse offset += 2; 2494771fe6b9SJerome Glisse 2495771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 2496771fe6b9SJerome Glisse tmp &= RADEON_SDRAM_MODE_MASK; 2497771fe6b9SJerome Glisse tmp |= or_mask; 2498771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 2499771fe6b9SJerome Glisse 2500771fe6b9SJerome Glisse or_mask = val << 24; 2501771fe6b9SJerome Glisse tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG); 2502771fe6b9SJerome Glisse tmp &= RADEON_B3MEM_RESET_MASK; 2503771fe6b9SJerome Glisse tmp |= or_mask; 2504771fe6b9SJerome Glisse WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp); 2505771fe6b9SJerome Glisse } 2506771fe6b9SJerome Glisse val = RBIOS8(offset); 2507771fe6b9SJerome Glisse } 2508771fe6b9SJerome Glisse } 2509771fe6b9SJerome Glisse } 2510771fe6b9SJerome Glisse 2511771fe6b9SJerome Glisse static uint32_t combios_detect_ram(struct drm_device *dev, int ram, 2512771fe6b9SJerome Glisse int mem_addr_mapping) 2513771fe6b9SJerome Glisse { 2514771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2515771fe6b9SJerome Glisse uint32_t mem_cntl; 2516771fe6b9SJerome Glisse uint32_t mem_size; 2517771fe6b9SJerome Glisse uint32_t addr = 0; 2518771fe6b9SJerome Glisse 2519771fe6b9SJerome Glisse mem_cntl = RREG32(RADEON_MEM_CNTL); 2520771fe6b9SJerome Glisse if (mem_cntl & RV100_HALF_MODE) 2521771fe6b9SJerome Glisse ram /= 2; 2522771fe6b9SJerome Glisse mem_size = ram; 2523771fe6b9SJerome Glisse mem_cntl &= ~(0xff << 8); 2524771fe6b9SJerome Glisse mem_cntl |= (mem_addr_mapping & 0xff) << 8; 2525771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 2526771fe6b9SJerome Glisse RREG32(RADEON_MEM_CNTL); 2527771fe6b9SJerome Glisse 2528771fe6b9SJerome Glisse /* sdram reset ? */ 2529771fe6b9SJerome Glisse 2530771fe6b9SJerome Glisse /* something like this???? */ 2531771fe6b9SJerome Glisse while (ram--) { 2532771fe6b9SJerome Glisse addr = ram * 1024 * 1024; 2533771fe6b9SJerome Glisse /* write to each page */ 2534771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 2535771fe6b9SJerome Glisse WREG32(RADEON_MM_DATA, 0xdeadbeef); 2536771fe6b9SJerome Glisse /* read back and verify */ 2537771fe6b9SJerome Glisse WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER); 2538771fe6b9SJerome Glisse if (RREG32(RADEON_MM_DATA) != 0xdeadbeef) 2539771fe6b9SJerome Glisse return 0; 2540771fe6b9SJerome Glisse } 2541771fe6b9SJerome Glisse 2542771fe6b9SJerome Glisse return mem_size; 2543771fe6b9SJerome Glisse } 2544771fe6b9SJerome Glisse 2545771fe6b9SJerome Glisse static void combios_write_ram_size(struct drm_device *dev) 2546771fe6b9SJerome Glisse { 2547771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2548771fe6b9SJerome Glisse uint8_t rev; 2549771fe6b9SJerome Glisse uint16_t offset; 2550771fe6b9SJerome Glisse uint32_t mem_size = 0; 2551771fe6b9SJerome Glisse uint32_t mem_cntl = 0; 2552771fe6b9SJerome Glisse 2553771fe6b9SJerome Glisse /* should do something smarter here I guess... */ 2554771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_IGP) 2555771fe6b9SJerome Glisse return; 2556771fe6b9SJerome Glisse 2557771fe6b9SJerome Glisse /* first check detected mem table */ 2558771fe6b9SJerome Glisse offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE); 2559771fe6b9SJerome Glisse if (offset) { 2560771fe6b9SJerome Glisse rev = RBIOS8(offset); 2561771fe6b9SJerome Glisse if (rev < 3) { 2562771fe6b9SJerome Glisse mem_cntl = RBIOS32(offset + 1); 2563771fe6b9SJerome Glisse mem_size = RBIOS16(offset + 5); 2564771fe6b9SJerome Glisse if (((rdev->flags & RADEON_FAMILY_MASK) < CHIP_R200) && 2565771fe6b9SJerome Glisse ((dev->pdev->device != 0x515e) 2566771fe6b9SJerome Glisse && (dev->pdev->device != 0x5969))) 2567771fe6b9SJerome Glisse WREG32(RADEON_MEM_CNTL, mem_cntl); 2568771fe6b9SJerome Glisse } 2569771fe6b9SJerome Glisse } 2570771fe6b9SJerome Glisse 2571771fe6b9SJerome Glisse if (!mem_size) { 2572771fe6b9SJerome Glisse offset = 2573771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE); 2574771fe6b9SJerome Glisse if (offset) { 2575771fe6b9SJerome Glisse rev = RBIOS8(offset - 1); 2576771fe6b9SJerome Glisse if (rev < 1) { 2577771fe6b9SJerome Glisse if (((rdev->flags & RADEON_FAMILY_MASK) < 2578771fe6b9SJerome Glisse CHIP_R200) 2579771fe6b9SJerome Glisse && ((dev->pdev->device != 0x515e) 2580771fe6b9SJerome Glisse && (dev->pdev->device != 0x5969))) { 2581771fe6b9SJerome Glisse int ram = 0; 2582771fe6b9SJerome Glisse int mem_addr_mapping = 0; 2583771fe6b9SJerome Glisse 2584771fe6b9SJerome Glisse while (RBIOS8(offset)) { 2585771fe6b9SJerome Glisse ram = RBIOS8(offset); 2586771fe6b9SJerome Glisse mem_addr_mapping = 2587771fe6b9SJerome Glisse RBIOS8(offset + 1); 2588771fe6b9SJerome Glisse if (mem_addr_mapping != 0x25) 2589771fe6b9SJerome Glisse ram *= 2; 2590771fe6b9SJerome Glisse mem_size = 2591771fe6b9SJerome Glisse combios_detect_ram(dev, ram, 2592771fe6b9SJerome Glisse mem_addr_mapping); 2593771fe6b9SJerome Glisse if (mem_size) 2594771fe6b9SJerome Glisse break; 2595771fe6b9SJerome Glisse offset += 2; 2596771fe6b9SJerome Glisse } 2597771fe6b9SJerome Glisse } else 2598771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 2599771fe6b9SJerome Glisse } else { 2600771fe6b9SJerome Glisse mem_size = RBIOS8(offset); 2601771fe6b9SJerome Glisse mem_size *= 2; /* convert to MB */ 2602771fe6b9SJerome Glisse } 2603771fe6b9SJerome Glisse } 2604771fe6b9SJerome Glisse } 2605771fe6b9SJerome Glisse 2606771fe6b9SJerome Glisse mem_size *= (1024 * 1024); /* convert to bytes */ 2607771fe6b9SJerome Glisse WREG32(RADEON_CONFIG_MEMSIZE, mem_size); 2608771fe6b9SJerome Glisse } 2609771fe6b9SJerome Glisse 2610771fe6b9SJerome Glisse void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable) 2611771fe6b9SJerome Glisse { 2612771fe6b9SJerome Glisse uint16_t dyn_clk_info = 2613771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 2614771fe6b9SJerome Glisse 2615771fe6b9SJerome Glisse if (dyn_clk_info) 2616771fe6b9SJerome Glisse combios_parse_pll_table(dev, dyn_clk_info); 2617771fe6b9SJerome Glisse } 2618771fe6b9SJerome Glisse 2619771fe6b9SJerome Glisse void radeon_combios_asic_init(struct drm_device *dev) 2620771fe6b9SJerome Glisse { 2621771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2622771fe6b9SJerome Glisse uint16_t table; 2623771fe6b9SJerome Glisse 2624771fe6b9SJerome Glisse /* port hardcoded mac stuff from radeonfb */ 2625771fe6b9SJerome Glisse if (rdev->bios == NULL) 2626771fe6b9SJerome Glisse return; 2627771fe6b9SJerome Glisse 2628771fe6b9SJerome Glisse /* ASIC INIT 1 */ 2629771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE); 2630771fe6b9SJerome Glisse if (table) 2631771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 2632771fe6b9SJerome Glisse 2633771fe6b9SJerome Glisse /* PLL INIT */ 2634771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE); 2635771fe6b9SJerome Glisse if (table) 2636771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 2637771fe6b9SJerome Glisse 2638771fe6b9SJerome Glisse /* ASIC INIT 2 */ 2639771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE); 2640771fe6b9SJerome Glisse if (table) 2641771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 2642771fe6b9SJerome Glisse 2643771fe6b9SJerome Glisse if (!(rdev->flags & RADEON_IS_IGP)) { 2644771fe6b9SJerome Glisse /* ASIC INIT 4 */ 2645771fe6b9SJerome Glisse table = 2646771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE); 2647771fe6b9SJerome Glisse if (table) 2648771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 2649771fe6b9SJerome Glisse 2650771fe6b9SJerome Glisse /* RAM RESET */ 2651771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE); 2652771fe6b9SJerome Glisse if (table) 2653771fe6b9SJerome Glisse combios_parse_ram_reset_table(dev, table); 2654771fe6b9SJerome Glisse 2655771fe6b9SJerome Glisse /* ASIC INIT 3 */ 2656771fe6b9SJerome Glisse table = 2657771fe6b9SJerome Glisse combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE); 2658771fe6b9SJerome Glisse if (table) 2659771fe6b9SJerome Glisse combios_parse_mmio_table(dev, table); 2660771fe6b9SJerome Glisse 2661771fe6b9SJerome Glisse /* write CONFIG_MEMSIZE */ 2662771fe6b9SJerome Glisse combios_write_ram_size(dev); 2663771fe6b9SJerome Glisse } 2664771fe6b9SJerome Glisse 2665771fe6b9SJerome Glisse /* DYN CLK 1 */ 2666771fe6b9SJerome Glisse table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 2667771fe6b9SJerome Glisse if (table) 2668771fe6b9SJerome Glisse combios_parse_pll_table(dev, table); 2669771fe6b9SJerome Glisse 2670771fe6b9SJerome Glisse } 2671771fe6b9SJerome Glisse 2672771fe6b9SJerome Glisse void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev) 2673771fe6b9SJerome Glisse { 2674771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2675771fe6b9SJerome Glisse uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch; 2676771fe6b9SJerome Glisse 2677771fe6b9SJerome Glisse bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); 2678771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 2679771fe6b9SJerome Glisse bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH); 2680771fe6b9SJerome Glisse 2681771fe6b9SJerome Glisse /* let the bios control the backlight */ 2682771fe6b9SJerome Glisse bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN; 2683771fe6b9SJerome Glisse 2684771fe6b9SJerome Glisse /* tell the bios not to handle mode switching */ 2685771fe6b9SJerome Glisse bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS | 2686771fe6b9SJerome Glisse RADEON_ACC_MODE_CHANGE); 2687771fe6b9SJerome Glisse 2688771fe6b9SJerome Glisse /* tell the bios a driver is loaded */ 2689771fe6b9SJerome Glisse bios_7_scratch |= RADEON_DRV_LOADED; 2690771fe6b9SJerome Glisse 2691771fe6b9SJerome Glisse WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch); 2692771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 2693771fe6b9SJerome Glisse WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch); 2694771fe6b9SJerome Glisse } 2695771fe6b9SJerome Glisse 2696771fe6b9SJerome Glisse void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock) 2697771fe6b9SJerome Glisse { 2698771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 2699771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2700771fe6b9SJerome Glisse uint32_t bios_6_scratch; 2701771fe6b9SJerome Glisse 2702771fe6b9SJerome Glisse bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 2703771fe6b9SJerome Glisse 2704771fe6b9SJerome Glisse if (lock) 2705771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DRIVER_CRITICAL; 2706771fe6b9SJerome Glisse else 2707771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DRIVER_CRITICAL; 2708771fe6b9SJerome Glisse 2709771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 2710771fe6b9SJerome Glisse } 2711771fe6b9SJerome Glisse 2712771fe6b9SJerome Glisse void 2713771fe6b9SJerome Glisse radeon_combios_connected_scratch_regs(struct drm_connector *connector, 2714771fe6b9SJerome Glisse struct drm_encoder *encoder, 2715771fe6b9SJerome Glisse bool connected) 2716771fe6b9SJerome Glisse { 2717771fe6b9SJerome Glisse struct drm_device *dev = connector->dev; 2718771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2719771fe6b9SJerome Glisse struct radeon_connector *radeon_connector = 2720771fe6b9SJerome Glisse to_radeon_connector(connector); 2721771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2722771fe6b9SJerome Glisse uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH); 2723771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 2724771fe6b9SJerome Glisse 2725771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) && 2726771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) { 2727771fe6b9SJerome Glisse if (connected) { 2728771fe6b9SJerome Glisse DRM_DEBUG("TV1 connected\n"); 2729771fe6b9SJerome Glisse /* fix me */ 2730771fe6b9SJerome Glisse bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO; 2731771fe6b9SJerome Glisse /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */ 2732771fe6b9SJerome Glisse bios_5_scratch |= RADEON_TV1_ON; 2733771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_TV1; 2734771fe6b9SJerome Glisse } else { 2735771fe6b9SJerome Glisse DRM_DEBUG("TV1 disconnected\n"); 2736771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK; 2737771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_ON; 2738771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_TV1; 2739771fe6b9SJerome Glisse } 2740771fe6b9SJerome Glisse } 2741771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) && 2742771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) { 2743771fe6b9SJerome Glisse if (connected) { 2744771fe6b9SJerome Glisse DRM_DEBUG("LCD1 connected\n"); 2745771fe6b9SJerome Glisse bios_4_scratch |= RADEON_LCD1_ATTACHED; 2746771fe6b9SJerome Glisse bios_5_scratch |= RADEON_LCD1_ON; 2747771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_LCD1; 2748771fe6b9SJerome Glisse } else { 2749771fe6b9SJerome Glisse DRM_DEBUG("LCD1 disconnected\n"); 2750771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_LCD1_ATTACHED; 2751771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_ON; 2752771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_LCD1; 2753771fe6b9SJerome Glisse } 2754771fe6b9SJerome Glisse } 2755771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) && 2756771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) { 2757771fe6b9SJerome Glisse if (connected) { 2758771fe6b9SJerome Glisse DRM_DEBUG("CRT1 connected\n"); 2759771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR; 2760771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT1_ON; 2761771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT1; 2762771fe6b9SJerome Glisse } else { 2763771fe6b9SJerome Glisse DRM_DEBUG("CRT1 disconnected\n"); 2764771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK; 2765771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_ON; 2766771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT1; 2767771fe6b9SJerome Glisse } 2768771fe6b9SJerome Glisse } 2769771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) && 2770771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) { 2771771fe6b9SJerome Glisse if (connected) { 2772771fe6b9SJerome Glisse DRM_DEBUG("CRT2 connected\n"); 2773771fe6b9SJerome Glisse bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR; 2774771fe6b9SJerome Glisse bios_5_scratch |= RADEON_CRT2_ON; 2775771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_CRT2; 2776771fe6b9SJerome Glisse } else { 2777771fe6b9SJerome Glisse DRM_DEBUG("CRT2 disconnected\n"); 2778771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK; 2779771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_ON; 2780771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_CRT2; 2781771fe6b9SJerome Glisse } 2782771fe6b9SJerome Glisse } 2783771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) && 2784771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) { 2785771fe6b9SJerome Glisse if (connected) { 2786771fe6b9SJerome Glisse DRM_DEBUG("DFP1 connected\n"); 2787771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP1_ATTACHED; 2788771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP1_ON; 2789771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP1; 2790771fe6b9SJerome Glisse } else { 2791771fe6b9SJerome Glisse DRM_DEBUG("DFP1 disconnected\n"); 2792771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP1_ATTACHED; 2793771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_ON; 2794771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP1; 2795771fe6b9SJerome Glisse } 2796771fe6b9SJerome Glisse } 2797771fe6b9SJerome Glisse if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) && 2798771fe6b9SJerome Glisse (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) { 2799771fe6b9SJerome Glisse if (connected) { 2800771fe6b9SJerome Glisse DRM_DEBUG("DFP2 connected\n"); 2801771fe6b9SJerome Glisse bios_4_scratch |= RADEON_DFP2_ATTACHED; 2802771fe6b9SJerome Glisse bios_5_scratch |= RADEON_DFP2_ON; 2803771fe6b9SJerome Glisse bios_5_scratch |= RADEON_ACC_REQ_DFP2; 2804771fe6b9SJerome Glisse } else { 2805771fe6b9SJerome Glisse DRM_DEBUG("DFP2 disconnected\n"); 2806771fe6b9SJerome Glisse bios_4_scratch &= ~RADEON_DFP2_ATTACHED; 2807771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_ON; 2808771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_ACC_REQ_DFP2; 2809771fe6b9SJerome Glisse } 2810771fe6b9SJerome Glisse } 2811771fe6b9SJerome Glisse WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch); 2812771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 2813771fe6b9SJerome Glisse } 2814771fe6b9SJerome Glisse 2815771fe6b9SJerome Glisse void 2816771fe6b9SJerome Glisse radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc) 2817771fe6b9SJerome Glisse { 2818771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 2819771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2820771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2821771fe6b9SJerome Glisse uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH); 2822771fe6b9SJerome Glisse 2823771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { 2824771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_TV1_CRTC_MASK; 2825771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT); 2826771fe6b9SJerome Glisse } 2827771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { 2828771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK; 2829771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT); 2830771fe6b9SJerome Glisse } 2831771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { 2832771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK; 2833771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT); 2834771fe6b9SJerome Glisse } 2835771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { 2836771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK; 2837771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT); 2838771fe6b9SJerome Glisse } 2839771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { 2840771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK; 2841771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT); 2842771fe6b9SJerome Glisse } 2843771fe6b9SJerome Glisse if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { 2844771fe6b9SJerome Glisse bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK; 2845771fe6b9SJerome Glisse bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT); 2846771fe6b9SJerome Glisse } 2847771fe6b9SJerome Glisse WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch); 2848771fe6b9SJerome Glisse } 2849771fe6b9SJerome Glisse 2850771fe6b9SJerome Glisse void 2851771fe6b9SJerome Glisse radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on) 2852771fe6b9SJerome Glisse { 2853771fe6b9SJerome Glisse struct drm_device *dev = encoder->dev; 2854771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 2855771fe6b9SJerome Glisse struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2856771fe6b9SJerome Glisse uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); 2857771fe6b9SJerome Glisse 2858771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { 2859771fe6b9SJerome Glisse if (on) 2860771fe6b9SJerome Glisse bios_6_scratch |= RADEON_TV_DPMS_ON; 2861771fe6b9SJerome Glisse else 2862771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_TV_DPMS_ON; 2863771fe6b9SJerome Glisse } 2864771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) { 2865771fe6b9SJerome Glisse if (on) 2866771fe6b9SJerome Glisse bios_6_scratch |= RADEON_CRT_DPMS_ON; 2867771fe6b9SJerome Glisse else 2868771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_CRT_DPMS_ON; 2869771fe6b9SJerome Glisse } 2870771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 2871771fe6b9SJerome Glisse if (on) 2872771fe6b9SJerome Glisse bios_6_scratch |= RADEON_LCD_DPMS_ON; 2873771fe6b9SJerome Glisse else 2874771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_LCD_DPMS_ON; 2875771fe6b9SJerome Glisse } 2876771fe6b9SJerome Glisse if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 2877771fe6b9SJerome Glisse if (on) 2878771fe6b9SJerome Glisse bios_6_scratch |= RADEON_DFP_DPMS_ON; 2879771fe6b9SJerome Glisse else 2880771fe6b9SJerome Glisse bios_6_scratch &= ~RADEON_DFP_DPMS_ON; 2881771fe6b9SJerome Glisse } 2882771fe6b9SJerome Glisse WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); 2883771fe6b9SJerome Glisse } 2884