Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2007-8 Advanced Micro Devices, Inc. |
| 3 | * Copyright 2008 Red Hat Inc. |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | * copy of this software and associated documentation files (the "Software"), |
| 7 | * to deal in the Software without restriction, including without limitation |
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | * and/or sell copies of the Software, and to permit persons to whom the |
| 10 | * Software is furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice shall be included in |
| 13 | * all copies or substantial portions of the Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 19 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 20 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 21 | * OTHER DEALINGS IN THE SOFTWARE. |
| 22 | * |
| 23 | * Authors: Dave Airlie |
| 24 | * Alex Deucher |
| 25 | */ |
| 26 | #include "drmP.h" |
| 27 | #include "radeon_drm.h" |
| 28 | #include "radeon.h" |
| 29 | |
| 30 | #include "atom.h" |
| 31 | #include "atom-bits.h" |
| 32 | |
| 33 | /* from radeon_encoder.c */ |
| 34 | extern uint32_t |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 35 | radeon_get_encoder_enum(struct drm_device *dev, uint32_t supported_device, |
| 36 | uint8_t dac); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 37 | extern void radeon_link_encoder_connector(struct drm_device *dev); |
| 38 | extern void |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 39 | radeon_add_atom_encoder(struct drm_device *dev, uint32_t encoder_enum, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 40 | uint32_t supported_device); |
| 41 | |
| 42 | /* from radeon_connector.c */ |
| 43 | extern void |
| 44 | radeon_add_atom_connector(struct drm_device *dev, |
| 45 | uint32_t connector_id, |
| 46 | uint32_t supported_device, |
| 47 | int connector_type, |
| 48 | struct radeon_i2c_bus_rec *i2c_bus, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 49 | uint32_t igp_lane_info, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 50 | uint16_t connector_object_id, |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 51 | struct radeon_hpd *hpd, |
| 52 | struct radeon_router *router); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 53 | |
| 54 | /* from radeon_legacy_encoder.c */ |
| 55 | extern void |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 56 | radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_enum, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 57 | uint32_t supported_device); |
| 58 | |
| 59 | union atom_supported_devices { |
| 60 | struct _ATOM_SUPPORTED_DEVICES_INFO info; |
| 61 | struct _ATOM_SUPPORTED_DEVICES_INFO_2 info_2; |
| 62 | struct _ATOM_SUPPORTED_DEVICES_INFO_2d1 info_2d1; |
| 63 | }; |
| 64 | |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 65 | static inline struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_device *rdev, |
| 66 | uint8_t id) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 67 | { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 68 | struct atom_context *ctx = rdev->mode_info.atom_context; |
Alex Deucher | 6a93cb2 | 2009-11-23 17:39:28 -0500 | [diff] [blame] | 69 | ATOM_GPIO_I2C_ASSIGMENT *gpio; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 70 | struct radeon_i2c_bus_rec i2c; |
| 71 | int index = GetIndexIntoMasterTable(DATA, GPIO_I2C_Info); |
| 72 | struct _ATOM_GPIO_I2C_INFO *i2c_info; |
Alex Deucher | 95beb69 | 2010-04-01 19:08:47 +0000 | [diff] [blame] | 73 | uint16_t data_offset, size; |
| 74 | int i, num_indices; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 75 | |
| 76 | memset(&i2c, 0, sizeof(struct radeon_i2c_bus_rec)); |
| 77 | i2c.valid = false; |
| 78 | |
Alex Deucher | 95beb69 | 2010-04-01 19:08:47 +0000 | [diff] [blame] | 79 | if (atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset)) { |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 80 | i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 81 | |
Alex Deucher | 95beb69 | 2010-04-01 19:08:47 +0000 | [diff] [blame] | 82 | num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / |
| 83 | sizeof(ATOM_GPIO_I2C_ASSIGMENT); |
| 84 | |
| 85 | for (i = 0; i < num_indices; i++) { |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 86 | gpio = &i2c_info->asGPIO_Info[i]; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 87 | |
Alex Deucher | ea39302 | 2010-08-27 16:04:29 -0400 | [diff] [blame] | 88 | /* some evergreen boards have bad data for this entry */ |
| 89 | if (ASIC_IS_DCE4(rdev)) { |
| 90 | if ((i == 7) && |
| 91 | (gpio->usClkMaskRegisterIndex == 0x1936) && |
| 92 | (gpio->sucI2cId.ucAccess == 0)) { |
| 93 | gpio->sucI2cId.ucAccess = 0x97; |
| 94 | gpio->ucDataMaskShift = 8; |
| 95 | gpio->ucDataEnShift = 8; |
| 96 | gpio->ucDataY_Shift = 8; |
| 97 | gpio->ucDataA_Shift = 8; |
| 98 | } |
| 99 | } |
| 100 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 101 | if (gpio->sucI2cId.ucAccess == id) { |
| 102 | i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4; |
| 103 | i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4; |
| 104 | i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex) * 4; |
| 105 | i2c.en_data_reg = le16_to_cpu(gpio->usDataEnRegisterIndex) * 4; |
| 106 | i2c.y_clk_reg = le16_to_cpu(gpio->usClkY_RegisterIndex) * 4; |
| 107 | i2c.y_data_reg = le16_to_cpu(gpio->usDataY_RegisterIndex) * 4; |
| 108 | i2c.a_clk_reg = le16_to_cpu(gpio->usClkA_RegisterIndex) * 4; |
| 109 | i2c.a_data_reg = le16_to_cpu(gpio->usDataA_RegisterIndex) * 4; |
| 110 | i2c.mask_clk_mask = (1 << gpio->ucClkMaskShift); |
| 111 | i2c.mask_data_mask = (1 << gpio->ucDataMaskShift); |
| 112 | i2c.en_clk_mask = (1 << gpio->ucClkEnShift); |
| 113 | i2c.en_data_mask = (1 << gpio->ucDataEnShift); |
| 114 | i2c.y_clk_mask = (1 << gpio->ucClkY_Shift); |
| 115 | i2c.y_data_mask = (1 << gpio->ucDataY_Shift); |
| 116 | i2c.a_clk_mask = (1 << gpio->ucClkA_Shift); |
| 117 | i2c.a_data_mask = (1 << gpio->ucDataA_Shift); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 118 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 119 | if (gpio->sucI2cId.sbfAccess.bfHW_Capable) |
| 120 | i2c.hw_capable = true; |
| 121 | else |
| 122 | i2c.hw_capable = false; |
Alex Deucher | 6a93cb2 | 2009-11-23 17:39:28 -0500 | [diff] [blame] | 123 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 124 | if (gpio->sucI2cId.ucAccess == 0xa0) |
| 125 | i2c.mm_i2c = true; |
| 126 | else |
| 127 | i2c.mm_i2c = false; |
Alex Deucher | 6a93cb2 | 2009-11-23 17:39:28 -0500 | [diff] [blame] | 128 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 129 | i2c.i2c_id = gpio->sucI2cId.ucAccess; |
Alex Deucher | 6a93cb2 | 2009-11-23 17:39:28 -0500 | [diff] [blame] | 130 | |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 131 | if (i2c.mask_clk_reg) |
| 132 | i2c.valid = true; |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 133 | break; |
| 134 | } |
Alex Deucher | d3f420d | 2009-12-08 14:30:49 -0500 | [diff] [blame] | 135 | } |
| 136 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 137 | |
| 138 | return i2c; |
| 139 | } |
| 140 | |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 141 | void radeon_atombios_i2c_init(struct radeon_device *rdev) |
| 142 | { |
| 143 | struct atom_context *ctx = rdev->mode_info.atom_context; |
| 144 | ATOM_GPIO_I2C_ASSIGMENT *gpio; |
| 145 | struct radeon_i2c_bus_rec i2c; |
| 146 | int index = GetIndexIntoMasterTable(DATA, GPIO_I2C_Info); |
| 147 | struct _ATOM_GPIO_I2C_INFO *i2c_info; |
| 148 | uint16_t data_offset, size; |
| 149 | int i, num_indices; |
| 150 | char stmp[32]; |
| 151 | |
| 152 | memset(&i2c, 0, sizeof(struct radeon_i2c_bus_rec)); |
| 153 | |
| 154 | if (atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset)) { |
| 155 | i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset); |
| 156 | |
| 157 | num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / |
| 158 | sizeof(ATOM_GPIO_I2C_ASSIGMENT); |
| 159 | |
| 160 | for (i = 0; i < num_indices; i++) { |
| 161 | gpio = &i2c_info->asGPIO_Info[i]; |
| 162 | i2c.valid = false; |
Alex Deucher | ea39302 | 2010-08-27 16:04:29 -0400 | [diff] [blame] | 163 | |
| 164 | /* some evergreen boards have bad data for this entry */ |
| 165 | if (ASIC_IS_DCE4(rdev)) { |
| 166 | if ((i == 7) && |
| 167 | (gpio->usClkMaskRegisterIndex == 0x1936) && |
| 168 | (gpio->sucI2cId.ucAccess == 0)) { |
| 169 | gpio->sucI2cId.ucAccess = 0x97; |
| 170 | gpio->ucDataMaskShift = 8; |
| 171 | gpio->ucDataEnShift = 8; |
| 172 | gpio->ucDataY_Shift = 8; |
| 173 | gpio->ucDataA_Shift = 8; |
| 174 | } |
| 175 | } |
| 176 | |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 177 | i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4; |
| 178 | i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4; |
| 179 | i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex) * 4; |
| 180 | i2c.en_data_reg = le16_to_cpu(gpio->usDataEnRegisterIndex) * 4; |
| 181 | i2c.y_clk_reg = le16_to_cpu(gpio->usClkY_RegisterIndex) * 4; |
| 182 | i2c.y_data_reg = le16_to_cpu(gpio->usDataY_RegisterIndex) * 4; |
| 183 | i2c.a_clk_reg = le16_to_cpu(gpio->usClkA_RegisterIndex) * 4; |
| 184 | i2c.a_data_reg = le16_to_cpu(gpio->usDataA_RegisterIndex) * 4; |
| 185 | i2c.mask_clk_mask = (1 << gpio->ucClkMaskShift); |
| 186 | i2c.mask_data_mask = (1 << gpio->ucDataMaskShift); |
| 187 | i2c.en_clk_mask = (1 << gpio->ucClkEnShift); |
| 188 | i2c.en_data_mask = (1 << gpio->ucDataEnShift); |
| 189 | i2c.y_clk_mask = (1 << gpio->ucClkY_Shift); |
| 190 | i2c.y_data_mask = (1 << gpio->ucDataY_Shift); |
| 191 | i2c.a_clk_mask = (1 << gpio->ucClkA_Shift); |
| 192 | i2c.a_data_mask = (1 << gpio->ucDataA_Shift); |
| 193 | |
| 194 | if (gpio->sucI2cId.sbfAccess.bfHW_Capable) |
| 195 | i2c.hw_capable = true; |
| 196 | else |
| 197 | i2c.hw_capable = false; |
| 198 | |
| 199 | if (gpio->sucI2cId.ucAccess == 0xa0) |
| 200 | i2c.mm_i2c = true; |
| 201 | else |
| 202 | i2c.mm_i2c = false; |
| 203 | |
| 204 | i2c.i2c_id = gpio->sucI2cId.ucAccess; |
| 205 | |
| 206 | if (i2c.mask_clk_reg) { |
| 207 | i2c.valid = true; |
| 208 | sprintf(stmp, "0x%x", i2c.i2c_id); |
| 209 | rdev->i2c_bus[i] = radeon_i2c_create(rdev->ddev, &i2c, stmp); |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 215 | static inline struct radeon_gpio_rec radeon_lookup_gpio(struct radeon_device *rdev, |
| 216 | u8 id) |
| 217 | { |
| 218 | struct atom_context *ctx = rdev->mode_info.atom_context; |
| 219 | struct radeon_gpio_rec gpio; |
| 220 | int index = GetIndexIntoMasterTable(DATA, GPIO_Pin_LUT); |
| 221 | struct _ATOM_GPIO_PIN_LUT *gpio_info; |
| 222 | ATOM_GPIO_PIN_ASSIGNMENT *pin; |
| 223 | u16 data_offset, size; |
| 224 | int i, num_indices; |
| 225 | |
| 226 | memset(&gpio, 0, sizeof(struct radeon_gpio_rec)); |
| 227 | gpio.valid = false; |
| 228 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 229 | if (atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset)) { |
| 230 | gpio_info = (struct _ATOM_GPIO_PIN_LUT *)(ctx->bios + data_offset); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 231 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 232 | num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / |
| 233 | sizeof(ATOM_GPIO_PIN_ASSIGNMENT); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 234 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 235 | for (i = 0; i < num_indices; i++) { |
| 236 | pin = &gpio_info->asGPIO_Pin[i]; |
| 237 | if (id == pin->ucGPIO_ID) { |
| 238 | gpio.id = pin->ucGPIO_ID; |
| 239 | gpio.reg = pin->usGpioPin_AIndex * 4; |
| 240 | gpio.mask = (1 << pin->ucGpioPinBitShift); |
| 241 | gpio.valid = true; |
| 242 | break; |
| 243 | } |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 244 | } |
| 245 | } |
| 246 | |
| 247 | return gpio; |
| 248 | } |
| 249 | |
| 250 | static struct radeon_hpd radeon_atom_get_hpd_info_from_gpio(struct radeon_device *rdev, |
| 251 | struct radeon_gpio_rec *gpio) |
| 252 | { |
| 253 | struct radeon_hpd hpd; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 254 | u32 reg; |
| 255 | |
Jean Delvare | 1d978da | 2010-08-15 14:11:24 +0200 | [diff] [blame] | 256 | memset(&hpd, 0, sizeof(struct radeon_hpd)); |
| 257 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 258 | if (ASIC_IS_DCE4(rdev)) |
| 259 | reg = EVERGREEN_DC_GPIO_HPD_A; |
| 260 | else |
| 261 | reg = AVIVO_DC_GPIO_HPD_A; |
| 262 | |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 263 | hpd.gpio = *gpio; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 264 | if (gpio->reg == reg) { |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 265 | switch(gpio->mask) { |
| 266 | case (1 << 0): |
| 267 | hpd.hpd = RADEON_HPD_1; |
| 268 | break; |
| 269 | case (1 << 8): |
| 270 | hpd.hpd = RADEON_HPD_2; |
| 271 | break; |
| 272 | case (1 << 16): |
| 273 | hpd.hpd = RADEON_HPD_3; |
| 274 | break; |
| 275 | case (1 << 24): |
| 276 | hpd.hpd = RADEON_HPD_4; |
| 277 | break; |
| 278 | case (1 << 26): |
| 279 | hpd.hpd = RADEON_HPD_5; |
| 280 | break; |
| 281 | case (1 << 28): |
| 282 | hpd.hpd = RADEON_HPD_6; |
| 283 | break; |
| 284 | default: |
| 285 | hpd.hpd = RADEON_HPD_NONE; |
| 286 | break; |
| 287 | } |
| 288 | } else |
| 289 | hpd.hpd = RADEON_HPD_NONE; |
| 290 | return hpd; |
| 291 | } |
| 292 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 293 | static bool radeon_atom_apply_quirks(struct drm_device *dev, |
| 294 | uint32_t supported_device, |
| 295 | int *connector_type, |
Alex Deucher | 848577e | 2009-07-08 16:15:30 -0400 | [diff] [blame] | 296 | struct radeon_i2c_bus_rec *i2c_bus, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 297 | uint16_t *line_mux, |
| 298 | struct radeon_hpd *hpd) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 299 | { |
Alex Deucher | 9ea2c4b | 2010-08-06 00:27:44 -0400 | [diff] [blame] | 300 | struct radeon_device *rdev = dev->dev_private; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 301 | |
| 302 | /* Asus M2A-VM HDMI board lists the DVI port as HDMI */ |
| 303 | if ((dev->pdev->device == 0x791e) && |
| 304 | (dev->pdev->subsystem_vendor == 0x1043) && |
| 305 | (dev->pdev->subsystem_device == 0x826d)) { |
| 306 | if ((*connector_type == DRM_MODE_CONNECTOR_HDMIA) && |
| 307 | (supported_device == ATOM_DEVICE_DFP3_SUPPORT)) |
| 308 | *connector_type = DRM_MODE_CONNECTOR_DVID; |
| 309 | } |
| 310 | |
Alex Deucher | c86a903 | 2010-02-18 14:14:58 -0500 | [diff] [blame] | 311 | /* Asrock RS600 board lists the DVI port as HDMI */ |
| 312 | if ((dev->pdev->device == 0x7941) && |
| 313 | (dev->pdev->subsystem_vendor == 0x1849) && |
| 314 | (dev->pdev->subsystem_device == 0x7941)) { |
| 315 | if ((*connector_type == DRM_MODE_CONNECTOR_HDMIA) && |
| 316 | (supported_device == ATOM_DEVICE_DFP3_SUPPORT)) |
| 317 | *connector_type = DRM_MODE_CONNECTOR_DVID; |
| 318 | } |
| 319 | |
Alex Deucher | f36fce0 | 2010-09-27 11:33:00 -0400 | [diff] [blame] | 320 | /* MSI K9A2GM V2/V3 board has no HDMI or DVI */ |
| 321 | if ((dev->pdev->device == 0x796e) && |
| 322 | (dev->pdev->subsystem_vendor == 0x1462) && |
| 323 | (dev->pdev->subsystem_device == 0x7302)) { |
| 324 | if ((supported_device == ATOM_DEVICE_DFP2_SUPPORT) || |
| 325 | (supported_device == ATOM_DEVICE_DFP3_SUPPORT)) |
| 326 | return false; |
| 327 | } |
| 328 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 329 | /* a-bit f-i90hd - ciaranm on #radeonhd - this board has no DVI */ |
| 330 | if ((dev->pdev->device == 0x7941) && |
| 331 | (dev->pdev->subsystem_vendor == 0x147b) && |
| 332 | (dev->pdev->subsystem_device == 0x2412)) { |
| 333 | if (*connector_type == DRM_MODE_CONNECTOR_DVII) |
| 334 | return false; |
| 335 | } |
| 336 | |
| 337 | /* Falcon NW laptop lists vga ddc line for LVDS */ |
| 338 | if ((dev->pdev->device == 0x5653) && |
| 339 | (dev->pdev->subsystem_vendor == 0x1462) && |
| 340 | (dev->pdev->subsystem_device == 0x0291)) { |
Alex Deucher | 848577e | 2009-07-08 16:15:30 -0400 | [diff] [blame] | 341 | if (*connector_type == DRM_MODE_CONNECTOR_LVDS) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 342 | i2c_bus->valid = false; |
Alex Deucher | 848577e | 2009-07-08 16:15:30 -0400 | [diff] [blame] | 343 | *line_mux = 53; |
| 344 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 345 | } |
| 346 | |
Alex Deucher | 4e3f9b78 | 2009-12-01 14:49:50 -0500 | [diff] [blame] | 347 | /* HIS X1300 is DVI+VGA, not DVI+DVI */ |
| 348 | if ((dev->pdev->device == 0x7146) && |
| 349 | (dev->pdev->subsystem_vendor == 0x17af) && |
| 350 | (dev->pdev->subsystem_device == 0x2058)) { |
| 351 | if (supported_device == ATOM_DEVICE_DFP1_SUPPORT) |
| 352 | return false; |
| 353 | } |
| 354 | |
Dave Airlie | aa1a750 | 2009-12-04 11:51:34 +1000 | [diff] [blame] | 355 | /* Gigabyte X1300 is DVI+VGA, not DVI+DVI */ |
| 356 | if ((dev->pdev->device == 0x7142) && |
| 357 | (dev->pdev->subsystem_vendor == 0x1458) && |
| 358 | (dev->pdev->subsystem_device == 0x2134)) { |
| 359 | if (supported_device == ATOM_DEVICE_DFP1_SUPPORT) |
| 360 | return false; |
| 361 | } |
| 362 | |
| 363 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 364 | /* Funky macbooks */ |
| 365 | if ((dev->pdev->device == 0x71C5) && |
| 366 | (dev->pdev->subsystem_vendor == 0x106b) && |
| 367 | (dev->pdev->subsystem_device == 0x0080)) { |
| 368 | if ((supported_device == ATOM_DEVICE_CRT1_SUPPORT) || |
| 369 | (supported_device == ATOM_DEVICE_DFP2_SUPPORT)) |
| 370 | return false; |
Alex Deucher | e1e8a5d | 2010-03-26 17:14:37 -0400 | [diff] [blame] | 371 | if (supported_device == ATOM_DEVICE_CRT2_SUPPORT) |
| 372 | *line_mux = 0x90; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 373 | } |
| 374 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 375 | /* ASUS HD 3600 XT board lists the DVI port as HDMI */ |
| 376 | if ((dev->pdev->device == 0x9598) && |
| 377 | (dev->pdev->subsystem_vendor == 0x1043) && |
| 378 | (dev->pdev->subsystem_device == 0x01da)) { |
Alex Deucher | 705af9c | 2009-09-10 16:31:13 -0400 | [diff] [blame] | 379 | if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) { |
Alex Deucher | d42571e | 2009-09-11 15:27:14 -0400 | [diff] [blame] | 380 | *connector_type = DRM_MODE_CONNECTOR_DVII; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 381 | } |
| 382 | } |
| 383 | |
Alex Deucher | e153b70 | 2010-07-20 18:07:22 -0400 | [diff] [blame] | 384 | /* ASUS HD 3600 board lists the DVI port as HDMI */ |
| 385 | if ((dev->pdev->device == 0x9598) && |
| 386 | (dev->pdev->subsystem_vendor == 0x1043) && |
| 387 | (dev->pdev->subsystem_device == 0x01e4)) { |
| 388 | if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) { |
| 389 | *connector_type = DRM_MODE_CONNECTOR_DVII; |
| 390 | } |
| 391 | } |
| 392 | |
Alex Deucher | 705af9c | 2009-09-10 16:31:13 -0400 | [diff] [blame] | 393 | /* ASUS HD 3450 board lists the DVI port as HDMI */ |
| 394 | if ((dev->pdev->device == 0x95C5) && |
| 395 | (dev->pdev->subsystem_vendor == 0x1043) && |
| 396 | (dev->pdev->subsystem_device == 0x01e2)) { |
| 397 | if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) { |
Alex Deucher | d42571e | 2009-09-11 15:27:14 -0400 | [diff] [blame] | 398 | *connector_type = DRM_MODE_CONNECTOR_DVII; |
Alex Deucher | 705af9c | 2009-09-10 16:31:13 -0400 | [diff] [blame] | 399 | } |
| 400 | } |
| 401 | |
| 402 | /* some BIOSes seem to report DAC on HDMI - usually this is a board with |
| 403 | * HDMI + VGA reporting as HDMI |
| 404 | */ |
| 405 | if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) { |
| 406 | if (supported_device & (ATOM_DEVICE_CRT_SUPPORT)) { |
| 407 | *connector_type = DRM_MODE_CONNECTOR_VGA; |
| 408 | *line_mux = 0; |
| 409 | } |
| 410 | } |
| 411 | |
Alex Deucher | 9ea2c4b | 2010-08-06 00:27:44 -0400 | [diff] [blame] | 412 | /* Acer laptop reports DVI-D as DVI-I and hpd pins reversed */ |
Alex Deucher | 3e5f8ff | 2009-11-17 17:12:10 -0500 | [diff] [blame] | 413 | if ((dev->pdev->device == 0x95c4) && |
| 414 | (dev->pdev->subsystem_vendor == 0x1025) && |
| 415 | (dev->pdev->subsystem_device == 0x013c)) { |
Alex Deucher | 9ea2c4b | 2010-08-06 00:27:44 -0400 | [diff] [blame] | 416 | struct radeon_gpio_rec gpio; |
| 417 | |
Alex Deucher | 3e5f8ff | 2009-11-17 17:12:10 -0500 | [diff] [blame] | 418 | if ((*connector_type == DRM_MODE_CONNECTOR_DVII) && |
Alex Deucher | 9ea2c4b | 2010-08-06 00:27:44 -0400 | [diff] [blame] | 419 | (supported_device == ATOM_DEVICE_DFP1_SUPPORT)) { |
| 420 | gpio = radeon_lookup_gpio(rdev, 6); |
| 421 | *hpd = radeon_atom_get_hpd_info_from_gpio(rdev, &gpio); |
Alex Deucher | 3e5f8ff | 2009-11-17 17:12:10 -0500 | [diff] [blame] | 422 | *connector_type = DRM_MODE_CONNECTOR_DVID; |
Alex Deucher | 9ea2c4b | 2010-08-06 00:27:44 -0400 | [diff] [blame] | 423 | } else if ((*connector_type == DRM_MODE_CONNECTOR_HDMIA) && |
| 424 | (supported_device == ATOM_DEVICE_DFP1_SUPPORT)) { |
| 425 | gpio = radeon_lookup_gpio(rdev, 7); |
| 426 | *hpd = radeon_atom_get_hpd_info_from_gpio(rdev, &gpio); |
| 427 | } |
Alex Deucher | 3e5f8ff | 2009-11-17 17:12:10 -0500 | [diff] [blame] | 428 | } |
| 429 | |
Dave Airlie | efa8450 | 2010-02-09 09:06:00 +1000 | [diff] [blame] | 430 | /* XFX Pine Group device rv730 reports no VGA DDC lines |
| 431 | * even though they are wired up to record 0x93 |
| 432 | */ |
| 433 | if ((dev->pdev->device == 0x9498) && |
| 434 | (dev->pdev->subsystem_vendor == 0x1682) && |
| 435 | (dev->pdev->subsystem_device == 0x2452)) { |
| 436 | struct radeon_device *rdev = dev->dev_private; |
| 437 | *i2c_bus = radeon_lookup_i2c_gpio(rdev, 0x93); |
| 438 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 439 | return true; |
| 440 | } |
| 441 | |
| 442 | const int supported_devices_connector_convert[] = { |
| 443 | DRM_MODE_CONNECTOR_Unknown, |
| 444 | DRM_MODE_CONNECTOR_VGA, |
| 445 | DRM_MODE_CONNECTOR_DVII, |
| 446 | DRM_MODE_CONNECTOR_DVID, |
| 447 | DRM_MODE_CONNECTOR_DVIA, |
| 448 | DRM_MODE_CONNECTOR_SVIDEO, |
| 449 | DRM_MODE_CONNECTOR_Composite, |
| 450 | DRM_MODE_CONNECTOR_LVDS, |
| 451 | DRM_MODE_CONNECTOR_Unknown, |
| 452 | DRM_MODE_CONNECTOR_Unknown, |
| 453 | DRM_MODE_CONNECTOR_HDMIA, |
| 454 | DRM_MODE_CONNECTOR_HDMIB, |
| 455 | DRM_MODE_CONNECTOR_Unknown, |
| 456 | DRM_MODE_CONNECTOR_Unknown, |
| 457 | DRM_MODE_CONNECTOR_9PinDIN, |
| 458 | DRM_MODE_CONNECTOR_DisplayPort |
| 459 | }; |
| 460 | |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 461 | const uint16_t supported_devices_connector_object_id_convert[] = { |
| 462 | CONNECTOR_OBJECT_ID_NONE, |
| 463 | CONNECTOR_OBJECT_ID_VGA, |
| 464 | CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, /* not all boards support DL */ |
| 465 | CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D, /* not all boards support DL */ |
| 466 | CONNECTOR_OBJECT_ID_VGA, /* technically DVI-A */ |
| 467 | CONNECTOR_OBJECT_ID_COMPOSITE, |
| 468 | CONNECTOR_OBJECT_ID_SVIDEO, |
| 469 | CONNECTOR_OBJECT_ID_LVDS, |
| 470 | CONNECTOR_OBJECT_ID_9PIN_DIN, |
| 471 | CONNECTOR_OBJECT_ID_9PIN_DIN, |
| 472 | CONNECTOR_OBJECT_ID_DISPLAYPORT, |
| 473 | CONNECTOR_OBJECT_ID_HDMI_TYPE_A, |
| 474 | CONNECTOR_OBJECT_ID_HDMI_TYPE_B, |
| 475 | CONNECTOR_OBJECT_ID_SVIDEO |
| 476 | }; |
| 477 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 478 | const int object_connector_convert[] = { |
| 479 | DRM_MODE_CONNECTOR_Unknown, |
| 480 | DRM_MODE_CONNECTOR_DVII, |
| 481 | DRM_MODE_CONNECTOR_DVII, |
| 482 | DRM_MODE_CONNECTOR_DVID, |
| 483 | DRM_MODE_CONNECTOR_DVID, |
| 484 | DRM_MODE_CONNECTOR_VGA, |
| 485 | DRM_MODE_CONNECTOR_Composite, |
| 486 | DRM_MODE_CONNECTOR_SVIDEO, |
| 487 | DRM_MODE_CONNECTOR_Unknown, |
Alex Deucher | 705af9c | 2009-09-10 16:31:13 -0400 | [diff] [blame] | 488 | DRM_MODE_CONNECTOR_Unknown, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 489 | DRM_MODE_CONNECTOR_9PinDIN, |
| 490 | DRM_MODE_CONNECTOR_Unknown, |
| 491 | DRM_MODE_CONNECTOR_HDMIA, |
| 492 | DRM_MODE_CONNECTOR_HDMIB, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 493 | DRM_MODE_CONNECTOR_LVDS, |
| 494 | DRM_MODE_CONNECTOR_9PinDIN, |
| 495 | DRM_MODE_CONNECTOR_Unknown, |
| 496 | DRM_MODE_CONNECTOR_Unknown, |
| 497 | DRM_MODE_CONNECTOR_Unknown, |
Alex Deucher | 196c58d | 2010-01-07 14:22:32 -0500 | [diff] [blame] | 498 | DRM_MODE_CONNECTOR_DisplayPort, |
| 499 | DRM_MODE_CONNECTOR_eDP, |
| 500 | DRM_MODE_CONNECTOR_Unknown |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 501 | }; |
| 502 | |
| 503 | bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev) |
| 504 | { |
| 505 | struct radeon_device *rdev = dev->dev_private; |
| 506 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
| 507 | struct atom_context *ctx = mode_info->atom_context; |
| 508 | int index = GetIndexIntoMasterTable(DATA, Object_Header); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 509 | u16 size, data_offset; |
| 510 | u8 frev, crev; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 511 | ATOM_CONNECTOR_OBJECT_TABLE *con_obj; |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 512 | ATOM_OBJECT_TABLE *router_obj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 513 | ATOM_DISPLAY_OBJECT_PATH_TABLE *path_obj; |
| 514 | ATOM_OBJECT_HEADER *obj_header; |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 515 | int i, j, k, path_size, device_support; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 516 | int connector_type; |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 517 | u16 igp_lane_info, conn_id, connector_object_id; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 518 | struct radeon_i2c_bus_rec ddc_bus; |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 519 | struct radeon_router router; |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 520 | struct radeon_gpio_rec gpio; |
| 521 | struct radeon_hpd hpd; |
| 522 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 523 | if (!atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 524 | return false; |
| 525 | |
| 526 | if (crev < 2) |
| 527 | return false; |
| 528 | |
Alex Deucher | fb939df | 2010-11-08 16:08:29 +0000 | [diff] [blame^] | 529 | router.ddc_valid = false; |
| 530 | router.cd_valid = false; |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 531 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 532 | obj_header = (ATOM_OBJECT_HEADER *) (ctx->bios + data_offset); |
| 533 | path_obj = (ATOM_DISPLAY_OBJECT_PATH_TABLE *) |
| 534 | (ctx->bios + data_offset + |
| 535 | le16_to_cpu(obj_header->usDisplayPathTableOffset)); |
| 536 | con_obj = (ATOM_CONNECTOR_OBJECT_TABLE *) |
| 537 | (ctx->bios + data_offset + |
| 538 | le16_to_cpu(obj_header->usConnectorObjectTableOffset)); |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 539 | router_obj = (ATOM_OBJECT_TABLE *) |
| 540 | (ctx->bios + data_offset + |
| 541 | le16_to_cpu(obj_header->usRouterObjectTableOffset)); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 542 | device_support = le16_to_cpu(obj_header->usDeviceSupport); |
| 543 | |
| 544 | path_size = 0; |
| 545 | for (i = 0; i < path_obj->ucNumOfDispPath; i++) { |
| 546 | uint8_t *addr = (uint8_t *) path_obj->asDispPath; |
| 547 | ATOM_DISPLAY_OBJECT_PATH *path; |
| 548 | addr += path_size; |
| 549 | path = (ATOM_DISPLAY_OBJECT_PATH *) addr; |
| 550 | path_size += le16_to_cpu(path->usSize); |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 551 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 552 | if (device_support & le16_to_cpu(path->usDeviceTag)) { |
| 553 | uint8_t con_obj_id, con_obj_num, con_obj_type; |
| 554 | |
| 555 | con_obj_id = |
| 556 | (le16_to_cpu(path->usConnObjectId) & OBJECT_ID_MASK) |
| 557 | >> OBJECT_ID_SHIFT; |
| 558 | con_obj_num = |
| 559 | (le16_to_cpu(path->usConnObjectId) & ENUM_ID_MASK) |
| 560 | >> ENUM_ID_SHIFT; |
| 561 | con_obj_type = |
| 562 | (le16_to_cpu(path->usConnObjectId) & |
| 563 | OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT; |
| 564 | |
Dave Airlie | 4bbd497 | 2009-09-25 08:56:12 +1000 | [diff] [blame] | 565 | /* TODO CV support */ |
| 566 | if (le16_to_cpu(path->usDeviceTag) == |
| 567 | ATOM_DEVICE_CV_SUPPORT) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 568 | continue; |
| 569 | |
Alex Deucher | ee59f2b | 2009-11-05 13:11:46 -0500 | [diff] [blame] | 570 | /* IGP chips */ |
| 571 | if ((rdev->flags & RADEON_IS_IGP) && |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 572 | (con_obj_id == |
| 573 | CONNECTOR_OBJECT_ID_PCIE_CONNECTOR)) { |
| 574 | uint16_t igp_offset = 0; |
| 575 | ATOM_INTEGRATED_SYSTEM_INFO_V2 *igp_obj; |
| 576 | |
| 577 | index = |
| 578 | GetIndexIntoMasterTable(DATA, |
| 579 | IntegratedSystemInfo); |
| 580 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 581 | if (atom_parse_data_header(ctx, index, &size, &frev, |
| 582 | &crev, &igp_offset)) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 583 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 584 | if (crev >= 2) { |
| 585 | igp_obj = |
| 586 | (ATOM_INTEGRATED_SYSTEM_INFO_V2 |
| 587 | *) (ctx->bios + igp_offset); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 588 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 589 | if (igp_obj) { |
| 590 | uint32_t slot_config, ct; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 591 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 592 | if (con_obj_num == 1) |
| 593 | slot_config = |
| 594 | igp_obj-> |
| 595 | ulDDISlot1Config; |
| 596 | else |
| 597 | slot_config = |
| 598 | igp_obj-> |
| 599 | ulDDISlot2Config; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 600 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 601 | ct = (slot_config >> 16) & 0xff; |
| 602 | connector_type = |
| 603 | object_connector_convert |
| 604 | [ct]; |
| 605 | connector_object_id = ct; |
| 606 | igp_lane_info = |
| 607 | slot_config & 0xffff; |
| 608 | } else |
| 609 | continue; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 610 | } else |
| 611 | continue; |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 612 | } else { |
| 613 | igp_lane_info = 0; |
| 614 | connector_type = |
| 615 | object_connector_convert[con_obj_id]; |
| 616 | connector_object_id = con_obj_id; |
| 617 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 618 | } else { |
| 619 | igp_lane_info = 0; |
| 620 | connector_type = |
| 621 | object_connector_convert[con_obj_id]; |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 622 | connector_object_id = con_obj_id; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | if (connector_type == DRM_MODE_CONNECTOR_Unknown) |
| 626 | continue; |
| 627 | |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 628 | for (j = 0; j < ((le16_to_cpu(path->usSize) - 8) / 2); j++) { |
| 629 | uint8_t grph_obj_id, grph_obj_num, grph_obj_type; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 630 | |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 631 | grph_obj_id = |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 632 | (le16_to_cpu(path->usGraphicObjIds[j]) & |
| 633 | OBJECT_ID_MASK) >> OBJECT_ID_SHIFT; |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 634 | grph_obj_num = |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 635 | (le16_to_cpu(path->usGraphicObjIds[j]) & |
| 636 | ENUM_ID_MASK) >> ENUM_ID_SHIFT; |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 637 | grph_obj_type = |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 638 | (le16_to_cpu(path->usGraphicObjIds[j]) & |
| 639 | OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT; |
| 640 | |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 641 | if (grph_obj_type == GRAPH_OBJECT_TYPE_ENCODER) { |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 642 | u16 encoder_obj = le16_to_cpu(path->usGraphicObjIds[j]); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 643 | |
| 644 | radeon_add_atom_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 645 | encoder_obj, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 646 | le16_to_cpu |
| 647 | (path-> |
| 648 | usDeviceTag)); |
| 649 | |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 650 | } else if (grph_obj_type == GRAPH_OBJECT_TYPE_ROUTER) { |
Alex Deucher | fb939df | 2010-11-08 16:08:29 +0000 | [diff] [blame^] | 651 | router.ddc_valid = false; |
| 652 | router.cd_valid = false; |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 653 | for (k = 0; k < router_obj->ucNumberOfObjects; k++) { |
| 654 | u16 router_obj_id = le16_to_cpu(router_obj->asObjects[j].usObjectID); |
| 655 | if (le16_to_cpu(path->usGraphicObjIds[j]) == router_obj_id) { |
| 656 | ATOM_COMMON_RECORD_HEADER *record = (ATOM_COMMON_RECORD_HEADER *) |
| 657 | (ctx->bios + data_offset + |
| 658 | le16_to_cpu(router_obj->asObjects[k].usRecordOffset)); |
| 659 | ATOM_I2C_RECORD *i2c_record; |
| 660 | ATOM_I2C_ID_CONFIG_ACCESS *i2c_config; |
| 661 | ATOM_ROUTER_DDC_PATH_SELECT_RECORD *ddc_path; |
Alex Deucher | fb939df | 2010-11-08 16:08:29 +0000 | [diff] [blame^] | 662 | ATOM_ROUTER_DATA_CLOCK_PATH_SELECT_RECORD *cd_path; |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 663 | ATOM_SRC_DST_TABLE_FOR_ONE_OBJECT *router_src_dst_table = |
| 664 | (ATOM_SRC_DST_TABLE_FOR_ONE_OBJECT *) |
| 665 | (ctx->bios + data_offset + |
| 666 | le16_to_cpu(router_obj->asObjects[k].usSrcDstTableOffset)); |
| 667 | int enum_id; |
| 668 | |
| 669 | router.router_id = router_obj_id; |
| 670 | for (enum_id = 0; enum_id < router_src_dst_table->ucNumberOfDst; |
| 671 | enum_id++) { |
| 672 | if (le16_to_cpu(path->usConnObjectId) == |
| 673 | le16_to_cpu(router_src_dst_table->usDstObjectID[enum_id])) |
| 674 | break; |
| 675 | } |
| 676 | |
| 677 | while (record->ucRecordType > 0 && |
| 678 | record->ucRecordType <= ATOM_MAX_OBJECT_RECORD_NUMBER) { |
| 679 | switch (record->ucRecordType) { |
| 680 | case ATOM_I2C_RECORD_TYPE: |
| 681 | i2c_record = |
| 682 | (ATOM_I2C_RECORD *) |
| 683 | record; |
| 684 | i2c_config = |
| 685 | (ATOM_I2C_ID_CONFIG_ACCESS *) |
| 686 | &i2c_record->sucI2cId; |
| 687 | router.i2c_info = |
| 688 | radeon_lookup_i2c_gpio(rdev, |
| 689 | i2c_config-> |
| 690 | ucAccess); |
| 691 | router.i2c_addr = i2c_record->ucI2CAddr >> 1; |
| 692 | break; |
| 693 | case ATOM_ROUTER_DDC_PATH_SELECT_RECORD_TYPE: |
| 694 | ddc_path = (ATOM_ROUTER_DDC_PATH_SELECT_RECORD *) |
| 695 | record; |
Alex Deucher | fb939df | 2010-11-08 16:08:29 +0000 | [diff] [blame^] | 696 | router.ddc_valid = true; |
| 697 | router.ddc_mux_type = ddc_path->ucMuxType; |
| 698 | router.ddc_mux_control_pin = ddc_path->ucMuxControlPin; |
| 699 | router.ddc_mux_state = ddc_path->ucMuxState[enum_id]; |
| 700 | break; |
| 701 | case ATOM_ROUTER_DATA_CLOCK_PATH_SELECT_RECORD_TYPE: |
| 702 | cd_path = (ATOM_ROUTER_DATA_CLOCK_PATH_SELECT_RECORD *) |
| 703 | record; |
| 704 | router.cd_valid = true; |
| 705 | router.cd_mux_type = cd_path->ucMuxType; |
| 706 | router.cd_mux_control_pin = cd_path->ucMuxControlPin; |
| 707 | router.cd_mux_state = cd_path->ucMuxState[enum_id]; |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 708 | break; |
| 709 | } |
| 710 | record = (ATOM_COMMON_RECORD_HEADER *) |
| 711 | ((char *)record + record->ucRecordSize); |
| 712 | } |
| 713 | } |
| 714 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 715 | } |
| 716 | } |
| 717 | |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 718 | /* look up gpio for ddc, hpd */ |
Alex Deucher | 2bfcc0f | 2010-05-18 19:26:46 -0400 | [diff] [blame] | 719 | ddc_bus.valid = false; |
| 720 | hpd.hpd = RADEON_HPD_NONE; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 721 | if ((le16_to_cpu(path->usDeviceTag) & |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 722 | (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT)) == 0) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 723 | for (j = 0; j < con_obj->ucNumberOfObjects; j++) { |
| 724 | if (le16_to_cpu(path->usConnObjectId) == |
| 725 | le16_to_cpu(con_obj->asObjects[j]. |
| 726 | usObjectID)) { |
| 727 | ATOM_COMMON_RECORD_HEADER |
| 728 | *record = |
| 729 | (ATOM_COMMON_RECORD_HEADER |
| 730 | *) |
| 731 | (ctx->bios + data_offset + |
| 732 | le16_to_cpu(con_obj-> |
| 733 | asObjects[j]. |
| 734 | usRecordOffset)); |
| 735 | ATOM_I2C_RECORD *i2c_record; |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 736 | ATOM_HPD_INT_RECORD *hpd_record; |
Alex Deucher | d3f420d | 2009-12-08 14:30:49 -0500 | [diff] [blame] | 737 | ATOM_I2C_ID_CONFIG_ACCESS *i2c_config; |
Alex Deucher | 6a93cb2 | 2009-11-23 17:39:28 -0500 | [diff] [blame] | 738 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 739 | while (record->ucRecordType > 0 |
| 740 | && record-> |
| 741 | ucRecordType <= |
| 742 | ATOM_MAX_OBJECT_RECORD_NUMBER) { |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 743 | switch (record->ucRecordType) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 744 | case ATOM_I2C_RECORD_TYPE: |
| 745 | i2c_record = |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 746 | (ATOM_I2C_RECORD *) |
| 747 | record; |
Alex Deucher | d3f420d | 2009-12-08 14:30:49 -0500 | [diff] [blame] | 748 | i2c_config = |
| 749 | (ATOM_I2C_ID_CONFIG_ACCESS *) |
| 750 | &i2c_record->sucI2cId; |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 751 | ddc_bus = radeon_lookup_i2c_gpio(rdev, |
Alex Deucher | d3f420d | 2009-12-08 14:30:49 -0500 | [diff] [blame] | 752 | i2c_config-> |
| 753 | ucAccess); |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 754 | break; |
| 755 | case ATOM_HPD_INT_RECORD_TYPE: |
| 756 | hpd_record = |
| 757 | (ATOM_HPD_INT_RECORD *) |
| 758 | record; |
| 759 | gpio = radeon_lookup_gpio(rdev, |
| 760 | hpd_record->ucHPDIntGPIOID); |
| 761 | hpd = radeon_atom_get_hpd_info_from_gpio(rdev, &gpio); |
| 762 | hpd.plugged_state = hpd_record->ucPlugged_PinState; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 763 | break; |
| 764 | } |
| 765 | record = |
| 766 | (ATOM_COMMON_RECORD_HEADER |
| 767 | *) ((char *)record |
| 768 | + |
| 769 | record-> |
| 770 | ucRecordSize); |
| 771 | } |
| 772 | break; |
| 773 | } |
| 774 | } |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 775 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 776 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 777 | /* needed for aux chan transactions */ |
Alex Deucher | 8e36ed0 | 2010-05-18 19:26:47 -0400 | [diff] [blame] | 778 | ddc_bus.hpd = hpd.hpd; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 779 | |
Alex Deucher | 705af9c | 2009-09-10 16:31:13 -0400 | [diff] [blame] | 780 | conn_id = le16_to_cpu(path->usConnObjectId); |
| 781 | |
| 782 | if (!radeon_atom_apply_quirks |
| 783 | (dev, le16_to_cpu(path->usDeviceTag), &connector_type, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 784 | &ddc_bus, &conn_id, &hpd)) |
Alex Deucher | 705af9c | 2009-09-10 16:31:13 -0400 | [diff] [blame] | 785 | continue; |
| 786 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 787 | radeon_add_atom_connector(dev, |
Alex Deucher | 705af9c | 2009-09-10 16:31:13 -0400 | [diff] [blame] | 788 | conn_id, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 789 | le16_to_cpu(path-> |
| 790 | usDeviceTag), |
| 791 | connector_type, &ddc_bus, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 792 | igp_lane_info, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 793 | connector_object_id, |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 794 | &hpd, |
| 795 | &router); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 796 | |
| 797 | } |
| 798 | } |
| 799 | |
| 800 | radeon_link_encoder_connector(dev); |
| 801 | |
| 802 | return true; |
| 803 | } |
| 804 | |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 805 | static uint16_t atombios_get_connector_object_id(struct drm_device *dev, |
| 806 | int connector_type, |
| 807 | uint16_t devices) |
| 808 | { |
| 809 | struct radeon_device *rdev = dev->dev_private; |
| 810 | |
| 811 | if (rdev->flags & RADEON_IS_IGP) { |
| 812 | return supported_devices_connector_object_id_convert |
| 813 | [connector_type]; |
| 814 | } else if (((connector_type == DRM_MODE_CONNECTOR_DVII) || |
| 815 | (connector_type == DRM_MODE_CONNECTOR_DVID)) && |
| 816 | (devices & ATOM_DEVICE_DFP2_SUPPORT)) { |
| 817 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
| 818 | struct atom_context *ctx = mode_info->atom_context; |
| 819 | int index = GetIndexIntoMasterTable(DATA, XTMDS_Info); |
| 820 | uint16_t size, data_offset; |
| 821 | uint8_t frev, crev; |
| 822 | ATOM_XTMDS_INFO *xtmds; |
| 823 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 824 | if (atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset)) { |
| 825 | xtmds = (ATOM_XTMDS_INFO *)(ctx->bios + data_offset); |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 826 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 827 | if (xtmds->ucSupportedLink & ATOM_XTMDS_SUPPORTED_DUALLINK) { |
| 828 | if (connector_type == DRM_MODE_CONNECTOR_DVII) |
| 829 | return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; |
| 830 | else |
| 831 | return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; |
| 832 | } else { |
| 833 | if (connector_type == DRM_MODE_CONNECTOR_DVII) |
| 834 | return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; |
| 835 | else |
| 836 | return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; |
| 837 | } |
| 838 | } else |
| 839 | return supported_devices_connector_object_id_convert |
| 840 | [connector_type]; |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 841 | } else { |
| 842 | return supported_devices_connector_object_id_convert |
| 843 | [connector_type]; |
| 844 | } |
| 845 | } |
| 846 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 847 | struct bios_connector { |
| 848 | bool valid; |
Alex Deucher | 705af9c | 2009-09-10 16:31:13 -0400 | [diff] [blame] | 849 | uint16_t line_mux; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 850 | uint16_t devices; |
| 851 | int connector_type; |
| 852 | struct radeon_i2c_bus_rec ddc_bus; |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 853 | struct radeon_hpd hpd; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 854 | }; |
| 855 | |
| 856 | bool radeon_get_atom_connector_info_from_supported_devices_table(struct |
| 857 | drm_device |
| 858 | *dev) |
| 859 | { |
| 860 | struct radeon_device *rdev = dev->dev_private; |
| 861 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
| 862 | struct atom_context *ctx = mode_info->atom_context; |
| 863 | int index = GetIndexIntoMasterTable(DATA, SupportedDevicesInfo); |
| 864 | uint16_t size, data_offset; |
| 865 | uint8_t frev, crev; |
| 866 | uint16_t device_support; |
| 867 | uint8_t dac; |
| 868 | union atom_supported_devices *supported_devices; |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 869 | int i, j, max_device; |
Prarit Bhargava | f49d273 | 2010-05-24 10:24:07 +1000 | [diff] [blame] | 870 | struct bios_connector *bios_connectors; |
| 871 | size_t bc_size = sizeof(*bios_connectors) * ATOM_MAX_SUPPORTED_DEVICE; |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 872 | struct radeon_router router; |
| 873 | |
Alex Deucher | fb939df | 2010-11-08 16:08:29 +0000 | [diff] [blame^] | 874 | router.ddc_valid = false; |
| 875 | router.cd_valid = false; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 876 | |
Prarit Bhargava | f49d273 | 2010-05-24 10:24:07 +1000 | [diff] [blame] | 877 | bios_connectors = kzalloc(bc_size, GFP_KERNEL); |
| 878 | if (!bios_connectors) |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 879 | return false; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 880 | |
Prarit Bhargava | f49d273 | 2010-05-24 10:24:07 +1000 | [diff] [blame] | 881 | if (!atom_parse_data_header(ctx, index, &size, &frev, &crev, |
| 882 | &data_offset)) { |
| 883 | kfree(bios_connectors); |
| 884 | return false; |
| 885 | } |
| 886 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 887 | supported_devices = |
| 888 | (union atom_supported_devices *)(ctx->bios + data_offset); |
| 889 | |
| 890 | device_support = le16_to_cpu(supported_devices->info.usDeviceSupport); |
| 891 | |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 892 | if (frev > 1) |
| 893 | max_device = ATOM_MAX_SUPPORTED_DEVICE; |
| 894 | else |
| 895 | max_device = ATOM_MAX_SUPPORTED_DEVICE_INFO; |
| 896 | |
| 897 | for (i = 0; i < max_device; i++) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 898 | ATOM_CONNECTOR_INFO_I2C ci = |
| 899 | supported_devices->info.asConnInfo[i]; |
| 900 | |
| 901 | bios_connectors[i].valid = false; |
| 902 | |
| 903 | if (!(device_support & (1 << i))) { |
| 904 | continue; |
| 905 | } |
| 906 | |
| 907 | if (i == ATOM_DEVICE_CV_INDEX) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 908 | DRM_DEBUG_KMS("Skipping Component Video\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 909 | continue; |
| 910 | } |
| 911 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 912 | bios_connectors[i].connector_type = |
| 913 | supported_devices_connector_convert[ci.sucConnectorInfo. |
| 914 | sbfAccess. |
| 915 | bfConnectorType]; |
| 916 | |
| 917 | if (bios_connectors[i].connector_type == |
| 918 | DRM_MODE_CONNECTOR_Unknown) |
| 919 | continue; |
| 920 | |
| 921 | dac = ci.sucConnectorInfo.sbfAccess.bfAssociatedDAC; |
| 922 | |
Alex Deucher | d3f420d | 2009-12-08 14:30:49 -0500 | [diff] [blame] | 923 | bios_connectors[i].line_mux = |
| 924 | ci.sucI2cId.ucAccess; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 925 | |
| 926 | /* give tv unique connector ids */ |
| 927 | if (i == ATOM_DEVICE_TV1_INDEX) { |
| 928 | bios_connectors[i].ddc_bus.valid = false; |
| 929 | bios_connectors[i].line_mux = 50; |
| 930 | } else if (i == ATOM_DEVICE_TV2_INDEX) { |
| 931 | bios_connectors[i].ddc_bus.valid = false; |
| 932 | bios_connectors[i].line_mux = 51; |
| 933 | } else if (i == ATOM_DEVICE_CV_INDEX) { |
| 934 | bios_connectors[i].ddc_bus.valid = false; |
| 935 | bios_connectors[i].line_mux = 52; |
| 936 | } else |
| 937 | bios_connectors[i].ddc_bus = |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 938 | radeon_lookup_i2c_gpio(rdev, |
| 939 | bios_connectors[i].line_mux); |
| 940 | |
| 941 | if ((crev > 1) && (frev > 1)) { |
| 942 | u8 isb = supported_devices->info_2d1.asIntSrcInfo[i].ucIntSrcBitmap; |
| 943 | switch (isb) { |
| 944 | case 0x4: |
| 945 | bios_connectors[i].hpd.hpd = RADEON_HPD_1; |
| 946 | break; |
| 947 | case 0xa: |
| 948 | bios_connectors[i].hpd.hpd = RADEON_HPD_2; |
| 949 | break; |
| 950 | default: |
| 951 | bios_connectors[i].hpd.hpd = RADEON_HPD_NONE; |
| 952 | break; |
| 953 | } |
| 954 | } else { |
| 955 | if (i == ATOM_DEVICE_DFP1_INDEX) |
| 956 | bios_connectors[i].hpd.hpd = RADEON_HPD_1; |
| 957 | else if (i == ATOM_DEVICE_DFP2_INDEX) |
| 958 | bios_connectors[i].hpd.hpd = RADEON_HPD_2; |
| 959 | else |
| 960 | bios_connectors[i].hpd.hpd = RADEON_HPD_NONE; |
| 961 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 962 | |
| 963 | /* Always set the connector type to VGA for CRT1/CRT2. if they are |
| 964 | * shared with a DVI port, we'll pick up the DVI connector when we |
| 965 | * merge the outputs. Some bioses incorrectly list VGA ports as DVI. |
| 966 | */ |
| 967 | if (i == ATOM_DEVICE_CRT1_INDEX || i == ATOM_DEVICE_CRT2_INDEX) |
| 968 | bios_connectors[i].connector_type = |
| 969 | DRM_MODE_CONNECTOR_VGA; |
| 970 | |
| 971 | if (!radeon_atom_apply_quirks |
| 972 | (dev, (1 << i), &bios_connectors[i].connector_type, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 973 | &bios_connectors[i].ddc_bus, &bios_connectors[i].line_mux, |
| 974 | &bios_connectors[i].hpd)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 975 | continue; |
| 976 | |
| 977 | bios_connectors[i].valid = true; |
| 978 | bios_connectors[i].devices = (1 << i); |
| 979 | |
| 980 | if (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom) |
| 981 | radeon_add_atom_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 982 | radeon_get_encoder_enum(dev, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 983 | (1 << i), |
| 984 | dac), |
| 985 | (1 << i)); |
| 986 | else |
| 987 | radeon_add_legacy_encoder(dev, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 988 | radeon_get_encoder_enum(dev, |
Alex Deucher | f56cd64 | 2009-12-18 11:28:22 -0500 | [diff] [blame] | 989 | (1 << i), |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 990 | dac), |
| 991 | (1 << i)); |
| 992 | } |
| 993 | |
| 994 | /* combine shared connectors */ |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 995 | for (i = 0; i < max_device; i++) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 996 | if (bios_connectors[i].valid) { |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 997 | for (j = 0; j < max_device; j++) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 998 | if (bios_connectors[j].valid && (i != j)) { |
| 999 | if (bios_connectors[i].line_mux == |
| 1000 | bios_connectors[j].line_mux) { |
Alex Deucher | f56cd64 | 2009-12-18 11:28:22 -0500 | [diff] [blame] | 1001 | /* make sure not to combine LVDS */ |
| 1002 | if (bios_connectors[i].devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
| 1003 | bios_connectors[i].line_mux = 53; |
| 1004 | bios_connectors[i].ddc_bus.valid = false; |
| 1005 | continue; |
| 1006 | } |
| 1007 | if (bios_connectors[j].devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
| 1008 | bios_connectors[j].line_mux = 53; |
| 1009 | bios_connectors[j].ddc_bus.valid = false; |
| 1010 | continue; |
| 1011 | } |
| 1012 | /* combine analog and digital for DVI-I */ |
| 1013 | if (((bios_connectors[i].devices & (ATOM_DEVICE_DFP_SUPPORT)) && |
| 1014 | (bios_connectors[j].devices & (ATOM_DEVICE_CRT_SUPPORT))) || |
| 1015 | ((bios_connectors[j].devices & (ATOM_DEVICE_DFP_SUPPORT)) && |
| 1016 | (bios_connectors[i].devices & (ATOM_DEVICE_CRT_SUPPORT)))) { |
| 1017 | bios_connectors[i].devices |= |
| 1018 | bios_connectors[j].devices; |
| 1019 | bios_connectors[i].connector_type = |
| 1020 | DRM_MODE_CONNECTOR_DVII; |
| 1021 | if (bios_connectors[j].devices & (ATOM_DEVICE_DFP_SUPPORT)) |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1022 | bios_connectors[i].hpd = |
| 1023 | bios_connectors[j].hpd; |
Alex Deucher | f56cd64 | 2009-12-18 11:28:22 -0500 | [diff] [blame] | 1024 | bios_connectors[j].valid = false; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1025 | } |
| 1026 | } |
| 1027 | } |
| 1028 | } |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | /* add the connectors */ |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1033 | for (i = 0; i < max_device; i++) { |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1034 | if (bios_connectors[i].valid) { |
| 1035 | uint16_t connector_object_id = |
| 1036 | atombios_get_connector_object_id(dev, |
| 1037 | bios_connectors[i].connector_type, |
| 1038 | bios_connectors[i].devices); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1039 | radeon_add_atom_connector(dev, |
| 1040 | bios_connectors[i].line_mux, |
| 1041 | bios_connectors[i].devices, |
| 1042 | bios_connectors[i]. |
| 1043 | connector_type, |
| 1044 | &bios_connectors[i].ddc_bus, |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1045 | 0, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1046 | connector_object_id, |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 1047 | &bios_connectors[i].hpd, |
| 1048 | &router); |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1049 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1050 | } |
| 1051 | |
| 1052 | radeon_link_encoder_connector(dev); |
| 1053 | |
Prarit Bhargava | f49d273 | 2010-05-24 10:24:07 +1000 | [diff] [blame] | 1054 | kfree(bios_connectors); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1055 | return true; |
| 1056 | } |
| 1057 | |
| 1058 | union firmware_info { |
| 1059 | ATOM_FIRMWARE_INFO info; |
| 1060 | ATOM_FIRMWARE_INFO_V1_2 info_12; |
| 1061 | ATOM_FIRMWARE_INFO_V1_3 info_13; |
| 1062 | ATOM_FIRMWARE_INFO_V1_4 info_14; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1063 | ATOM_FIRMWARE_INFO_V2_1 info_21; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1064 | }; |
| 1065 | |
| 1066 | bool radeon_atom_get_clock_info(struct drm_device *dev) |
| 1067 | { |
| 1068 | struct radeon_device *rdev = dev->dev_private; |
| 1069 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
| 1070 | int index = GetIndexIntoMasterTable(DATA, FirmwareInfo); |
| 1071 | union firmware_info *firmware_info; |
| 1072 | uint8_t frev, crev; |
| 1073 | struct radeon_pll *p1pll = &rdev->clock.p1pll; |
| 1074 | struct radeon_pll *p2pll = &rdev->clock.p2pll; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1075 | struct radeon_pll *dcpll = &rdev->clock.dcpll; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1076 | struct radeon_pll *spll = &rdev->clock.spll; |
| 1077 | struct radeon_pll *mpll = &rdev->clock.mpll; |
| 1078 | uint16_t data_offset; |
| 1079 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1080 | if (atom_parse_data_header(mode_info->atom_context, index, NULL, |
| 1081 | &frev, &crev, &data_offset)) { |
| 1082 | firmware_info = |
| 1083 | (union firmware_info *)(mode_info->atom_context->bios + |
| 1084 | data_offset); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1085 | /* pixel clocks */ |
| 1086 | p1pll->reference_freq = |
| 1087 | le16_to_cpu(firmware_info->info.usReferenceClock); |
| 1088 | p1pll->reference_div = 0; |
| 1089 | |
Mathias Fröhlich | bc293e5 | 2009-10-19 17:49:49 -0400 | [diff] [blame] | 1090 | if (crev < 2) |
| 1091 | p1pll->pll_out_min = |
| 1092 | le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Output); |
| 1093 | else |
| 1094 | p1pll->pll_out_min = |
| 1095 | le32_to_cpu(firmware_info->info_12.ulMinPixelClockPLL_Output); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1096 | p1pll->pll_out_max = |
| 1097 | le32_to_cpu(firmware_info->info.ulMaxPixelClockPLL_Output); |
| 1098 | |
Alex Deucher | 86cb2bb | 2010-03-08 12:55:16 -0500 | [diff] [blame] | 1099 | if (crev >= 4) { |
| 1100 | p1pll->lcd_pll_out_min = |
| 1101 | le16_to_cpu(firmware_info->info_14.usLcdMinPixelClockPLL_Output) * 100; |
| 1102 | if (p1pll->lcd_pll_out_min == 0) |
| 1103 | p1pll->lcd_pll_out_min = p1pll->pll_out_min; |
| 1104 | p1pll->lcd_pll_out_max = |
| 1105 | le16_to_cpu(firmware_info->info_14.usLcdMaxPixelClockPLL_Output) * 100; |
| 1106 | if (p1pll->lcd_pll_out_max == 0) |
| 1107 | p1pll->lcd_pll_out_max = p1pll->pll_out_max; |
| 1108 | } else { |
| 1109 | p1pll->lcd_pll_out_min = p1pll->pll_out_min; |
| 1110 | p1pll->lcd_pll_out_max = p1pll->pll_out_max; |
| 1111 | } |
| 1112 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1113 | if (p1pll->pll_out_min == 0) { |
| 1114 | if (ASIC_IS_AVIVO(rdev)) |
| 1115 | p1pll->pll_out_min = 64800; |
| 1116 | else |
| 1117 | p1pll->pll_out_min = 20000; |
Alex Deucher | 8f552a6 | 2009-10-27 11:16:09 -0400 | [diff] [blame] | 1118 | } else if (p1pll->pll_out_min > 64800) { |
| 1119 | /* Limiting the pll output range is a good thing generally as |
| 1120 | * it limits the number of possible pll combinations for a given |
| 1121 | * frequency presumably to the ones that work best on each card. |
| 1122 | * However, certain duallink DVI monitors seem to like |
| 1123 | * pll combinations that would be limited by this at least on |
| 1124 | * pre-DCE 3.0 r6xx hardware. This might need to be adjusted per |
| 1125 | * family. |
| 1126 | */ |
Alex Deucher | 48dfaae | 2010-09-29 11:37:41 -0400 | [diff] [blame] | 1127 | p1pll->pll_out_min = 64800; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1128 | } |
| 1129 | |
| 1130 | p1pll->pll_in_min = |
| 1131 | le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Input); |
| 1132 | p1pll->pll_in_max = |
| 1133 | le16_to_cpu(firmware_info->info.usMaxPixelClockPLL_Input); |
| 1134 | |
| 1135 | *p2pll = *p1pll; |
| 1136 | |
| 1137 | /* system clock */ |
| 1138 | spll->reference_freq = |
| 1139 | le16_to_cpu(firmware_info->info.usReferenceClock); |
| 1140 | spll->reference_div = 0; |
| 1141 | |
| 1142 | spll->pll_out_min = |
| 1143 | le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Output); |
| 1144 | spll->pll_out_max = |
| 1145 | le32_to_cpu(firmware_info->info.ulMaxEngineClockPLL_Output); |
| 1146 | |
| 1147 | /* ??? */ |
| 1148 | if (spll->pll_out_min == 0) { |
| 1149 | if (ASIC_IS_AVIVO(rdev)) |
| 1150 | spll->pll_out_min = 64800; |
| 1151 | else |
| 1152 | spll->pll_out_min = 20000; |
| 1153 | } |
| 1154 | |
| 1155 | spll->pll_in_min = |
| 1156 | le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Input); |
| 1157 | spll->pll_in_max = |
| 1158 | le16_to_cpu(firmware_info->info.usMaxEngineClockPLL_Input); |
| 1159 | |
| 1160 | /* memory clock */ |
| 1161 | mpll->reference_freq = |
| 1162 | le16_to_cpu(firmware_info->info.usReferenceClock); |
| 1163 | mpll->reference_div = 0; |
| 1164 | |
| 1165 | mpll->pll_out_min = |
| 1166 | le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Output); |
| 1167 | mpll->pll_out_max = |
| 1168 | le32_to_cpu(firmware_info->info.ulMaxMemoryClockPLL_Output); |
| 1169 | |
| 1170 | /* ??? */ |
| 1171 | if (mpll->pll_out_min == 0) { |
| 1172 | if (ASIC_IS_AVIVO(rdev)) |
| 1173 | mpll->pll_out_min = 64800; |
| 1174 | else |
| 1175 | mpll->pll_out_min = 20000; |
| 1176 | } |
| 1177 | |
| 1178 | mpll->pll_in_min = |
| 1179 | le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Input); |
| 1180 | mpll->pll_in_max = |
| 1181 | le16_to_cpu(firmware_info->info.usMaxMemoryClockPLL_Input); |
| 1182 | |
| 1183 | rdev->clock.default_sclk = |
| 1184 | le32_to_cpu(firmware_info->info.ulDefaultEngineClock); |
| 1185 | rdev->clock.default_mclk = |
| 1186 | le32_to_cpu(firmware_info->info.ulDefaultMemoryClock); |
| 1187 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1188 | if (ASIC_IS_DCE4(rdev)) { |
| 1189 | rdev->clock.default_dispclk = |
| 1190 | le32_to_cpu(firmware_info->info_21.ulDefaultDispEngineClkFreq); |
| 1191 | if (rdev->clock.default_dispclk == 0) |
| 1192 | rdev->clock.default_dispclk = 60000; /* 600 Mhz */ |
| 1193 | rdev->clock.dp_extclk = |
| 1194 | le16_to_cpu(firmware_info->info_21.usUniphyDPModeExtClkFreq); |
| 1195 | } |
| 1196 | *dcpll = *p1pll; |
| 1197 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1198 | return true; |
| 1199 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1200 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1201 | return false; |
| 1202 | } |
| 1203 | |
Alex Deucher | 06b6476 | 2010-01-05 11:27:29 -0500 | [diff] [blame] | 1204 | union igp_info { |
| 1205 | struct _ATOM_INTEGRATED_SYSTEM_INFO info; |
| 1206 | struct _ATOM_INTEGRATED_SYSTEM_INFO_V2 info_2; |
| 1207 | }; |
| 1208 | |
| 1209 | bool radeon_atombios_sideport_present(struct radeon_device *rdev) |
| 1210 | { |
| 1211 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
| 1212 | int index = GetIndexIntoMasterTable(DATA, IntegratedSystemInfo); |
| 1213 | union igp_info *igp_info; |
| 1214 | u8 frev, crev; |
| 1215 | u16 data_offset; |
| 1216 | |
Alex Deucher | 4c70b2e | 2010-08-02 19:39:15 -0400 | [diff] [blame] | 1217 | /* sideport is AMD only */ |
| 1218 | if (rdev->family == CHIP_RS600) |
| 1219 | return false; |
| 1220 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1221 | if (atom_parse_data_header(mode_info->atom_context, index, NULL, |
| 1222 | &frev, &crev, &data_offset)) { |
| 1223 | igp_info = (union igp_info *)(mode_info->atom_context->bios + |
Alex Deucher | 06b6476 | 2010-01-05 11:27:29 -0500 | [diff] [blame] | 1224 | data_offset); |
Alex Deucher | 06b6476 | 2010-01-05 11:27:29 -0500 | [diff] [blame] | 1225 | switch (crev) { |
| 1226 | case 1: |
Alex Deucher | 4c70b2e | 2010-08-02 19:39:15 -0400 | [diff] [blame] | 1227 | if (igp_info->info.ulBootUpMemoryClock) |
| 1228 | return true; |
Alex Deucher | 06b6476 | 2010-01-05 11:27:29 -0500 | [diff] [blame] | 1229 | break; |
| 1230 | case 2: |
Alex Deucher | 4b80d95 | 2010-08-20 12:47:54 -0400 | [diff] [blame] | 1231 | if (igp_info->info_2.ulBootUpSidePortClock) |
Alex Deucher | 06b6476 | 2010-01-05 11:27:29 -0500 | [diff] [blame] | 1232 | return true; |
| 1233 | break; |
| 1234 | default: |
| 1235 | DRM_ERROR("Unsupported IGP table: %d %d\n", frev, crev); |
| 1236 | break; |
| 1237 | } |
| 1238 | } |
| 1239 | return false; |
| 1240 | } |
| 1241 | |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 1242 | bool radeon_atombios_get_tmds_info(struct radeon_encoder *encoder, |
| 1243 | struct radeon_encoder_int_tmds *tmds) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1244 | { |
| 1245 | struct drm_device *dev = encoder->base.dev; |
| 1246 | struct radeon_device *rdev = dev->dev_private; |
| 1247 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
| 1248 | int index = GetIndexIntoMasterTable(DATA, TMDS_Info); |
| 1249 | uint16_t data_offset; |
| 1250 | struct _ATOM_TMDS_INFO *tmds_info; |
| 1251 | uint8_t frev, crev; |
| 1252 | uint16_t maxfreq; |
| 1253 | int i; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1254 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1255 | if (atom_parse_data_header(mode_info->atom_context, index, NULL, |
| 1256 | &frev, &crev, &data_offset)) { |
| 1257 | tmds_info = |
| 1258 | (struct _ATOM_TMDS_INFO *)(mode_info->atom_context->bios + |
| 1259 | data_offset); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1260 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1261 | maxfreq = le16_to_cpu(tmds_info->usMaxFrequency); |
| 1262 | for (i = 0; i < 4; i++) { |
| 1263 | tmds->tmds_pll[i].freq = |
| 1264 | le16_to_cpu(tmds_info->asMiscInfo[i].usFrequency); |
| 1265 | tmds->tmds_pll[i].value = |
| 1266 | tmds_info->asMiscInfo[i].ucPLL_ChargePump & 0x3f; |
| 1267 | tmds->tmds_pll[i].value |= |
| 1268 | (tmds_info->asMiscInfo[i]. |
| 1269 | ucPLL_VCO_Gain & 0x3f) << 6; |
| 1270 | tmds->tmds_pll[i].value |= |
| 1271 | (tmds_info->asMiscInfo[i]. |
| 1272 | ucPLL_DutyCycle & 0xf) << 12; |
| 1273 | tmds->tmds_pll[i].value |= |
| 1274 | (tmds_info->asMiscInfo[i]. |
| 1275 | ucPLL_VoltageSwing & 0xf) << 16; |
| 1276 | |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 1277 | DRM_DEBUG_KMS("TMDS PLL From ATOMBIOS %u %x\n", |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1278 | tmds->tmds_pll[i].freq, |
| 1279 | tmds->tmds_pll[i].value); |
| 1280 | |
| 1281 | if (maxfreq == tmds->tmds_pll[i].freq) { |
| 1282 | tmds->tmds_pll[i].freq = 0xffffffff; |
| 1283 | break; |
| 1284 | } |
| 1285 | } |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 1286 | return true; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1287 | } |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 1288 | return false; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1289 | } |
| 1290 | |
Alex Deucher | ba032a5 | 2010-10-04 17:13:01 -0400 | [diff] [blame] | 1291 | bool radeon_atombios_get_ppll_ss_info(struct radeon_device *rdev, |
| 1292 | struct radeon_atom_ss *ss, |
| 1293 | int id) |
Alex Deucher | ebbe1cb | 2009-10-16 11:15:25 -0400 | [diff] [blame] | 1294 | { |
Alex Deucher | ebbe1cb | 2009-10-16 11:15:25 -0400 | [diff] [blame] | 1295 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
| 1296 | int index = GetIndexIntoMasterTable(DATA, PPLL_SS_Info); |
Alex Deucher | ba032a5 | 2010-10-04 17:13:01 -0400 | [diff] [blame] | 1297 | uint16_t data_offset, size; |
Alex Deucher | ebbe1cb | 2009-10-16 11:15:25 -0400 | [diff] [blame] | 1298 | struct _ATOM_SPREAD_SPECTRUM_INFO *ss_info; |
| 1299 | uint8_t frev, crev; |
Alex Deucher | ba032a5 | 2010-10-04 17:13:01 -0400 | [diff] [blame] | 1300 | int i, num_indices; |
Alex Deucher | ebbe1cb | 2009-10-16 11:15:25 -0400 | [diff] [blame] | 1301 | |
Alex Deucher | ba032a5 | 2010-10-04 17:13:01 -0400 | [diff] [blame] | 1302 | memset(ss, 0, sizeof(struct radeon_atom_ss)); |
| 1303 | if (atom_parse_data_header(mode_info->atom_context, index, &size, |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1304 | &frev, &crev, &data_offset)) { |
| 1305 | ss_info = |
| 1306 | (struct _ATOM_SPREAD_SPECTRUM_INFO *)(mode_info->atom_context->bios + data_offset); |
Alex Deucher | ebbe1cb | 2009-10-16 11:15:25 -0400 | [diff] [blame] | 1307 | |
Alex Deucher | ba032a5 | 2010-10-04 17:13:01 -0400 | [diff] [blame] | 1308 | num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / |
| 1309 | sizeof(ATOM_SPREAD_SPECTRUM_ASSIGNMENT); |
Alex Deucher | ebbe1cb | 2009-10-16 11:15:25 -0400 | [diff] [blame] | 1310 | |
Alex Deucher | ba032a5 | 2010-10-04 17:13:01 -0400 | [diff] [blame] | 1311 | for (i = 0; i < num_indices; i++) { |
Alex Deucher | 279b215 | 2009-12-08 14:07:03 -0500 | [diff] [blame] | 1312 | if (ss_info->asSS_Info[i].ucSS_Id == id) { |
| 1313 | ss->percentage = |
| 1314 | le16_to_cpu(ss_info->asSS_Info[i].usSpreadSpectrumPercentage); |
| 1315 | ss->type = ss_info->asSS_Info[i].ucSpreadSpectrumType; |
| 1316 | ss->step = ss_info->asSS_Info[i].ucSS_Step; |
| 1317 | ss->delay = ss_info->asSS_Info[i].ucSS_Delay; |
| 1318 | ss->range = ss_info->asSS_Info[i].ucSS_Range; |
| 1319 | ss->refdiv = ss_info->asSS_Info[i].ucRecommendedRef_Div; |
Alex Deucher | ba032a5 | 2010-10-04 17:13:01 -0400 | [diff] [blame] | 1320 | return true; |
Alex Deucher | 279b215 | 2009-12-08 14:07:03 -0500 | [diff] [blame] | 1321 | } |
| 1322 | } |
Alex Deucher | ebbe1cb | 2009-10-16 11:15:25 -0400 | [diff] [blame] | 1323 | } |
Alex Deucher | ba032a5 | 2010-10-04 17:13:01 -0400 | [diff] [blame] | 1324 | return false; |
| 1325 | } |
| 1326 | |
| 1327 | union asic_ss_info { |
| 1328 | struct _ATOM_ASIC_INTERNAL_SS_INFO info; |
| 1329 | struct _ATOM_ASIC_INTERNAL_SS_INFO_V2 info_2; |
| 1330 | struct _ATOM_ASIC_INTERNAL_SS_INFO_V3 info_3; |
| 1331 | }; |
| 1332 | |
| 1333 | bool radeon_atombios_get_asic_ss_info(struct radeon_device *rdev, |
| 1334 | struct radeon_atom_ss *ss, |
| 1335 | int id, u32 clock) |
| 1336 | { |
| 1337 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
| 1338 | int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info); |
| 1339 | uint16_t data_offset, size; |
| 1340 | union asic_ss_info *ss_info; |
| 1341 | uint8_t frev, crev; |
| 1342 | int i, num_indices; |
| 1343 | |
| 1344 | memset(ss, 0, sizeof(struct radeon_atom_ss)); |
| 1345 | if (atom_parse_data_header(mode_info->atom_context, index, &size, |
| 1346 | &frev, &crev, &data_offset)) { |
| 1347 | |
| 1348 | ss_info = |
| 1349 | (union asic_ss_info *)(mode_info->atom_context->bios + data_offset); |
| 1350 | |
| 1351 | switch (frev) { |
| 1352 | case 1: |
| 1353 | num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / |
| 1354 | sizeof(ATOM_ASIC_SS_ASSIGNMENT); |
| 1355 | |
| 1356 | for (i = 0; i < num_indices; i++) { |
| 1357 | if ((ss_info->info.asSpreadSpectrum[i].ucClockIndication == id) && |
| 1358 | (clock <= ss_info->info.asSpreadSpectrum[i].ulTargetClockRange)) { |
| 1359 | ss->percentage = |
| 1360 | le16_to_cpu(ss_info->info.asSpreadSpectrum[i].usSpreadSpectrumPercentage); |
| 1361 | ss->type = ss_info->info.asSpreadSpectrum[i].ucSpreadSpectrumMode; |
| 1362 | ss->rate = le16_to_cpu(ss_info->info.asSpreadSpectrum[i].usSpreadRateInKhz); |
| 1363 | return true; |
| 1364 | } |
| 1365 | } |
| 1366 | break; |
| 1367 | case 2: |
| 1368 | num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / |
| 1369 | sizeof(ATOM_ASIC_SS_ASSIGNMENT_V2); |
| 1370 | for (i = 0; i < num_indices; i++) { |
| 1371 | if ((ss_info->info_2.asSpreadSpectrum[i].ucClockIndication == id) && |
| 1372 | (clock <= ss_info->info_2.asSpreadSpectrum[i].ulTargetClockRange)) { |
| 1373 | ss->percentage = |
| 1374 | le16_to_cpu(ss_info->info_2.asSpreadSpectrum[i].usSpreadSpectrumPercentage); |
| 1375 | ss->type = ss_info->info_2.asSpreadSpectrum[i].ucSpreadSpectrumMode; |
| 1376 | ss->rate = le16_to_cpu(ss_info->info_2.asSpreadSpectrum[i].usSpreadRateIn10Hz); |
| 1377 | return true; |
| 1378 | } |
| 1379 | } |
| 1380 | break; |
| 1381 | case 3: |
| 1382 | num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / |
| 1383 | sizeof(ATOM_ASIC_SS_ASSIGNMENT_V3); |
| 1384 | for (i = 0; i < num_indices; i++) { |
| 1385 | if ((ss_info->info_3.asSpreadSpectrum[i].ucClockIndication == id) && |
| 1386 | (clock <= ss_info->info_3.asSpreadSpectrum[i].ulTargetClockRange)) { |
| 1387 | ss->percentage = |
| 1388 | le16_to_cpu(ss_info->info_3.asSpreadSpectrum[i].usSpreadSpectrumPercentage); |
| 1389 | ss->type = ss_info->info_3.asSpreadSpectrum[i].ucSpreadSpectrumMode; |
| 1390 | ss->rate = le16_to_cpu(ss_info->info_3.asSpreadSpectrum[i].usSpreadRateIn10Hz); |
| 1391 | return true; |
| 1392 | } |
| 1393 | } |
| 1394 | break; |
| 1395 | default: |
| 1396 | DRM_ERROR("Unsupported ASIC_InternalSS_Info table: %d %d\n", frev, crev); |
| 1397 | break; |
| 1398 | } |
| 1399 | |
| 1400 | } |
| 1401 | return false; |
Alex Deucher | ebbe1cb | 2009-10-16 11:15:25 -0400 | [diff] [blame] | 1402 | } |
| 1403 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1404 | union lvds_info { |
| 1405 | struct _ATOM_LVDS_INFO info; |
| 1406 | struct _ATOM_LVDS_INFO_V12 info_12; |
| 1407 | }; |
| 1408 | |
| 1409 | struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct |
| 1410 | radeon_encoder |
| 1411 | *encoder) |
| 1412 | { |
| 1413 | struct drm_device *dev = encoder->base.dev; |
| 1414 | struct radeon_device *rdev = dev->dev_private; |
| 1415 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
| 1416 | int index = GetIndexIntoMasterTable(DATA, LVDS_Info); |
Alex Deucher | 7dde8a19 | 2009-11-30 01:40:24 -0500 | [diff] [blame] | 1417 | uint16_t data_offset, misc; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1418 | union lvds_info *lvds_info; |
| 1419 | uint8_t frev, crev; |
| 1420 | struct radeon_encoder_atom_dig *lvds = NULL; |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1421 | int encoder_enum = (encoder->encoder_enum & ENUM_ID_MASK) >> ENUM_ID_SHIFT; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1422 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1423 | if (atom_parse_data_header(mode_info->atom_context, index, NULL, |
| 1424 | &frev, &crev, &data_offset)) { |
| 1425 | lvds_info = |
| 1426 | (union lvds_info *)(mode_info->atom_context->bios + data_offset); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1427 | lvds = |
| 1428 | kzalloc(sizeof(struct radeon_encoder_atom_dig), GFP_KERNEL); |
| 1429 | |
| 1430 | if (!lvds) |
| 1431 | return NULL; |
| 1432 | |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1433 | lvds->native_mode.clock = |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1434 | le16_to_cpu(lvds_info->info.sLCDTiming.usPixClk) * 10; |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1435 | lvds->native_mode.hdisplay = |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1436 | le16_to_cpu(lvds_info->info.sLCDTiming.usHActive); |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1437 | lvds->native_mode.vdisplay = |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1438 | le16_to_cpu(lvds_info->info.sLCDTiming.usVActive); |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1439 | lvds->native_mode.htotal = lvds->native_mode.hdisplay + |
| 1440 | le16_to_cpu(lvds_info->info.sLCDTiming.usHBlanking_Time); |
| 1441 | lvds->native_mode.hsync_start = lvds->native_mode.hdisplay + |
| 1442 | le16_to_cpu(lvds_info->info.sLCDTiming.usHSyncOffset); |
| 1443 | lvds->native_mode.hsync_end = lvds->native_mode.hsync_start + |
| 1444 | le16_to_cpu(lvds_info->info.sLCDTiming.usHSyncWidth); |
| 1445 | lvds->native_mode.vtotal = lvds->native_mode.vdisplay + |
| 1446 | le16_to_cpu(lvds_info->info.sLCDTiming.usVBlanking_Time); |
| 1447 | lvds->native_mode.vsync_start = lvds->native_mode.vdisplay + |
Alex Deucher | 1ff26a3 | 2010-05-18 00:23:15 -0400 | [diff] [blame] | 1448 | le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncOffset); |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1449 | lvds->native_mode.vsync_end = lvds->native_mode.vsync_start + |
| 1450 | le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncWidth); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1451 | lvds->panel_pwr_delay = |
| 1452 | le16_to_cpu(lvds_info->info.usOffDelayInMs); |
Alex Deucher | ba032a5 | 2010-10-04 17:13:01 -0400 | [diff] [blame] | 1453 | lvds->lcd_misc = lvds_info->info.ucLVDS_Misc; |
Alex Deucher | 7dde8a19 | 2009-11-30 01:40:24 -0500 | [diff] [blame] | 1454 | |
| 1455 | misc = le16_to_cpu(lvds_info->info.sLCDTiming.susModeMiscInfo.usAccess); |
| 1456 | if (misc & ATOM_VSYNC_POLARITY) |
| 1457 | lvds->native_mode.flags |= DRM_MODE_FLAG_NVSYNC; |
| 1458 | if (misc & ATOM_HSYNC_POLARITY) |
| 1459 | lvds->native_mode.flags |= DRM_MODE_FLAG_NHSYNC; |
| 1460 | if (misc & ATOM_COMPOSITESYNC) |
| 1461 | lvds->native_mode.flags |= DRM_MODE_FLAG_CSYNC; |
| 1462 | if (misc & ATOM_INTERLACE) |
| 1463 | lvds->native_mode.flags |= DRM_MODE_FLAG_INTERLACE; |
| 1464 | if (misc & ATOM_DOUBLE_CLOCK_MODE) |
| 1465 | lvds->native_mode.flags |= DRM_MODE_FLAG_DBLSCAN; |
| 1466 | |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 1467 | /* set crtc values */ |
| 1468 | drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1469 | |
Alex Deucher | ba032a5 | 2010-10-04 17:13:01 -0400 | [diff] [blame] | 1470 | lvds->lcd_ss_id = lvds_info->info.ucSS_Id; |
Alex Deucher | ebbe1cb | 2009-10-16 11:15:25 -0400 | [diff] [blame] | 1471 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1472 | encoder->native_mode = lvds->native_mode; |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 1473 | |
| 1474 | if (encoder_enum == 2) |
| 1475 | lvds->linkb = true; |
| 1476 | else |
| 1477 | lvds->linkb = false; |
| 1478 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1479 | } |
| 1480 | return lvds; |
| 1481 | } |
| 1482 | |
Alex Deucher | 6fe7ac3 | 2009-06-12 17:26:08 +0000 | [diff] [blame] | 1483 | struct radeon_encoder_primary_dac * |
| 1484 | radeon_atombios_get_primary_dac_info(struct radeon_encoder *encoder) |
| 1485 | { |
| 1486 | struct drm_device *dev = encoder->base.dev; |
| 1487 | struct radeon_device *rdev = dev->dev_private; |
| 1488 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
| 1489 | int index = GetIndexIntoMasterTable(DATA, CompassionateData); |
| 1490 | uint16_t data_offset; |
| 1491 | struct _COMPASSIONATE_DATA *dac_info; |
| 1492 | uint8_t frev, crev; |
| 1493 | uint8_t bg, dac; |
Alex Deucher | 6fe7ac3 | 2009-06-12 17:26:08 +0000 | [diff] [blame] | 1494 | struct radeon_encoder_primary_dac *p_dac = NULL; |
| 1495 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1496 | if (atom_parse_data_header(mode_info->atom_context, index, NULL, |
| 1497 | &frev, &crev, &data_offset)) { |
| 1498 | dac_info = (struct _COMPASSIONATE_DATA *) |
| 1499 | (mode_info->atom_context->bios + data_offset); |
Alex Deucher | 6fe7ac3 | 2009-06-12 17:26:08 +0000 | [diff] [blame] | 1500 | |
Alex Deucher | 6fe7ac3 | 2009-06-12 17:26:08 +0000 | [diff] [blame] | 1501 | p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), GFP_KERNEL); |
| 1502 | |
| 1503 | if (!p_dac) |
| 1504 | return NULL; |
| 1505 | |
| 1506 | bg = dac_info->ucDAC1_BG_Adjustment; |
| 1507 | dac = dac_info->ucDAC1_DAC_Adjustment; |
| 1508 | p_dac->ps2_pdac_adj = (bg << 8) | (dac); |
| 1509 | |
| 1510 | } |
| 1511 | return p_dac; |
| 1512 | } |
| 1513 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1514 | bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index, |
Alex Deucher | 5a9bcac | 2009-10-08 15:09:31 -0400 | [diff] [blame] | 1515 | struct drm_display_mode *mode) |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1516 | { |
| 1517 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
| 1518 | ATOM_ANALOG_TV_INFO *tv_info; |
| 1519 | ATOM_ANALOG_TV_INFO_V1_2 *tv_info_v1_2; |
| 1520 | ATOM_DTD_FORMAT *dtd_timings; |
| 1521 | int data_index = GetIndexIntoMasterTable(DATA, AnalogTV_Info); |
| 1522 | u8 frev, crev; |
Alex Deucher | 5a9bcac | 2009-10-08 15:09:31 -0400 | [diff] [blame] | 1523 | u16 data_offset, misc; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1524 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1525 | if (!atom_parse_data_header(mode_info->atom_context, data_index, NULL, |
| 1526 | &frev, &crev, &data_offset)) |
| 1527 | return false; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1528 | |
| 1529 | switch (crev) { |
| 1530 | case 1: |
| 1531 | tv_info = (ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset); |
Dan Carpenter | 0031c41 | 2010-04-27 14:11:04 -0700 | [diff] [blame] | 1532 | if (index >= MAX_SUPPORTED_TV_TIMING) |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1533 | return false; |
| 1534 | |
Alex Deucher | 5a9bcac | 2009-10-08 15:09:31 -0400 | [diff] [blame] | 1535 | mode->crtc_htotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Total); |
| 1536 | mode->crtc_hdisplay = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Disp); |
| 1537 | mode->crtc_hsync_start = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncStart); |
| 1538 | mode->crtc_hsync_end = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncStart) + |
| 1539 | le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncWidth); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1540 | |
Alex Deucher | 5a9bcac | 2009-10-08 15:09:31 -0400 | [diff] [blame] | 1541 | mode->crtc_vtotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_Total); |
| 1542 | mode->crtc_vdisplay = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_Disp); |
| 1543 | mode->crtc_vsync_start = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncStart); |
| 1544 | mode->crtc_vsync_end = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncStart) + |
| 1545 | le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncWidth); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1546 | |
Alex Deucher | 5a9bcac | 2009-10-08 15:09:31 -0400 | [diff] [blame] | 1547 | mode->flags = 0; |
| 1548 | misc = le16_to_cpu(tv_info->aModeTimings[index].susModeMiscInfo.usAccess); |
| 1549 | if (misc & ATOM_VSYNC_POLARITY) |
| 1550 | mode->flags |= DRM_MODE_FLAG_NVSYNC; |
| 1551 | if (misc & ATOM_HSYNC_POLARITY) |
| 1552 | mode->flags |= DRM_MODE_FLAG_NHSYNC; |
| 1553 | if (misc & ATOM_COMPOSITESYNC) |
| 1554 | mode->flags |= DRM_MODE_FLAG_CSYNC; |
| 1555 | if (misc & ATOM_INTERLACE) |
| 1556 | mode->flags |= DRM_MODE_FLAG_INTERLACE; |
| 1557 | if (misc & ATOM_DOUBLE_CLOCK_MODE) |
| 1558 | mode->flags |= DRM_MODE_FLAG_DBLSCAN; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1559 | |
Alex Deucher | 5a9bcac | 2009-10-08 15:09:31 -0400 | [diff] [blame] | 1560 | mode->clock = le16_to_cpu(tv_info->aModeTimings[index].usPixelClock) * 10; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1561 | |
| 1562 | if (index == 1) { |
| 1563 | /* PAL timings appear to have wrong values for totals */ |
Alex Deucher | 5a9bcac | 2009-10-08 15:09:31 -0400 | [diff] [blame] | 1564 | mode->crtc_htotal -= 1; |
| 1565 | mode->crtc_vtotal -= 1; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1566 | } |
| 1567 | break; |
| 1568 | case 2: |
| 1569 | tv_info_v1_2 = (ATOM_ANALOG_TV_INFO_V1_2 *)(mode_info->atom_context->bios + data_offset); |
Dan Carpenter | 0031c41 | 2010-04-27 14:11:04 -0700 | [diff] [blame] | 1570 | if (index >= MAX_SUPPORTED_TV_TIMING_V1_2) |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1571 | return false; |
| 1572 | |
| 1573 | dtd_timings = &tv_info_v1_2->aModeTimings[index]; |
Alex Deucher | 5a9bcac | 2009-10-08 15:09:31 -0400 | [diff] [blame] | 1574 | mode->crtc_htotal = le16_to_cpu(dtd_timings->usHActive) + |
| 1575 | le16_to_cpu(dtd_timings->usHBlanking_Time); |
| 1576 | mode->crtc_hdisplay = le16_to_cpu(dtd_timings->usHActive); |
| 1577 | mode->crtc_hsync_start = le16_to_cpu(dtd_timings->usHActive) + |
| 1578 | le16_to_cpu(dtd_timings->usHSyncOffset); |
| 1579 | mode->crtc_hsync_end = mode->crtc_hsync_start + |
| 1580 | le16_to_cpu(dtd_timings->usHSyncWidth); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1581 | |
Alex Deucher | 5a9bcac | 2009-10-08 15:09:31 -0400 | [diff] [blame] | 1582 | mode->crtc_vtotal = le16_to_cpu(dtd_timings->usVActive) + |
| 1583 | le16_to_cpu(dtd_timings->usVBlanking_Time); |
| 1584 | mode->crtc_vdisplay = le16_to_cpu(dtd_timings->usVActive); |
| 1585 | mode->crtc_vsync_start = le16_to_cpu(dtd_timings->usVActive) + |
| 1586 | le16_to_cpu(dtd_timings->usVSyncOffset); |
| 1587 | mode->crtc_vsync_end = mode->crtc_vsync_start + |
| 1588 | le16_to_cpu(dtd_timings->usVSyncWidth); |
| 1589 | |
| 1590 | mode->flags = 0; |
| 1591 | misc = le16_to_cpu(dtd_timings->susModeMiscInfo.usAccess); |
| 1592 | if (misc & ATOM_VSYNC_POLARITY) |
| 1593 | mode->flags |= DRM_MODE_FLAG_NVSYNC; |
| 1594 | if (misc & ATOM_HSYNC_POLARITY) |
| 1595 | mode->flags |= DRM_MODE_FLAG_NHSYNC; |
| 1596 | if (misc & ATOM_COMPOSITESYNC) |
| 1597 | mode->flags |= DRM_MODE_FLAG_CSYNC; |
| 1598 | if (misc & ATOM_INTERLACE) |
| 1599 | mode->flags |= DRM_MODE_FLAG_INTERLACE; |
| 1600 | if (misc & ATOM_DOUBLE_CLOCK_MODE) |
| 1601 | mode->flags |= DRM_MODE_FLAG_DBLSCAN; |
| 1602 | |
| 1603 | mode->clock = le16_to_cpu(dtd_timings->usPixClk) * 10; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1604 | break; |
| 1605 | } |
| 1606 | return true; |
| 1607 | } |
| 1608 | |
Alex Deucher | d79766f | 2009-12-17 19:00:29 -0500 | [diff] [blame] | 1609 | enum radeon_tv_std |
| 1610 | radeon_atombios_get_tv_info(struct radeon_device *rdev) |
| 1611 | { |
| 1612 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
| 1613 | int index = GetIndexIntoMasterTable(DATA, AnalogTV_Info); |
| 1614 | uint16_t data_offset; |
| 1615 | uint8_t frev, crev; |
| 1616 | struct _ATOM_ANALOG_TV_INFO *tv_info; |
| 1617 | enum radeon_tv_std tv_std = TV_STD_NTSC; |
| 1618 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1619 | if (atom_parse_data_header(mode_info->atom_context, index, NULL, |
| 1620 | &frev, &crev, &data_offset)) { |
Alex Deucher | d79766f | 2009-12-17 19:00:29 -0500 | [diff] [blame] | 1621 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1622 | tv_info = (struct _ATOM_ANALOG_TV_INFO *) |
| 1623 | (mode_info->atom_context->bios + data_offset); |
Alex Deucher | d79766f | 2009-12-17 19:00:29 -0500 | [diff] [blame] | 1624 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1625 | switch (tv_info->ucTV_BootUpDefaultStandard) { |
| 1626 | case ATOM_TV_NTSC: |
| 1627 | tv_std = TV_STD_NTSC; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 1628 | DRM_DEBUG_KMS("Default TV standard: NTSC\n"); |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1629 | break; |
| 1630 | case ATOM_TV_NTSCJ: |
| 1631 | tv_std = TV_STD_NTSC_J; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 1632 | DRM_DEBUG_KMS("Default TV standard: NTSC-J\n"); |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1633 | break; |
| 1634 | case ATOM_TV_PAL: |
| 1635 | tv_std = TV_STD_PAL; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 1636 | DRM_DEBUG_KMS("Default TV standard: PAL\n"); |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1637 | break; |
| 1638 | case ATOM_TV_PALM: |
| 1639 | tv_std = TV_STD_PAL_M; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 1640 | DRM_DEBUG_KMS("Default TV standard: PAL-M\n"); |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1641 | break; |
| 1642 | case ATOM_TV_PALN: |
| 1643 | tv_std = TV_STD_PAL_N; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 1644 | DRM_DEBUG_KMS("Default TV standard: PAL-N\n"); |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1645 | break; |
| 1646 | case ATOM_TV_PALCN: |
| 1647 | tv_std = TV_STD_PAL_CN; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 1648 | DRM_DEBUG_KMS("Default TV standard: PAL-CN\n"); |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1649 | break; |
| 1650 | case ATOM_TV_PAL60: |
| 1651 | tv_std = TV_STD_PAL_60; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 1652 | DRM_DEBUG_KMS("Default TV standard: PAL-60\n"); |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1653 | break; |
| 1654 | case ATOM_TV_SECAM: |
| 1655 | tv_std = TV_STD_SECAM; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 1656 | DRM_DEBUG_KMS("Default TV standard: SECAM\n"); |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1657 | break; |
| 1658 | default: |
| 1659 | tv_std = TV_STD_NTSC; |
Alex Deucher | 40f76d8 | 2010-10-07 22:38:42 -0400 | [diff] [blame] | 1660 | DRM_DEBUG_KMS("Unknown TV standard; defaulting to NTSC\n"); |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1661 | break; |
| 1662 | } |
Alex Deucher | d79766f | 2009-12-17 19:00:29 -0500 | [diff] [blame] | 1663 | } |
| 1664 | return tv_std; |
| 1665 | } |
| 1666 | |
Alex Deucher | 6fe7ac3 | 2009-06-12 17:26:08 +0000 | [diff] [blame] | 1667 | struct radeon_encoder_tv_dac * |
| 1668 | radeon_atombios_get_tv_dac_info(struct radeon_encoder *encoder) |
| 1669 | { |
| 1670 | struct drm_device *dev = encoder->base.dev; |
| 1671 | struct radeon_device *rdev = dev->dev_private; |
| 1672 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
| 1673 | int index = GetIndexIntoMasterTable(DATA, CompassionateData); |
| 1674 | uint16_t data_offset; |
| 1675 | struct _COMPASSIONATE_DATA *dac_info; |
| 1676 | uint8_t frev, crev; |
| 1677 | uint8_t bg, dac; |
Alex Deucher | 6fe7ac3 | 2009-06-12 17:26:08 +0000 | [diff] [blame] | 1678 | struct radeon_encoder_tv_dac *tv_dac = NULL; |
| 1679 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1680 | if (atom_parse_data_header(mode_info->atom_context, index, NULL, |
| 1681 | &frev, &crev, &data_offset)) { |
Alex Deucher | 6fe7ac3 | 2009-06-12 17:26:08 +0000 | [diff] [blame] | 1682 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1683 | dac_info = (struct _COMPASSIONATE_DATA *) |
| 1684 | (mode_info->atom_context->bios + data_offset); |
Alex Deucher | 6fe7ac3 | 2009-06-12 17:26:08 +0000 | [diff] [blame] | 1685 | |
Alex Deucher | 6fe7ac3 | 2009-06-12 17:26:08 +0000 | [diff] [blame] | 1686 | tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); |
| 1687 | |
| 1688 | if (!tv_dac) |
| 1689 | return NULL; |
| 1690 | |
| 1691 | bg = dac_info->ucDAC2_CRT2_BG_Adjustment; |
| 1692 | dac = dac_info->ucDAC2_CRT2_DAC_Adjustment; |
| 1693 | tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); |
| 1694 | |
| 1695 | bg = dac_info->ucDAC2_PAL_BG_Adjustment; |
| 1696 | dac = dac_info->ucDAC2_PAL_DAC_Adjustment; |
| 1697 | tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); |
| 1698 | |
| 1699 | bg = dac_info->ucDAC2_NTSC_BG_Adjustment; |
| 1700 | dac = dac_info->ucDAC2_NTSC_DAC_Adjustment; |
| 1701 | tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); |
| 1702 | |
Alex Deucher | d79766f | 2009-12-17 19:00:29 -0500 | [diff] [blame] | 1703 | tv_dac->tv_std = radeon_atombios_get_tv_info(rdev); |
Alex Deucher | 6fe7ac3 | 2009-06-12 17:26:08 +0000 | [diff] [blame] | 1704 | } |
| 1705 | return tv_dac; |
| 1706 | } |
| 1707 | |
Alex Deucher | 29fb52c | 2010-03-11 10:01:17 -0500 | [diff] [blame] | 1708 | static const char *thermal_controller_names[] = { |
| 1709 | "NONE", |
Alex Deucher | 678e7dfa | 2010-04-22 14:17:56 -0400 | [diff] [blame] | 1710 | "lm63", |
| 1711 | "adm1032", |
| 1712 | "adm1030", |
| 1713 | "max6649", |
| 1714 | "lm64", |
| 1715 | "f75375", |
| 1716 | "asc7xxx", |
Alex Deucher | 29fb52c | 2010-03-11 10:01:17 -0500 | [diff] [blame] | 1717 | }; |
| 1718 | |
| 1719 | static const char *pp_lib_thermal_controller_names[] = { |
| 1720 | "NONE", |
Alex Deucher | 678e7dfa | 2010-04-22 14:17:56 -0400 | [diff] [blame] | 1721 | "lm63", |
| 1722 | "adm1032", |
| 1723 | "adm1030", |
| 1724 | "max6649", |
| 1725 | "lm64", |
| 1726 | "f75375", |
Alex Deucher | 29fb52c | 2010-03-11 10:01:17 -0500 | [diff] [blame] | 1727 | "RV6xx", |
| 1728 | "RV770", |
Alex Deucher | 678e7dfa | 2010-04-22 14:17:56 -0400 | [diff] [blame] | 1729 | "adt7473", |
Alex Deucher | 49f6598 | 2010-03-24 16:39:45 -0400 | [diff] [blame] | 1730 | "External GPIO", |
| 1731 | "Evergreen", |
Alex Deucher | 678e7dfa | 2010-04-22 14:17:56 -0400 | [diff] [blame] | 1732 | "adt7473 with internal", |
Alex Deucher | 49f6598 | 2010-03-24 16:39:45 -0400 | [diff] [blame] | 1733 | |
Alex Deucher | 29fb52c | 2010-03-11 10:01:17 -0500 | [diff] [blame] | 1734 | }; |
| 1735 | |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1736 | union power_info { |
| 1737 | struct _ATOM_POWERPLAY_INFO info; |
| 1738 | struct _ATOM_POWERPLAY_INFO_V2 info_2; |
| 1739 | struct _ATOM_POWERPLAY_INFO_V3 info_3; |
| 1740 | struct _ATOM_PPLIB_POWERPLAYTABLE info_4; |
| 1741 | }; |
| 1742 | |
| 1743 | void radeon_atombios_get_power_modes(struct radeon_device *rdev) |
| 1744 | { |
| 1745 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
| 1746 | int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo); |
| 1747 | u16 data_offset; |
| 1748 | u8 frev, crev; |
| 1749 | u32 misc, misc2 = 0, sclk, mclk; |
| 1750 | union power_info *power_info; |
| 1751 | struct _ATOM_PPLIB_NONCLOCK_INFO *non_clock_info; |
| 1752 | struct _ATOM_PPLIB_STATE *power_state; |
| 1753 | int num_modes = 0, i, j; |
| 1754 | int state_index = 0, mode_index = 0; |
Alex Deucher | 29fb52c | 2010-03-11 10:01:17 -0500 | [diff] [blame] | 1755 | struct radeon_i2c_bus_rec i2c_bus; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1756 | |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1757 | rdev->pm.default_power_state_index = -1; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1758 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame] | 1759 | if (atom_parse_data_header(mode_info->atom_context, index, NULL, |
| 1760 | &frev, &crev, &data_offset)) { |
| 1761 | power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1762 | if (frev < 4) { |
Alex Deucher | 29fb52c | 2010-03-11 10:01:17 -0500 | [diff] [blame] | 1763 | /* add the i2c bus for thermal/fan chip */ |
| 1764 | if (power_info->info.ucOverdriveThermalController > 0) { |
| 1765 | DRM_INFO("Possible %s thermal controller at 0x%02x\n", |
| 1766 | thermal_controller_names[power_info->info.ucOverdriveThermalController], |
| 1767 | power_info->info.ucOverdriveControllerAddress >> 1); |
| 1768 | i2c_bus = radeon_lookup_i2c_gpio(rdev, power_info->info.ucOverdriveI2cLine); |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 1769 | rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); |
Alex Deucher | 678e7dfa | 2010-04-22 14:17:56 -0400 | [diff] [blame] | 1770 | if (rdev->pm.i2c_bus) { |
| 1771 | struct i2c_board_info info = { }; |
| 1772 | const char *name = thermal_controller_names[power_info->info. |
| 1773 | ucOverdriveThermalController]; |
| 1774 | info.addr = power_info->info.ucOverdriveControllerAddress >> 1; |
| 1775 | strlcpy(info.type, name, sizeof(info.type)); |
| 1776 | i2c_new_device(&rdev->pm.i2c_bus->adapter, &info); |
| 1777 | } |
Alex Deucher | 29fb52c | 2010-03-11 10:01:17 -0500 | [diff] [blame] | 1778 | } |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1779 | num_modes = power_info->info.ucNumOfPowerModeEntries; |
| 1780 | if (num_modes > ATOM_MAX_NUMBEROF_POWER_BLOCK) |
| 1781 | num_modes = ATOM_MAX_NUMBEROF_POWER_BLOCK; |
Alex Deucher | 02b17cc | 2010-04-22 13:25:06 -0400 | [diff] [blame] | 1782 | /* last mode is usually default, array is low to high */ |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1783 | for (i = 0; i < num_modes; i++) { |
| 1784 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; |
| 1785 | switch (frev) { |
| 1786 | case 1: |
| 1787 | rdev->pm.power_state[state_index].num_clock_modes = 1; |
| 1788 | rdev->pm.power_state[state_index].clock_info[0].mclk = |
| 1789 | le16_to_cpu(power_info->info.asPowerPlayInfo[i].usMemoryClock); |
| 1790 | rdev->pm.power_state[state_index].clock_info[0].sclk = |
| 1791 | le16_to_cpu(power_info->info.asPowerPlayInfo[i].usEngineClock); |
| 1792 | /* skip invalid modes */ |
| 1793 | if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) || |
| 1794 | (rdev->pm.power_state[state_index].clock_info[0].sclk == 0)) |
| 1795 | continue; |
Alex Deucher | 79daedc | 2010-04-22 14:25:19 -0400 | [diff] [blame] | 1796 | rdev->pm.power_state[state_index].pcie_lanes = |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1797 | power_info->info.asPowerPlayInfo[i].ucNumPciELanes; |
| 1798 | misc = le32_to_cpu(power_info->info.asPowerPlayInfo[i].ulMiscInfo); |
Alex Deucher | 84d88f4 | 2010-05-27 17:01:42 -0400 | [diff] [blame] | 1799 | if ((misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT) || |
| 1800 | (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH)) { |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1801 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = |
| 1802 | VOLTAGE_GPIO; |
| 1803 | rdev->pm.power_state[state_index].clock_info[0].voltage.gpio = |
| 1804 | radeon_lookup_gpio(rdev, |
| 1805 | power_info->info.asPowerPlayInfo[i].ucVoltageDropIndex); |
| 1806 | if (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH) |
| 1807 | rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = |
| 1808 | true; |
| 1809 | else |
| 1810 | rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = |
| 1811 | false; |
| 1812 | } else if (misc & ATOM_PM_MISCINFO_PROGRAM_VOLTAGE) { |
| 1813 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = |
| 1814 | VOLTAGE_VDDC; |
| 1815 | rdev->pm.power_state[state_index].clock_info[0].voltage.vddc_id = |
| 1816 | power_info->info.asPowerPlayInfo[i].ucVoltageDropIndex; |
| 1817 | } |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 1818 | rdev->pm.power_state[state_index].flags = RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; |
Alex Deucher | 79daedc | 2010-04-22 14:25:19 -0400 | [diff] [blame] | 1819 | rdev->pm.power_state[state_index].misc = misc; |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 1820 | /* order matters! */ |
| 1821 | if (misc & ATOM_PM_MISCINFO_POWER_SAVING_MODE) |
| 1822 | rdev->pm.power_state[state_index].type = |
| 1823 | POWER_STATE_TYPE_POWERSAVE; |
| 1824 | if (misc & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE) |
| 1825 | rdev->pm.power_state[state_index].type = |
| 1826 | POWER_STATE_TYPE_BATTERY; |
| 1827 | if (misc & ATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE) |
| 1828 | rdev->pm.power_state[state_index].type = |
| 1829 | POWER_STATE_TYPE_BATTERY; |
| 1830 | if (misc & ATOM_PM_MISCINFO_LOAD_BALANCE_EN) |
| 1831 | rdev->pm.power_state[state_index].type = |
| 1832 | POWER_STATE_TYPE_BALANCED; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1833 | if (misc & ATOM_PM_MISCINFO_3D_ACCELERATION_EN) { |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 1834 | rdev->pm.power_state[state_index].type = |
| 1835 | POWER_STATE_TYPE_PERFORMANCE; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1836 | rdev->pm.power_state[state_index].flags &= |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 1837 | ~RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1838 | } |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1839 | if (misc & ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE) { |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 1840 | rdev->pm.power_state[state_index].type = |
| 1841 | POWER_STATE_TYPE_DEFAULT; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1842 | rdev->pm.default_power_state_index = state_index; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1843 | rdev->pm.power_state[state_index].default_clock_mode = |
| 1844 | &rdev->pm.power_state[state_index].clock_info[0]; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1845 | rdev->pm.power_state[state_index].flags &= |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 1846 | ~RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; |
| 1847 | } else if (state_index == 0) { |
| 1848 | rdev->pm.power_state[state_index].clock_info[0].flags |= |
| 1849 | RADEON_PM_MODE_NO_DISPLAY; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1850 | } |
| 1851 | state_index++; |
| 1852 | break; |
| 1853 | case 2: |
| 1854 | rdev->pm.power_state[state_index].num_clock_modes = 1; |
| 1855 | rdev->pm.power_state[state_index].clock_info[0].mclk = |
| 1856 | le32_to_cpu(power_info->info_2.asPowerPlayInfo[i].ulMemoryClock); |
| 1857 | rdev->pm.power_state[state_index].clock_info[0].sclk = |
| 1858 | le32_to_cpu(power_info->info_2.asPowerPlayInfo[i].ulEngineClock); |
| 1859 | /* skip invalid modes */ |
| 1860 | if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) || |
| 1861 | (rdev->pm.power_state[state_index].clock_info[0].sclk == 0)) |
| 1862 | continue; |
Alex Deucher | 79daedc | 2010-04-22 14:25:19 -0400 | [diff] [blame] | 1863 | rdev->pm.power_state[state_index].pcie_lanes = |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1864 | power_info->info_2.asPowerPlayInfo[i].ucNumPciELanes; |
| 1865 | misc = le32_to_cpu(power_info->info_2.asPowerPlayInfo[i].ulMiscInfo); |
| 1866 | misc2 = le32_to_cpu(power_info->info_2.asPowerPlayInfo[i].ulMiscInfo2); |
Alex Deucher | 84d88f4 | 2010-05-27 17:01:42 -0400 | [diff] [blame] | 1867 | if ((misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT) || |
| 1868 | (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH)) { |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1869 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = |
| 1870 | VOLTAGE_GPIO; |
| 1871 | rdev->pm.power_state[state_index].clock_info[0].voltage.gpio = |
| 1872 | radeon_lookup_gpio(rdev, |
| 1873 | power_info->info_2.asPowerPlayInfo[i].ucVoltageDropIndex); |
| 1874 | if (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH) |
| 1875 | rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = |
| 1876 | true; |
| 1877 | else |
| 1878 | rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = |
| 1879 | false; |
| 1880 | } else if (misc & ATOM_PM_MISCINFO_PROGRAM_VOLTAGE) { |
| 1881 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = |
| 1882 | VOLTAGE_VDDC; |
| 1883 | rdev->pm.power_state[state_index].clock_info[0].voltage.vddc_id = |
| 1884 | power_info->info_2.asPowerPlayInfo[i].ucVoltageDropIndex; |
| 1885 | } |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 1886 | rdev->pm.power_state[state_index].flags = RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; |
Alex Deucher | 79daedc | 2010-04-22 14:25:19 -0400 | [diff] [blame] | 1887 | rdev->pm.power_state[state_index].misc = misc; |
| 1888 | rdev->pm.power_state[state_index].misc2 = misc2; |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 1889 | /* order matters! */ |
| 1890 | if (misc & ATOM_PM_MISCINFO_POWER_SAVING_MODE) |
| 1891 | rdev->pm.power_state[state_index].type = |
| 1892 | POWER_STATE_TYPE_POWERSAVE; |
| 1893 | if (misc & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE) |
| 1894 | rdev->pm.power_state[state_index].type = |
| 1895 | POWER_STATE_TYPE_BATTERY; |
| 1896 | if (misc & ATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE) |
| 1897 | rdev->pm.power_state[state_index].type = |
| 1898 | POWER_STATE_TYPE_BATTERY; |
| 1899 | if (misc & ATOM_PM_MISCINFO_LOAD_BALANCE_EN) |
| 1900 | rdev->pm.power_state[state_index].type = |
| 1901 | POWER_STATE_TYPE_BALANCED; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1902 | if (misc & ATOM_PM_MISCINFO_3D_ACCELERATION_EN) { |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 1903 | rdev->pm.power_state[state_index].type = |
| 1904 | POWER_STATE_TYPE_PERFORMANCE; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1905 | rdev->pm.power_state[state_index].flags &= |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 1906 | ~RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1907 | } |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 1908 | if (misc2 & ATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE) |
| 1909 | rdev->pm.power_state[state_index].type = |
| 1910 | POWER_STATE_TYPE_BALANCED; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1911 | if (misc2 & ATOM_PM_MISCINFO2_MULTI_DISPLAY_SUPPORT) |
| 1912 | rdev->pm.power_state[state_index].flags &= |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 1913 | ~RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1914 | if (misc & ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE) { |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 1915 | rdev->pm.power_state[state_index].type = |
| 1916 | POWER_STATE_TYPE_DEFAULT; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1917 | rdev->pm.default_power_state_index = state_index; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1918 | rdev->pm.power_state[state_index].default_clock_mode = |
| 1919 | &rdev->pm.power_state[state_index].clock_info[0]; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1920 | rdev->pm.power_state[state_index].flags &= |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 1921 | ~RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; |
| 1922 | } else if (state_index == 0) { |
| 1923 | rdev->pm.power_state[state_index].clock_info[0].flags |= |
| 1924 | RADEON_PM_MODE_NO_DISPLAY; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1925 | } |
| 1926 | state_index++; |
| 1927 | break; |
| 1928 | case 3: |
| 1929 | rdev->pm.power_state[state_index].num_clock_modes = 1; |
| 1930 | rdev->pm.power_state[state_index].clock_info[0].mclk = |
| 1931 | le32_to_cpu(power_info->info_3.asPowerPlayInfo[i].ulMemoryClock); |
| 1932 | rdev->pm.power_state[state_index].clock_info[0].sclk = |
| 1933 | le32_to_cpu(power_info->info_3.asPowerPlayInfo[i].ulEngineClock); |
| 1934 | /* skip invalid modes */ |
| 1935 | if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) || |
| 1936 | (rdev->pm.power_state[state_index].clock_info[0].sclk == 0)) |
| 1937 | continue; |
Alex Deucher | 79daedc | 2010-04-22 14:25:19 -0400 | [diff] [blame] | 1938 | rdev->pm.power_state[state_index].pcie_lanes = |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1939 | power_info->info_3.asPowerPlayInfo[i].ucNumPciELanes; |
| 1940 | misc = le32_to_cpu(power_info->info_3.asPowerPlayInfo[i].ulMiscInfo); |
| 1941 | misc2 = le32_to_cpu(power_info->info_3.asPowerPlayInfo[i].ulMiscInfo2); |
Alex Deucher | 84d88f4 | 2010-05-27 17:01:42 -0400 | [diff] [blame] | 1942 | if ((misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT) || |
| 1943 | (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH)) { |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1944 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = |
| 1945 | VOLTAGE_GPIO; |
| 1946 | rdev->pm.power_state[state_index].clock_info[0].voltage.gpio = |
| 1947 | radeon_lookup_gpio(rdev, |
| 1948 | power_info->info_3.asPowerPlayInfo[i].ucVoltageDropIndex); |
| 1949 | if (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH) |
| 1950 | rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = |
| 1951 | true; |
| 1952 | else |
| 1953 | rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = |
| 1954 | false; |
| 1955 | } else if (misc & ATOM_PM_MISCINFO_PROGRAM_VOLTAGE) { |
| 1956 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = |
| 1957 | VOLTAGE_VDDC; |
| 1958 | rdev->pm.power_state[state_index].clock_info[0].voltage.vddc_id = |
| 1959 | power_info->info_3.asPowerPlayInfo[i].ucVoltageDropIndex; |
| 1960 | if (misc2 & ATOM_PM_MISCINFO2_VDDCI_DYNAMIC_VOLTAGE_EN) { |
| 1961 | rdev->pm.power_state[state_index].clock_info[0].voltage.vddci_enabled = |
| 1962 | true; |
| 1963 | rdev->pm.power_state[state_index].clock_info[0].voltage.vddci_id = |
| 1964 | power_info->info_3.asPowerPlayInfo[i].ucVDDCI_VoltageDropIndex; |
| 1965 | } |
| 1966 | } |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 1967 | rdev->pm.power_state[state_index].flags = RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; |
Alex Deucher | 79daedc | 2010-04-22 14:25:19 -0400 | [diff] [blame] | 1968 | rdev->pm.power_state[state_index].misc = misc; |
| 1969 | rdev->pm.power_state[state_index].misc2 = misc2; |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 1970 | /* order matters! */ |
| 1971 | if (misc & ATOM_PM_MISCINFO_POWER_SAVING_MODE) |
| 1972 | rdev->pm.power_state[state_index].type = |
| 1973 | POWER_STATE_TYPE_POWERSAVE; |
| 1974 | if (misc & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE) |
| 1975 | rdev->pm.power_state[state_index].type = |
| 1976 | POWER_STATE_TYPE_BATTERY; |
| 1977 | if (misc & ATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE) |
| 1978 | rdev->pm.power_state[state_index].type = |
| 1979 | POWER_STATE_TYPE_BATTERY; |
| 1980 | if (misc & ATOM_PM_MISCINFO_LOAD_BALANCE_EN) |
| 1981 | rdev->pm.power_state[state_index].type = |
| 1982 | POWER_STATE_TYPE_BALANCED; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1983 | if (misc & ATOM_PM_MISCINFO_3D_ACCELERATION_EN) { |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 1984 | rdev->pm.power_state[state_index].type = |
| 1985 | POWER_STATE_TYPE_PERFORMANCE; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1986 | rdev->pm.power_state[state_index].flags &= |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 1987 | ~RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1988 | } |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 1989 | if (misc2 & ATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE) |
| 1990 | rdev->pm.power_state[state_index].type = |
| 1991 | POWER_STATE_TYPE_BALANCED; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1992 | if (misc & ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE) { |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 1993 | rdev->pm.power_state[state_index].type = |
| 1994 | POWER_STATE_TYPE_DEFAULT; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 1995 | rdev->pm.default_power_state_index = state_index; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 1996 | rdev->pm.power_state[state_index].default_clock_mode = |
| 1997 | &rdev->pm.power_state[state_index].clock_info[0]; |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 1998 | } else if (state_index == 0) { |
| 1999 | rdev->pm.power_state[state_index].clock_info[0].flags |= |
| 2000 | RADEON_PM_MODE_NO_DISPLAY; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2001 | } |
| 2002 | state_index++; |
| 2003 | break; |
| 2004 | } |
| 2005 | } |
Alex Deucher | 02b17cc | 2010-04-22 13:25:06 -0400 | [diff] [blame] | 2006 | /* last mode is usually default */ |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 2007 | if (rdev->pm.default_power_state_index == -1) { |
Alex Deucher | 02b17cc | 2010-04-22 13:25:06 -0400 | [diff] [blame] | 2008 | rdev->pm.power_state[state_index - 1].type = |
| 2009 | POWER_STATE_TYPE_DEFAULT; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 2010 | rdev->pm.default_power_state_index = state_index - 1; |
Alex Deucher | 02b17cc | 2010-04-22 13:25:06 -0400 | [diff] [blame] | 2011 | rdev->pm.power_state[state_index - 1].default_clock_mode = |
| 2012 | &rdev->pm.power_state[state_index - 1].clock_info[0]; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 2013 | rdev->pm.power_state[state_index].flags &= |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 2014 | ~RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; |
Alex Deucher | 79daedc | 2010-04-22 14:25:19 -0400 | [diff] [blame] | 2015 | rdev->pm.power_state[state_index].misc = 0; |
| 2016 | rdev->pm.power_state[state_index].misc2 = 0; |
Alex Deucher | 02b17cc | 2010-04-22 13:25:06 -0400 | [diff] [blame] | 2017 | } |
Alex Deucher | 49f6598 | 2010-03-24 16:39:45 -0400 | [diff] [blame] | 2018 | } else { |
Alex Deucher | c5e8ce6 | 2010-05-27 17:01:40 -0400 | [diff] [blame] | 2019 | int fw_index = GetIndexIntoMasterTable(DATA, FirmwareInfo); |
| 2020 | uint8_t fw_frev, fw_crev; |
| 2021 | uint16_t fw_data_offset, vddc = 0; |
| 2022 | union firmware_info *firmware_info; |
| 2023 | ATOM_PPLIB_THERMALCONTROLLER *controller = &power_info->info_4.sThermalController; |
| 2024 | |
| 2025 | if (atom_parse_data_header(mode_info->atom_context, fw_index, NULL, |
| 2026 | &fw_frev, &fw_crev, &fw_data_offset)) { |
| 2027 | firmware_info = |
| 2028 | (union firmware_info *)(mode_info->atom_context->bios + |
| 2029 | fw_data_offset); |
| 2030 | vddc = firmware_info->info_14.usBootUpVDDCVoltage; |
| 2031 | } |
| 2032 | |
Alex Deucher | 29fb52c | 2010-03-11 10:01:17 -0500 | [diff] [blame] | 2033 | /* add the i2c bus for thermal/fan chip */ |
Alex Deucher | 678e7dfa | 2010-04-22 14:17:56 -0400 | [diff] [blame] | 2034 | if (controller->ucType > 0) { |
Alex Deucher | 21a8122 | 2010-07-02 12:58:16 -0400 | [diff] [blame] | 2035 | if (controller->ucType == ATOM_PP_THERMALCONTROLLER_RV6xx) { |
Alex Deucher | 29fb52c | 2010-03-11 10:01:17 -0500 | [diff] [blame] | 2036 | DRM_INFO("Internal thermal controller %s fan control\n", |
Alex Deucher | 678e7dfa | 2010-04-22 14:17:56 -0400 | [diff] [blame] | 2037 | (controller->ucFanParameters & |
Alex Deucher | 29fb52c | 2010-03-11 10:01:17 -0500 | [diff] [blame] | 2038 | ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with"); |
Alex Deucher | 21a8122 | 2010-07-02 12:58:16 -0400 | [diff] [blame] | 2039 | rdev->pm.int_thermal_type = THERMAL_TYPE_RV6XX; |
| 2040 | } else if (controller->ucType == ATOM_PP_THERMALCONTROLLER_RV770) { |
| 2041 | DRM_INFO("Internal thermal controller %s fan control\n", |
| 2042 | (controller->ucFanParameters & |
| 2043 | ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with"); |
| 2044 | rdev->pm.int_thermal_type = THERMAL_TYPE_RV770; |
| 2045 | } else if (controller->ucType == ATOM_PP_THERMALCONTROLLER_EVERGREEN) { |
| 2046 | DRM_INFO("Internal thermal controller %s fan control\n", |
| 2047 | (controller->ucFanParameters & |
| 2048 | ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with"); |
| 2049 | rdev->pm.int_thermal_type = THERMAL_TYPE_EVERGREEN; |
Alex Deucher | 678e7dfa | 2010-04-22 14:17:56 -0400 | [diff] [blame] | 2050 | } else if ((controller->ucType == |
Alex Deucher | 49f6598 | 2010-03-24 16:39:45 -0400 | [diff] [blame] | 2051 | ATOM_PP_THERMALCONTROLLER_EXTERNAL_GPIO) || |
Alex Deucher | 678e7dfa | 2010-04-22 14:17:56 -0400 | [diff] [blame] | 2052 | (controller->ucType == |
Alex Deucher | 49f6598 | 2010-03-24 16:39:45 -0400 | [diff] [blame] | 2053 | ATOM_PP_THERMALCONTROLLER_ADT7473_WITH_INTERNAL)) { |
| 2054 | DRM_INFO("Special thermal controller config\n"); |
Alex Deucher | 29fb52c | 2010-03-11 10:01:17 -0500 | [diff] [blame] | 2055 | } else { |
| 2056 | DRM_INFO("Possible %s thermal controller at 0x%02x %s fan control\n", |
Alex Deucher | 678e7dfa | 2010-04-22 14:17:56 -0400 | [diff] [blame] | 2057 | pp_lib_thermal_controller_names[controller->ucType], |
| 2058 | controller->ucI2cAddress >> 1, |
| 2059 | (controller->ucFanParameters & |
Alex Deucher | 29fb52c | 2010-03-11 10:01:17 -0500 | [diff] [blame] | 2060 | ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with"); |
Alex Deucher | 678e7dfa | 2010-04-22 14:17:56 -0400 | [diff] [blame] | 2061 | i2c_bus = radeon_lookup_i2c_gpio(rdev, controller->ucI2cLine); |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 2062 | rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); |
Alex Deucher | 678e7dfa | 2010-04-22 14:17:56 -0400 | [diff] [blame] | 2063 | if (rdev->pm.i2c_bus) { |
| 2064 | struct i2c_board_info info = { }; |
| 2065 | const char *name = pp_lib_thermal_controller_names[controller->ucType]; |
| 2066 | info.addr = controller->ucI2cAddress >> 1; |
| 2067 | strlcpy(info.type, name, sizeof(info.type)); |
| 2068 | i2c_new_device(&rdev->pm.i2c_bus->adapter, &info); |
| 2069 | } |
| 2070 | |
Alex Deucher | 29fb52c | 2010-03-11 10:01:17 -0500 | [diff] [blame] | 2071 | } |
| 2072 | } |
Alex Deucher | 02b17cc | 2010-04-22 13:25:06 -0400 | [diff] [blame] | 2073 | /* first mode is usually default, followed by low to high */ |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2074 | for (i = 0; i < power_info->info_4.ucNumStates; i++) { |
| 2075 | mode_index = 0; |
| 2076 | power_state = (struct _ATOM_PPLIB_STATE *) |
| 2077 | (mode_info->atom_context->bios + |
| 2078 | data_offset + |
| 2079 | le16_to_cpu(power_info->info_4.usStateArrayOffset) + |
| 2080 | i * power_info->info_4.ucStateEntrySize); |
| 2081 | non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *) |
| 2082 | (mode_info->atom_context->bios + |
| 2083 | data_offset + |
| 2084 | le16_to_cpu(power_info->info_4.usNonClockInfoArrayOffset) + |
| 2085 | (power_state->ucNonClockStateIndex * |
| 2086 | power_info->info_4.ucNonClockSize)); |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2087 | for (j = 0; j < (power_info->info_4.ucStateEntrySize - 1); j++) { |
| 2088 | if (rdev->flags & RADEON_IS_IGP) { |
| 2089 | struct _ATOM_PPLIB_RS780_CLOCK_INFO *clock_info = |
| 2090 | (struct _ATOM_PPLIB_RS780_CLOCK_INFO *) |
| 2091 | (mode_info->atom_context->bios + |
| 2092 | data_offset + |
| 2093 | le16_to_cpu(power_info->info_4.usClockInfoArrayOffset) + |
| 2094 | (power_state->ucClockStateIndices[j] * |
| 2095 | power_info->info_4.ucClockInfoSize)); |
| 2096 | sclk = le16_to_cpu(clock_info->usLowEngineClockLow); |
| 2097 | sclk |= clock_info->ucLowEngineClockHigh << 16; |
| 2098 | rdev->pm.power_state[state_index].clock_info[mode_index].sclk = sclk; |
| 2099 | /* skip invalid modes */ |
| 2100 | if (rdev->pm.power_state[state_index].clock_info[mode_index].sclk == 0) |
| 2101 | continue; |
Alex Deucher | aa1df0f | 2010-06-07 11:35:53 -0400 | [diff] [blame] | 2102 | /* voltage works differently on IGPs */ |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2103 | mode_index++; |
Alex Deucher | 49f6598 | 2010-03-24 16:39:45 -0400 | [diff] [blame] | 2104 | } else if (ASIC_IS_DCE4(rdev)) { |
| 2105 | struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO *clock_info = |
| 2106 | (struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO *) |
| 2107 | (mode_info->atom_context->bios + |
| 2108 | data_offset + |
| 2109 | le16_to_cpu(power_info->info_4.usClockInfoArrayOffset) + |
| 2110 | (power_state->ucClockStateIndices[j] * |
| 2111 | power_info->info_4.ucClockInfoSize)); |
| 2112 | sclk = le16_to_cpu(clock_info->usEngineClockLow); |
| 2113 | sclk |= clock_info->ucEngineClockHigh << 16; |
| 2114 | mclk = le16_to_cpu(clock_info->usMemoryClockLow); |
| 2115 | mclk |= clock_info->ucMemoryClockHigh << 16; |
| 2116 | rdev->pm.power_state[state_index].clock_info[mode_index].mclk = mclk; |
| 2117 | rdev->pm.power_state[state_index].clock_info[mode_index].sclk = sclk; |
| 2118 | /* skip invalid modes */ |
| 2119 | if ((rdev->pm.power_state[state_index].clock_info[mode_index].mclk == 0) || |
| 2120 | (rdev->pm.power_state[state_index].clock_info[mode_index].sclk == 0)) |
| 2121 | continue; |
Alex Deucher | 49f6598 | 2010-03-24 16:39:45 -0400 | [diff] [blame] | 2122 | rdev->pm.power_state[state_index].clock_info[mode_index].voltage.type = |
| 2123 | VOLTAGE_SW; |
| 2124 | rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage = |
| 2125 | clock_info->usVDDC; |
| 2126 | /* XXX usVDDCI */ |
| 2127 | mode_index++; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2128 | } else { |
| 2129 | struct _ATOM_PPLIB_R600_CLOCK_INFO *clock_info = |
| 2130 | (struct _ATOM_PPLIB_R600_CLOCK_INFO *) |
| 2131 | (mode_info->atom_context->bios + |
| 2132 | data_offset + |
| 2133 | le16_to_cpu(power_info->info_4.usClockInfoArrayOffset) + |
| 2134 | (power_state->ucClockStateIndices[j] * |
| 2135 | power_info->info_4.ucClockInfoSize)); |
| 2136 | sclk = le16_to_cpu(clock_info->usEngineClockLow); |
| 2137 | sclk |= clock_info->ucEngineClockHigh << 16; |
| 2138 | mclk = le16_to_cpu(clock_info->usMemoryClockLow); |
| 2139 | mclk |= clock_info->ucMemoryClockHigh << 16; |
| 2140 | rdev->pm.power_state[state_index].clock_info[mode_index].mclk = mclk; |
| 2141 | rdev->pm.power_state[state_index].clock_info[mode_index].sclk = sclk; |
| 2142 | /* skip invalid modes */ |
| 2143 | if ((rdev->pm.power_state[state_index].clock_info[mode_index].mclk == 0) || |
| 2144 | (rdev->pm.power_state[state_index].clock_info[mode_index].sclk == 0)) |
| 2145 | continue; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2146 | rdev->pm.power_state[state_index].clock_info[mode_index].voltage.type = |
| 2147 | VOLTAGE_SW; |
| 2148 | rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage = |
| 2149 | clock_info->usVDDC; |
| 2150 | mode_index++; |
| 2151 | } |
| 2152 | } |
| 2153 | rdev->pm.power_state[state_index].num_clock_modes = mode_index; |
| 2154 | if (mode_index) { |
Rafał Miłecki | 845db70 | 2009-12-23 00:42:43 +0100 | [diff] [blame] | 2155 | misc = le32_to_cpu(non_clock_info->ulCapsAndSettings); |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2156 | misc2 = le16_to_cpu(non_clock_info->usClassification); |
Alex Deucher | 79daedc | 2010-04-22 14:25:19 -0400 | [diff] [blame] | 2157 | rdev->pm.power_state[state_index].misc = misc; |
| 2158 | rdev->pm.power_state[state_index].misc2 = misc2; |
| 2159 | rdev->pm.power_state[state_index].pcie_lanes = |
Rafał Miłecki | 845db70 | 2009-12-23 00:42:43 +0100 | [diff] [blame] | 2160 | ((misc & ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >> |
| 2161 | ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT) + 1; |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 2162 | switch (misc2 & ATOM_PPLIB_CLASSIFICATION_UI_MASK) { |
| 2163 | case ATOM_PPLIB_CLASSIFICATION_UI_BATTERY: |
| 2164 | rdev->pm.power_state[state_index].type = |
| 2165 | POWER_STATE_TYPE_BATTERY; |
| 2166 | break; |
| 2167 | case ATOM_PPLIB_CLASSIFICATION_UI_BALANCED: |
| 2168 | rdev->pm.power_state[state_index].type = |
| 2169 | POWER_STATE_TYPE_BALANCED; |
| 2170 | break; |
| 2171 | case ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE: |
| 2172 | rdev->pm.power_state[state_index].type = |
| 2173 | POWER_STATE_TYPE_PERFORMANCE; |
| 2174 | break; |
Alex Deucher | a44d2f3 | 2010-08-04 11:10:26 -0400 | [diff] [blame] | 2175 | case ATOM_PPLIB_CLASSIFICATION_UI_NONE: |
| 2176 | if (misc2 & ATOM_PPLIB_CLASSIFICATION_3DPERFORMANCE) |
| 2177 | rdev->pm.power_state[state_index].type = |
| 2178 | POWER_STATE_TYPE_PERFORMANCE; |
| 2179 | break; |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 2180 | } |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 2181 | rdev->pm.power_state[state_index].flags = 0; |
| 2182 | if (misc & ATOM_PPLIB_SINGLE_DISPLAY_ONLY) |
| 2183 | rdev->pm.power_state[state_index].flags |= |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 2184 | RADEON_PM_STATE_SINGLE_DISPLAY_ONLY; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2185 | if (misc2 & ATOM_PPLIB_CLASSIFICATION_BOOT) { |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 2186 | rdev->pm.power_state[state_index].type = |
| 2187 | POWER_STATE_TYPE_DEFAULT; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 2188 | rdev->pm.default_power_state_index = state_index; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2189 | rdev->pm.power_state[state_index].default_clock_mode = |
| 2190 | &rdev->pm.power_state[state_index].clock_info[mode_index - 1]; |
Alex Deucher | c5e8ce6 | 2010-05-27 17:01:40 -0400 | [diff] [blame] | 2191 | /* patch the table values with the default slck/mclk from firmware info */ |
| 2192 | for (j = 0; j < mode_index; j++) { |
| 2193 | rdev->pm.power_state[state_index].clock_info[j].mclk = |
| 2194 | rdev->clock.default_mclk; |
| 2195 | rdev->pm.power_state[state_index].clock_info[j].sclk = |
| 2196 | rdev->clock.default_sclk; |
| 2197 | if (vddc) |
| 2198 | rdev->pm.power_state[state_index].clock_info[j].voltage.voltage = |
| 2199 | vddc; |
| 2200 | } |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2201 | } |
| 2202 | state_index++; |
| 2203 | } |
| 2204 | } |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 2205 | /* if multiple clock modes, mark the lowest as no display */ |
| 2206 | for (i = 0; i < state_index; i++) { |
| 2207 | if (rdev->pm.power_state[i].num_clock_modes > 1) |
| 2208 | rdev->pm.power_state[i].clock_info[0].flags |= |
| 2209 | RADEON_PM_MODE_NO_DISPLAY; |
| 2210 | } |
Alex Deucher | 02b17cc | 2010-04-22 13:25:06 -0400 | [diff] [blame] | 2211 | /* first mode is usually default */ |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 2212 | if (rdev->pm.default_power_state_index == -1) { |
Alex Deucher | 02b17cc | 2010-04-22 13:25:06 -0400 | [diff] [blame] | 2213 | rdev->pm.power_state[0].type = |
| 2214 | POWER_STATE_TYPE_DEFAULT; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 2215 | rdev->pm.default_power_state_index = 0; |
Alex Deucher | 02b17cc | 2010-04-22 13:25:06 -0400 | [diff] [blame] | 2216 | rdev->pm.power_state[0].default_clock_mode = |
| 2217 | &rdev->pm.power_state[0].clock_info[0]; |
| 2218 | } |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2219 | } |
| 2220 | } else { |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2221 | /* add the default mode */ |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 2222 | rdev->pm.power_state[state_index].type = |
| 2223 | POWER_STATE_TYPE_DEFAULT; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2224 | rdev->pm.power_state[state_index].num_clock_modes = 1; |
| 2225 | rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk; |
| 2226 | rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk; |
| 2227 | rdev->pm.power_state[state_index].default_clock_mode = |
| 2228 | &rdev->pm.power_state[state_index].clock_info[0]; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2229 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; |
Alex Deucher | 79daedc | 2010-04-22 14:25:19 -0400 | [diff] [blame] | 2230 | rdev->pm.power_state[state_index].pcie_lanes = 16; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 2231 | rdev->pm.default_power_state_index = state_index; |
| 2232 | rdev->pm.power_state[state_index].flags = 0; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2233 | state_index++; |
| 2234 | } |
Alex Deucher | 02b17cc | 2010-04-22 13:25:06 -0400 | [diff] [blame] | 2235 | |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2236 | rdev->pm.num_power_states = state_index; |
Rafał Miłecki | 9038dfd | 2010-02-20 23:15:04 +0000 | [diff] [blame] | 2237 | |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 2238 | rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; |
| 2239 | rdev->pm.current_clock_mode_index = 0; |
Alex Deucher | 4d60173 | 2010-06-07 18:15:18 -0400 | [diff] [blame] | 2240 | rdev->pm.current_vddc = rdev->pm.power_state[rdev->pm.default_power_state_index].clock_info[0].voltage.voltage; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 2241 | } |
| 2242 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2243 | void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable) |
| 2244 | { |
| 2245 | DYNAMIC_CLOCK_GATING_PS_ALLOCATION args; |
| 2246 | int index = GetIndexIntoMasterTable(COMMAND, DynamicClockGating); |
| 2247 | |
| 2248 | args.ucEnable = enable; |
| 2249 | |
| 2250 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
| 2251 | } |
| 2252 | |
Rafał Miłecki | 7433874 | 2009-11-03 00:53:02 +0100 | [diff] [blame] | 2253 | uint32_t radeon_atom_get_engine_clock(struct radeon_device *rdev) |
| 2254 | { |
| 2255 | GET_ENGINE_CLOCK_PS_ALLOCATION args; |
| 2256 | int index = GetIndexIntoMasterTable(COMMAND, GetEngineClock); |
| 2257 | |
| 2258 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
| 2259 | return args.ulReturnEngineClock; |
| 2260 | } |
| 2261 | |
| 2262 | uint32_t radeon_atom_get_memory_clock(struct radeon_device *rdev) |
| 2263 | { |
| 2264 | GET_MEMORY_CLOCK_PS_ALLOCATION args; |
| 2265 | int index = GetIndexIntoMasterTable(COMMAND, GetMemoryClock); |
| 2266 | |
| 2267 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
| 2268 | return args.ulReturnMemoryClock; |
| 2269 | } |
| 2270 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2271 | void radeon_atom_set_engine_clock(struct radeon_device *rdev, |
| 2272 | uint32_t eng_clock) |
| 2273 | { |
| 2274 | SET_ENGINE_CLOCK_PS_ALLOCATION args; |
| 2275 | int index = GetIndexIntoMasterTable(COMMAND, SetEngineClock); |
| 2276 | |
| 2277 | args.ulTargetEngineClock = eng_clock; /* 10 khz */ |
| 2278 | |
| 2279 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
| 2280 | } |
| 2281 | |
| 2282 | void radeon_atom_set_memory_clock(struct radeon_device *rdev, |
| 2283 | uint32_t mem_clock) |
| 2284 | { |
| 2285 | SET_MEMORY_CLOCK_PS_ALLOCATION args; |
| 2286 | int index = GetIndexIntoMasterTable(COMMAND, SetMemoryClock); |
| 2287 | |
| 2288 | if (rdev->flags & RADEON_IS_IGP) |
| 2289 | return; |
| 2290 | |
| 2291 | args.ulTargetMemoryClock = mem_clock; /* 10 khz */ |
| 2292 | |
| 2293 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
| 2294 | } |
| 2295 | |
Alex Deucher | 7ac9aa5 | 2010-05-27 19:25:54 -0400 | [diff] [blame] | 2296 | union set_voltage { |
| 2297 | struct _SET_VOLTAGE_PS_ALLOCATION alloc; |
| 2298 | struct _SET_VOLTAGE_PARAMETERS v1; |
| 2299 | struct _SET_VOLTAGE_PARAMETERS_V2 v2; |
| 2300 | }; |
| 2301 | |
| 2302 | void radeon_atom_set_voltage(struct radeon_device *rdev, u16 level) |
| 2303 | { |
| 2304 | union set_voltage args; |
| 2305 | int index = GetIndexIntoMasterTable(COMMAND, SetVoltage); |
| 2306 | u8 frev, crev, volt_index = level; |
| 2307 | |
| 2308 | if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev)) |
| 2309 | return; |
| 2310 | |
| 2311 | switch (crev) { |
| 2312 | case 1: |
| 2313 | args.v1.ucVoltageType = SET_VOLTAGE_TYPE_ASIC_VDDC; |
| 2314 | args.v1.ucVoltageMode = SET_ASIC_VOLTAGE_MODE_ALL_SOURCE; |
| 2315 | args.v1.ucVoltageIndex = volt_index; |
| 2316 | break; |
| 2317 | case 2: |
| 2318 | args.v2.ucVoltageType = SET_VOLTAGE_TYPE_ASIC_VDDC; |
| 2319 | args.v2.ucVoltageMode = SET_ASIC_VOLTAGE_MODE_SET_VOLTAGE; |
| 2320 | args.v2.usVoltageLevel = cpu_to_le16(level); |
| 2321 | break; |
| 2322 | default: |
| 2323 | DRM_ERROR("Unknown table version %d, %d\n", frev, crev); |
| 2324 | return; |
| 2325 | } |
| 2326 | |
| 2327 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
| 2328 | } |
| 2329 | |
| 2330 | |
| 2331 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2332 | void radeon_atom_initialize_bios_scratch_regs(struct drm_device *dev) |
| 2333 | { |
| 2334 | struct radeon_device *rdev = dev->dev_private; |
| 2335 | uint32_t bios_2_scratch, bios_6_scratch; |
| 2336 | |
| 2337 | if (rdev->family >= CHIP_R600) { |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 2338 | bios_2_scratch = RREG32(R600_BIOS_2_SCRATCH); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2339 | bios_6_scratch = RREG32(R600_BIOS_6_SCRATCH); |
| 2340 | } else { |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 2341 | bios_2_scratch = RREG32(RADEON_BIOS_2_SCRATCH); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2342 | bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); |
| 2343 | } |
| 2344 | |
| 2345 | /* let the bios control the backlight */ |
| 2346 | bios_2_scratch &= ~ATOM_S2_VRI_BRIGHT_ENABLE; |
| 2347 | |
| 2348 | /* tell the bios not to handle mode switching */ |
| 2349 | bios_6_scratch |= (ATOM_S6_ACC_BLOCK_DISPLAY_SWITCH | ATOM_S6_ACC_MODE); |
| 2350 | |
| 2351 | if (rdev->family >= CHIP_R600) { |
| 2352 | WREG32(R600_BIOS_2_SCRATCH, bios_2_scratch); |
| 2353 | WREG32(R600_BIOS_6_SCRATCH, bios_6_scratch); |
| 2354 | } else { |
| 2355 | WREG32(RADEON_BIOS_2_SCRATCH, bios_2_scratch); |
| 2356 | WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); |
| 2357 | } |
| 2358 | |
| 2359 | } |
| 2360 | |
Yang Zhao | f657c2a | 2009-09-15 12:21:01 +1000 | [diff] [blame] | 2361 | void radeon_save_bios_scratch_regs(struct radeon_device *rdev) |
| 2362 | { |
| 2363 | uint32_t scratch_reg; |
| 2364 | int i; |
| 2365 | |
| 2366 | if (rdev->family >= CHIP_R600) |
| 2367 | scratch_reg = R600_BIOS_0_SCRATCH; |
| 2368 | else |
| 2369 | scratch_reg = RADEON_BIOS_0_SCRATCH; |
| 2370 | |
| 2371 | for (i = 0; i < RADEON_BIOS_NUM_SCRATCH; i++) |
| 2372 | rdev->bios_scratch[i] = RREG32(scratch_reg + (i * 4)); |
| 2373 | } |
| 2374 | |
| 2375 | void radeon_restore_bios_scratch_regs(struct radeon_device *rdev) |
| 2376 | { |
| 2377 | uint32_t scratch_reg; |
| 2378 | int i; |
| 2379 | |
| 2380 | if (rdev->family >= CHIP_R600) |
| 2381 | scratch_reg = R600_BIOS_0_SCRATCH; |
| 2382 | else |
| 2383 | scratch_reg = RADEON_BIOS_0_SCRATCH; |
| 2384 | |
| 2385 | for (i = 0; i < RADEON_BIOS_NUM_SCRATCH; i++) |
| 2386 | WREG32(scratch_reg + (i * 4), rdev->bios_scratch[i]); |
| 2387 | } |
| 2388 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2389 | void radeon_atom_output_lock(struct drm_encoder *encoder, bool lock) |
| 2390 | { |
| 2391 | struct drm_device *dev = encoder->dev; |
| 2392 | struct radeon_device *rdev = dev->dev_private; |
| 2393 | uint32_t bios_6_scratch; |
| 2394 | |
| 2395 | if (rdev->family >= CHIP_R600) |
| 2396 | bios_6_scratch = RREG32(R600_BIOS_6_SCRATCH); |
| 2397 | else |
| 2398 | bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); |
| 2399 | |
| 2400 | if (lock) |
| 2401 | bios_6_scratch |= ATOM_S6_CRITICAL_STATE; |
| 2402 | else |
| 2403 | bios_6_scratch &= ~ATOM_S6_CRITICAL_STATE; |
| 2404 | |
| 2405 | if (rdev->family >= CHIP_R600) |
| 2406 | WREG32(R600_BIOS_6_SCRATCH, bios_6_scratch); |
| 2407 | else |
| 2408 | WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); |
| 2409 | } |
| 2410 | |
| 2411 | /* at some point we may want to break this out into individual functions */ |
| 2412 | void |
| 2413 | radeon_atombios_connected_scratch_regs(struct drm_connector *connector, |
| 2414 | struct drm_encoder *encoder, |
| 2415 | bool connected) |
| 2416 | { |
| 2417 | struct drm_device *dev = connector->dev; |
| 2418 | struct radeon_device *rdev = dev->dev_private; |
| 2419 | struct radeon_connector *radeon_connector = |
| 2420 | to_radeon_connector(connector); |
| 2421 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 2422 | uint32_t bios_0_scratch, bios_3_scratch, bios_6_scratch; |
| 2423 | |
| 2424 | if (rdev->family >= CHIP_R600) { |
| 2425 | bios_0_scratch = RREG32(R600_BIOS_0_SCRATCH); |
| 2426 | bios_3_scratch = RREG32(R600_BIOS_3_SCRATCH); |
| 2427 | bios_6_scratch = RREG32(R600_BIOS_6_SCRATCH); |
| 2428 | } else { |
| 2429 | bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); |
| 2430 | bios_3_scratch = RREG32(RADEON_BIOS_3_SCRATCH); |
| 2431 | bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); |
| 2432 | } |
| 2433 | |
| 2434 | if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) && |
| 2435 | (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) { |
| 2436 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2437 | DRM_DEBUG_KMS("TV1 connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2438 | bios_3_scratch |= ATOM_S3_TV1_ACTIVE; |
| 2439 | bios_6_scratch |= ATOM_S6_ACC_REQ_TV1; |
| 2440 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2441 | DRM_DEBUG_KMS("TV1 disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2442 | bios_0_scratch &= ~ATOM_S0_TV1_MASK; |
| 2443 | bios_3_scratch &= ~ATOM_S3_TV1_ACTIVE; |
| 2444 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_TV1; |
| 2445 | } |
| 2446 | } |
| 2447 | if ((radeon_encoder->devices & ATOM_DEVICE_CV_SUPPORT) && |
| 2448 | (radeon_connector->devices & ATOM_DEVICE_CV_SUPPORT)) { |
| 2449 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2450 | DRM_DEBUG_KMS("CV connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2451 | bios_3_scratch |= ATOM_S3_CV_ACTIVE; |
| 2452 | bios_6_scratch |= ATOM_S6_ACC_REQ_CV; |
| 2453 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2454 | DRM_DEBUG_KMS("CV disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2455 | bios_0_scratch &= ~ATOM_S0_CV_MASK; |
| 2456 | bios_3_scratch &= ~ATOM_S3_CV_ACTIVE; |
| 2457 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_CV; |
| 2458 | } |
| 2459 | } |
| 2460 | if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) && |
| 2461 | (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) { |
| 2462 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2463 | DRM_DEBUG_KMS("LCD1 connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2464 | bios_0_scratch |= ATOM_S0_LCD1; |
| 2465 | bios_3_scratch |= ATOM_S3_LCD1_ACTIVE; |
| 2466 | bios_6_scratch |= ATOM_S6_ACC_REQ_LCD1; |
| 2467 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2468 | DRM_DEBUG_KMS("LCD1 disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2469 | bios_0_scratch &= ~ATOM_S0_LCD1; |
| 2470 | bios_3_scratch &= ~ATOM_S3_LCD1_ACTIVE; |
| 2471 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_LCD1; |
| 2472 | } |
| 2473 | } |
| 2474 | if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) && |
| 2475 | (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) { |
| 2476 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2477 | DRM_DEBUG_KMS("CRT1 connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2478 | bios_0_scratch |= ATOM_S0_CRT1_COLOR; |
| 2479 | bios_3_scratch |= ATOM_S3_CRT1_ACTIVE; |
| 2480 | bios_6_scratch |= ATOM_S6_ACC_REQ_CRT1; |
| 2481 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2482 | DRM_DEBUG_KMS("CRT1 disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2483 | bios_0_scratch &= ~ATOM_S0_CRT1_MASK; |
| 2484 | bios_3_scratch &= ~ATOM_S3_CRT1_ACTIVE; |
| 2485 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_CRT1; |
| 2486 | } |
| 2487 | } |
| 2488 | if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) && |
| 2489 | (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) { |
| 2490 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2491 | DRM_DEBUG_KMS("CRT2 connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2492 | bios_0_scratch |= ATOM_S0_CRT2_COLOR; |
| 2493 | bios_3_scratch |= ATOM_S3_CRT2_ACTIVE; |
| 2494 | bios_6_scratch |= ATOM_S6_ACC_REQ_CRT2; |
| 2495 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2496 | DRM_DEBUG_KMS("CRT2 disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2497 | bios_0_scratch &= ~ATOM_S0_CRT2_MASK; |
| 2498 | bios_3_scratch &= ~ATOM_S3_CRT2_ACTIVE; |
| 2499 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_CRT2; |
| 2500 | } |
| 2501 | } |
| 2502 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) && |
| 2503 | (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) { |
| 2504 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2505 | DRM_DEBUG_KMS("DFP1 connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2506 | bios_0_scratch |= ATOM_S0_DFP1; |
| 2507 | bios_3_scratch |= ATOM_S3_DFP1_ACTIVE; |
| 2508 | bios_6_scratch |= ATOM_S6_ACC_REQ_DFP1; |
| 2509 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2510 | DRM_DEBUG_KMS("DFP1 disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2511 | bios_0_scratch &= ~ATOM_S0_DFP1; |
| 2512 | bios_3_scratch &= ~ATOM_S3_DFP1_ACTIVE; |
| 2513 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP1; |
| 2514 | } |
| 2515 | } |
| 2516 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) && |
| 2517 | (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) { |
| 2518 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2519 | DRM_DEBUG_KMS("DFP2 connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2520 | bios_0_scratch |= ATOM_S0_DFP2; |
| 2521 | bios_3_scratch |= ATOM_S3_DFP2_ACTIVE; |
| 2522 | bios_6_scratch |= ATOM_S6_ACC_REQ_DFP2; |
| 2523 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2524 | DRM_DEBUG_KMS("DFP2 disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2525 | bios_0_scratch &= ~ATOM_S0_DFP2; |
| 2526 | bios_3_scratch &= ~ATOM_S3_DFP2_ACTIVE; |
| 2527 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP2; |
| 2528 | } |
| 2529 | } |
| 2530 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP3_SUPPORT) && |
| 2531 | (radeon_connector->devices & ATOM_DEVICE_DFP3_SUPPORT)) { |
| 2532 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2533 | DRM_DEBUG_KMS("DFP3 connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2534 | bios_0_scratch |= ATOM_S0_DFP3; |
| 2535 | bios_3_scratch |= ATOM_S3_DFP3_ACTIVE; |
| 2536 | bios_6_scratch |= ATOM_S6_ACC_REQ_DFP3; |
| 2537 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2538 | DRM_DEBUG_KMS("DFP3 disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2539 | bios_0_scratch &= ~ATOM_S0_DFP3; |
| 2540 | bios_3_scratch &= ~ATOM_S3_DFP3_ACTIVE; |
| 2541 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP3; |
| 2542 | } |
| 2543 | } |
| 2544 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP4_SUPPORT) && |
| 2545 | (radeon_connector->devices & ATOM_DEVICE_DFP4_SUPPORT)) { |
| 2546 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2547 | DRM_DEBUG_KMS("DFP4 connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2548 | bios_0_scratch |= ATOM_S0_DFP4; |
| 2549 | bios_3_scratch |= ATOM_S3_DFP4_ACTIVE; |
| 2550 | bios_6_scratch |= ATOM_S6_ACC_REQ_DFP4; |
| 2551 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2552 | DRM_DEBUG_KMS("DFP4 disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2553 | bios_0_scratch &= ~ATOM_S0_DFP4; |
| 2554 | bios_3_scratch &= ~ATOM_S3_DFP4_ACTIVE; |
| 2555 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP4; |
| 2556 | } |
| 2557 | } |
| 2558 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP5_SUPPORT) && |
| 2559 | (radeon_connector->devices & ATOM_DEVICE_DFP5_SUPPORT)) { |
| 2560 | if (connected) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2561 | DRM_DEBUG_KMS("DFP5 connected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2562 | bios_0_scratch |= ATOM_S0_DFP5; |
| 2563 | bios_3_scratch |= ATOM_S3_DFP5_ACTIVE; |
| 2564 | bios_6_scratch |= ATOM_S6_ACC_REQ_DFP5; |
| 2565 | } else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 2566 | DRM_DEBUG_KMS("DFP5 disconnected\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2567 | bios_0_scratch &= ~ATOM_S0_DFP5; |
| 2568 | bios_3_scratch &= ~ATOM_S3_DFP5_ACTIVE; |
| 2569 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP5; |
| 2570 | } |
| 2571 | } |
| 2572 | |
| 2573 | if (rdev->family >= CHIP_R600) { |
| 2574 | WREG32(R600_BIOS_0_SCRATCH, bios_0_scratch); |
| 2575 | WREG32(R600_BIOS_3_SCRATCH, bios_3_scratch); |
| 2576 | WREG32(R600_BIOS_6_SCRATCH, bios_6_scratch); |
| 2577 | } else { |
| 2578 | WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch); |
| 2579 | WREG32(RADEON_BIOS_3_SCRATCH, bios_3_scratch); |
| 2580 | WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); |
| 2581 | } |
| 2582 | } |
| 2583 | |
| 2584 | void |
| 2585 | radeon_atombios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc) |
| 2586 | { |
| 2587 | struct drm_device *dev = encoder->dev; |
| 2588 | struct radeon_device *rdev = dev->dev_private; |
| 2589 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 2590 | uint32_t bios_3_scratch; |
| 2591 | |
| 2592 | if (rdev->family >= CHIP_R600) |
| 2593 | bios_3_scratch = RREG32(R600_BIOS_3_SCRATCH); |
| 2594 | else |
| 2595 | bios_3_scratch = RREG32(RADEON_BIOS_3_SCRATCH); |
| 2596 | |
| 2597 | if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { |
| 2598 | bios_3_scratch &= ~ATOM_S3_TV1_CRTC_ACTIVE; |
| 2599 | bios_3_scratch |= (crtc << 18); |
| 2600 | } |
| 2601 | if (radeon_encoder->devices & ATOM_DEVICE_CV_SUPPORT) { |
| 2602 | bios_3_scratch &= ~ATOM_S3_CV_CRTC_ACTIVE; |
| 2603 | bios_3_scratch |= (crtc << 24); |
| 2604 | } |
| 2605 | if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { |
| 2606 | bios_3_scratch &= ~ATOM_S3_CRT1_CRTC_ACTIVE; |
| 2607 | bios_3_scratch |= (crtc << 16); |
| 2608 | } |
| 2609 | if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { |
| 2610 | bios_3_scratch &= ~ATOM_S3_CRT2_CRTC_ACTIVE; |
| 2611 | bios_3_scratch |= (crtc << 20); |
| 2612 | } |
| 2613 | if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { |
| 2614 | bios_3_scratch &= ~ATOM_S3_LCD1_CRTC_ACTIVE; |
| 2615 | bios_3_scratch |= (crtc << 17); |
| 2616 | } |
| 2617 | if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { |
| 2618 | bios_3_scratch &= ~ATOM_S3_DFP1_CRTC_ACTIVE; |
| 2619 | bios_3_scratch |= (crtc << 19); |
| 2620 | } |
| 2621 | if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { |
| 2622 | bios_3_scratch &= ~ATOM_S3_DFP2_CRTC_ACTIVE; |
| 2623 | bios_3_scratch |= (crtc << 23); |
| 2624 | } |
| 2625 | if (radeon_encoder->devices & ATOM_DEVICE_DFP3_SUPPORT) { |
| 2626 | bios_3_scratch &= ~ATOM_S3_DFP3_CRTC_ACTIVE; |
| 2627 | bios_3_scratch |= (crtc << 25); |
| 2628 | } |
| 2629 | |
| 2630 | if (rdev->family >= CHIP_R600) |
| 2631 | WREG32(R600_BIOS_3_SCRATCH, bios_3_scratch); |
| 2632 | else |
| 2633 | WREG32(RADEON_BIOS_3_SCRATCH, bios_3_scratch); |
| 2634 | } |
| 2635 | |
| 2636 | void |
| 2637 | radeon_atombios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on) |
| 2638 | { |
| 2639 | struct drm_device *dev = encoder->dev; |
| 2640 | struct radeon_device *rdev = dev->dev_private; |
| 2641 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 2642 | uint32_t bios_2_scratch; |
| 2643 | |
| 2644 | if (rdev->family >= CHIP_R600) |
| 2645 | bios_2_scratch = RREG32(R600_BIOS_2_SCRATCH); |
| 2646 | else |
| 2647 | bios_2_scratch = RREG32(RADEON_BIOS_2_SCRATCH); |
| 2648 | |
| 2649 | if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { |
| 2650 | if (on) |
| 2651 | bios_2_scratch &= ~ATOM_S2_TV1_DPMS_STATE; |
| 2652 | else |
| 2653 | bios_2_scratch |= ATOM_S2_TV1_DPMS_STATE; |
| 2654 | } |
| 2655 | if (radeon_encoder->devices & ATOM_DEVICE_CV_SUPPORT) { |
| 2656 | if (on) |
| 2657 | bios_2_scratch &= ~ATOM_S2_CV_DPMS_STATE; |
| 2658 | else |
| 2659 | bios_2_scratch |= ATOM_S2_CV_DPMS_STATE; |
| 2660 | } |
| 2661 | if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { |
| 2662 | if (on) |
| 2663 | bios_2_scratch &= ~ATOM_S2_CRT1_DPMS_STATE; |
| 2664 | else |
| 2665 | bios_2_scratch |= ATOM_S2_CRT1_DPMS_STATE; |
| 2666 | } |
| 2667 | if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { |
| 2668 | if (on) |
| 2669 | bios_2_scratch &= ~ATOM_S2_CRT2_DPMS_STATE; |
| 2670 | else |
| 2671 | bios_2_scratch |= ATOM_S2_CRT2_DPMS_STATE; |
| 2672 | } |
| 2673 | if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { |
| 2674 | if (on) |
| 2675 | bios_2_scratch &= ~ATOM_S2_LCD1_DPMS_STATE; |
| 2676 | else |
| 2677 | bios_2_scratch |= ATOM_S2_LCD1_DPMS_STATE; |
| 2678 | } |
| 2679 | if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { |
| 2680 | if (on) |
| 2681 | bios_2_scratch &= ~ATOM_S2_DFP1_DPMS_STATE; |
| 2682 | else |
| 2683 | bios_2_scratch |= ATOM_S2_DFP1_DPMS_STATE; |
| 2684 | } |
| 2685 | if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { |
| 2686 | if (on) |
| 2687 | bios_2_scratch &= ~ATOM_S2_DFP2_DPMS_STATE; |
| 2688 | else |
| 2689 | bios_2_scratch |= ATOM_S2_DFP2_DPMS_STATE; |
| 2690 | } |
| 2691 | if (radeon_encoder->devices & ATOM_DEVICE_DFP3_SUPPORT) { |
| 2692 | if (on) |
| 2693 | bios_2_scratch &= ~ATOM_S2_DFP3_DPMS_STATE; |
| 2694 | else |
| 2695 | bios_2_scratch |= ATOM_S2_DFP3_DPMS_STATE; |
| 2696 | } |
| 2697 | if (radeon_encoder->devices & ATOM_DEVICE_DFP4_SUPPORT) { |
| 2698 | if (on) |
| 2699 | bios_2_scratch &= ~ATOM_S2_DFP4_DPMS_STATE; |
| 2700 | else |
| 2701 | bios_2_scratch |= ATOM_S2_DFP4_DPMS_STATE; |
| 2702 | } |
| 2703 | if (radeon_encoder->devices & ATOM_DEVICE_DFP5_SUPPORT) { |
| 2704 | if (on) |
| 2705 | bios_2_scratch &= ~ATOM_S2_DFP5_DPMS_STATE; |
| 2706 | else |
| 2707 | bios_2_scratch |= ATOM_S2_DFP5_DPMS_STATE; |
| 2708 | } |
| 2709 | |
| 2710 | if (rdev->family >= CHIP_R600) |
| 2711 | WREG32(R600_BIOS_2_SCRATCH, bios_2_scratch); |
| 2712 | else |
| 2713 | WREG32(RADEON_BIOS_2_SCRATCH, bios_2_scratch); |
| 2714 | } |