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