radeon_atombios.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477
  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. #include "atom.h"
  30. #include "atom-bits.h"
  31. /* from radeon_encoder.c */
  32. extern uint32_t
  33. radeon_get_encoder_id(struct drm_device *dev, uint32_t supported_device,
  34. uint8_t dac);
  35. extern void radeon_link_encoder_connector(struct drm_device *dev);
  36. extern void
  37. radeon_add_atom_encoder(struct drm_device *dev, uint32_t encoder_id,
  38. uint32_t supported_device);
  39. /* from radeon_connector.c */
  40. extern void
  41. radeon_add_atom_connector(struct drm_device *dev,
  42. uint32_t connector_id,
  43. uint32_t supported_device,
  44. int connector_type,
  45. struct radeon_i2c_bus_rec *i2c_bus,
  46. bool linkb, uint32_t igp_lane_info);
  47. /* from radeon_legacy_encoder.c */
  48. extern void
  49. radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_id,
  50. uint32_t supported_device);
  51. union atom_supported_devices {
  52. struct _ATOM_SUPPORTED_DEVICES_INFO info;
  53. struct _ATOM_SUPPORTED_DEVICES_INFO_2 info_2;
  54. struct _ATOM_SUPPORTED_DEVICES_INFO_2d1 info_2d1;
  55. };
  56. static inline struct radeon_i2c_bus_rec radeon_lookup_gpio(struct drm_device
  57. *dev, uint8_t id)
  58. {
  59. struct radeon_device *rdev = dev->dev_private;
  60. struct atom_context *ctx = rdev->mode_info.atom_context;
  61. ATOM_GPIO_I2C_ASSIGMENT gpio;
  62. struct radeon_i2c_bus_rec i2c;
  63. int index = GetIndexIntoMasterTable(DATA, GPIO_I2C_Info);
  64. struct _ATOM_GPIO_I2C_INFO *i2c_info;
  65. uint16_t data_offset;
  66. memset(&i2c, 0, sizeof(struct radeon_i2c_bus_rec));
  67. i2c.valid = false;
  68. atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset);
  69. i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset);
  70. gpio = i2c_info->asGPIO_Info[id];
  71. i2c.mask_clk_reg = le16_to_cpu(gpio.usClkMaskRegisterIndex) * 4;
  72. i2c.mask_data_reg = le16_to_cpu(gpio.usDataMaskRegisterIndex) * 4;
  73. i2c.put_clk_reg = le16_to_cpu(gpio.usClkEnRegisterIndex) * 4;
  74. i2c.put_data_reg = le16_to_cpu(gpio.usDataEnRegisterIndex) * 4;
  75. i2c.get_clk_reg = le16_to_cpu(gpio.usClkY_RegisterIndex) * 4;
  76. i2c.get_data_reg = le16_to_cpu(gpio.usDataY_RegisterIndex) * 4;
  77. i2c.a_clk_reg = le16_to_cpu(gpio.usClkA_RegisterIndex) * 4;
  78. i2c.a_data_reg = le16_to_cpu(gpio.usDataA_RegisterIndex) * 4;
  79. i2c.mask_clk_mask = (1 << gpio.ucClkMaskShift);
  80. i2c.mask_data_mask = (1 << gpio.ucDataMaskShift);
  81. i2c.put_clk_mask = (1 << gpio.ucClkEnShift);
  82. i2c.put_data_mask = (1 << gpio.ucDataEnShift);
  83. i2c.get_clk_mask = (1 << gpio.ucClkY_Shift);
  84. i2c.get_data_mask = (1 << gpio.ucDataY_Shift);
  85. i2c.a_clk_mask = (1 << gpio.ucClkA_Shift);
  86. i2c.a_data_mask = (1 << gpio.ucDataA_Shift);
  87. i2c.valid = true;
  88. return i2c;
  89. }
  90. static bool radeon_atom_apply_quirks(struct drm_device *dev,
  91. uint32_t supported_device,
  92. int *connector_type,
  93. struct radeon_i2c_bus_rec *i2c_bus,
  94. uint16_t *line_mux)
  95. {
  96. /* Asus M2A-VM HDMI board lists the DVI port as HDMI */
  97. if ((dev->pdev->device == 0x791e) &&
  98. (dev->pdev->subsystem_vendor == 0x1043) &&
  99. (dev->pdev->subsystem_device == 0x826d)) {
  100. if ((*connector_type == DRM_MODE_CONNECTOR_HDMIA) &&
  101. (supported_device == ATOM_DEVICE_DFP3_SUPPORT))
  102. *connector_type = DRM_MODE_CONNECTOR_DVID;
  103. }
  104. /* a-bit f-i90hd - ciaranm on #radeonhd - this board has no DVI */
  105. if ((dev->pdev->device == 0x7941) &&
  106. (dev->pdev->subsystem_vendor == 0x147b) &&
  107. (dev->pdev->subsystem_device == 0x2412)) {
  108. if (*connector_type == DRM_MODE_CONNECTOR_DVII)
  109. return false;
  110. }
  111. /* Falcon NW laptop lists vga ddc line for LVDS */
  112. if ((dev->pdev->device == 0x5653) &&
  113. (dev->pdev->subsystem_vendor == 0x1462) &&
  114. (dev->pdev->subsystem_device == 0x0291)) {
  115. if (*connector_type == DRM_MODE_CONNECTOR_LVDS) {
  116. i2c_bus->valid = false;
  117. *line_mux = 53;
  118. }
  119. }
  120. /* Funky macbooks */
  121. if ((dev->pdev->device == 0x71C5) &&
  122. (dev->pdev->subsystem_vendor == 0x106b) &&
  123. (dev->pdev->subsystem_device == 0x0080)) {
  124. if ((supported_device == ATOM_DEVICE_CRT1_SUPPORT) ||
  125. (supported_device == ATOM_DEVICE_DFP2_SUPPORT))
  126. return false;
  127. }
  128. /* ASUS HD 3600 XT board lists the DVI port as HDMI */
  129. if ((dev->pdev->device == 0x9598) &&
  130. (dev->pdev->subsystem_vendor == 0x1043) &&
  131. (dev->pdev->subsystem_device == 0x01da)) {
  132. if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) {
  133. *connector_type = DRM_MODE_CONNECTOR_DVII;
  134. }
  135. }
  136. /* ASUS HD 3450 board lists the DVI port as HDMI */
  137. if ((dev->pdev->device == 0x95C5) &&
  138. (dev->pdev->subsystem_vendor == 0x1043) &&
  139. (dev->pdev->subsystem_device == 0x01e2)) {
  140. if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) {
  141. *connector_type = DRM_MODE_CONNECTOR_DVII;
  142. }
  143. }
  144. /* some BIOSes seem to report DAC on HDMI - usually this is a board with
  145. * HDMI + VGA reporting as HDMI
  146. */
  147. if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) {
  148. if (supported_device & (ATOM_DEVICE_CRT_SUPPORT)) {
  149. *connector_type = DRM_MODE_CONNECTOR_VGA;
  150. *line_mux = 0;
  151. }
  152. }
  153. return true;
  154. }
  155. const int supported_devices_connector_convert[] = {
  156. DRM_MODE_CONNECTOR_Unknown,
  157. DRM_MODE_CONNECTOR_VGA,
  158. DRM_MODE_CONNECTOR_DVII,
  159. DRM_MODE_CONNECTOR_DVID,
  160. DRM_MODE_CONNECTOR_DVIA,
  161. DRM_MODE_CONNECTOR_SVIDEO,
  162. DRM_MODE_CONNECTOR_Composite,
  163. DRM_MODE_CONNECTOR_LVDS,
  164. DRM_MODE_CONNECTOR_Unknown,
  165. DRM_MODE_CONNECTOR_Unknown,
  166. DRM_MODE_CONNECTOR_HDMIA,
  167. DRM_MODE_CONNECTOR_HDMIB,
  168. DRM_MODE_CONNECTOR_Unknown,
  169. DRM_MODE_CONNECTOR_Unknown,
  170. DRM_MODE_CONNECTOR_9PinDIN,
  171. DRM_MODE_CONNECTOR_DisplayPort
  172. };
  173. const int object_connector_convert[] = {
  174. DRM_MODE_CONNECTOR_Unknown,
  175. DRM_MODE_CONNECTOR_DVII,
  176. DRM_MODE_CONNECTOR_DVII,
  177. DRM_MODE_CONNECTOR_DVID,
  178. DRM_MODE_CONNECTOR_DVID,
  179. DRM_MODE_CONNECTOR_VGA,
  180. DRM_MODE_CONNECTOR_Composite,
  181. DRM_MODE_CONNECTOR_SVIDEO,
  182. DRM_MODE_CONNECTOR_Unknown,
  183. DRM_MODE_CONNECTOR_Unknown,
  184. DRM_MODE_CONNECTOR_9PinDIN,
  185. DRM_MODE_CONNECTOR_Unknown,
  186. DRM_MODE_CONNECTOR_HDMIA,
  187. DRM_MODE_CONNECTOR_HDMIB,
  188. DRM_MODE_CONNECTOR_LVDS,
  189. DRM_MODE_CONNECTOR_9PinDIN,
  190. DRM_MODE_CONNECTOR_Unknown,
  191. DRM_MODE_CONNECTOR_Unknown,
  192. DRM_MODE_CONNECTOR_Unknown,
  193. DRM_MODE_CONNECTOR_DisplayPort
  194. };
  195. bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
  196. {
  197. struct radeon_device *rdev = dev->dev_private;
  198. struct radeon_mode_info *mode_info = &rdev->mode_info;
  199. struct atom_context *ctx = mode_info->atom_context;
  200. int index = GetIndexIntoMasterTable(DATA, Object_Header);
  201. uint16_t size, data_offset;
  202. uint8_t frev, crev, line_mux = 0;
  203. ATOM_CONNECTOR_OBJECT_TABLE *con_obj;
  204. ATOM_DISPLAY_OBJECT_PATH_TABLE *path_obj;
  205. ATOM_OBJECT_HEADER *obj_header;
  206. int i, j, path_size, device_support;
  207. int connector_type;
  208. uint16_t igp_lane_info, conn_id;
  209. bool linkb;
  210. struct radeon_i2c_bus_rec ddc_bus;
  211. atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset);
  212. if (data_offset == 0)
  213. return false;
  214. if (crev < 2)
  215. return false;
  216. obj_header = (ATOM_OBJECT_HEADER *) (ctx->bios + data_offset);
  217. path_obj = (ATOM_DISPLAY_OBJECT_PATH_TABLE *)
  218. (ctx->bios + data_offset +
  219. le16_to_cpu(obj_header->usDisplayPathTableOffset));
  220. con_obj = (ATOM_CONNECTOR_OBJECT_TABLE *)
  221. (ctx->bios + data_offset +
  222. le16_to_cpu(obj_header->usConnectorObjectTableOffset));
  223. device_support = le16_to_cpu(obj_header->usDeviceSupport);
  224. path_size = 0;
  225. for (i = 0; i < path_obj->ucNumOfDispPath; i++) {
  226. uint8_t *addr = (uint8_t *) path_obj->asDispPath;
  227. ATOM_DISPLAY_OBJECT_PATH *path;
  228. addr += path_size;
  229. path = (ATOM_DISPLAY_OBJECT_PATH *) addr;
  230. path_size += le16_to_cpu(path->usSize);
  231. linkb = false;
  232. if (device_support & le16_to_cpu(path->usDeviceTag)) {
  233. uint8_t con_obj_id, con_obj_num, con_obj_type;
  234. con_obj_id =
  235. (le16_to_cpu(path->usConnObjectId) & OBJECT_ID_MASK)
  236. >> OBJECT_ID_SHIFT;
  237. con_obj_num =
  238. (le16_to_cpu(path->usConnObjectId) & ENUM_ID_MASK)
  239. >> ENUM_ID_SHIFT;
  240. con_obj_type =
  241. (le16_to_cpu(path->usConnObjectId) &
  242. OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT;
  243. /* TODO CV support */
  244. if (le16_to_cpu(path->usDeviceTag) ==
  245. ATOM_DEVICE_CV_SUPPORT)
  246. continue;
  247. /* IGP chips */
  248. if ((rdev->flags & RADEON_IS_IGP) &&
  249. (con_obj_id ==
  250. CONNECTOR_OBJECT_ID_PCIE_CONNECTOR)) {
  251. uint16_t igp_offset = 0;
  252. ATOM_INTEGRATED_SYSTEM_INFO_V2 *igp_obj;
  253. index =
  254. GetIndexIntoMasterTable(DATA,
  255. IntegratedSystemInfo);
  256. atom_parse_data_header(ctx, index, &size, &frev,
  257. &crev, &igp_offset);
  258. if (crev >= 2) {
  259. igp_obj =
  260. (ATOM_INTEGRATED_SYSTEM_INFO_V2
  261. *) (ctx->bios + igp_offset);
  262. if (igp_obj) {
  263. uint32_t slot_config, ct;
  264. if (con_obj_num == 1)
  265. slot_config =
  266. igp_obj->
  267. ulDDISlot1Config;
  268. else
  269. slot_config =
  270. igp_obj->
  271. ulDDISlot2Config;
  272. ct = (slot_config >> 16) & 0xff;
  273. connector_type =
  274. object_connector_convert
  275. [ct];
  276. igp_lane_info =
  277. slot_config & 0xffff;
  278. } else
  279. continue;
  280. } else
  281. continue;
  282. } else {
  283. igp_lane_info = 0;
  284. connector_type =
  285. object_connector_convert[con_obj_id];
  286. }
  287. if (connector_type == DRM_MODE_CONNECTOR_Unknown)
  288. continue;
  289. for (j = 0; j < ((le16_to_cpu(path->usSize) - 8) / 2);
  290. j++) {
  291. uint8_t enc_obj_id, enc_obj_num, enc_obj_type;
  292. enc_obj_id =
  293. (le16_to_cpu(path->usGraphicObjIds[j]) &
  294. OBJECT_ID_MASK) >> OBJECT_ID_SHIFT;
  295. enc_obj_num =
  296. (le16_to_cpu(path->usGraphicObjIds[j]) &
  297. ENUM_ID_MASK) >> ENUM_ID_SHIFT;
  298. enc_obj_type =
  299. (le16_to_cpu(path->usGraphicObjIds[j]) &
  300. OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT;
  301. /* FIXME: add support for router objects */
  302. if (enc_obj_type == GRAPH_OBJECT_TYPE_ENCODER) {
  303. if (enc_obj_num == 2)
  304. linkb = true;
  305. else
  306. linkb = false;
  307. radeon_add_atom_encoder(dev,
  308. enc_obj_id,
  309. le16_to_cpu
  310. (path->
  311. usDeviceTag));
  312. }
  313. }
  314. /* look up gpio for ddc */
  315. if ((le16_to_cpu(path->usDeviceTag) &
  316. (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT))
  317. == 0) {
  318. for (j = 0; j < con_obj->ucNumberOfObjects; j++) {
  319. if (le16_to_cpu(path->usConnObjectId) ==
  320. le16_to_cpu(con_obj->asObjects[j].
  321. usObjectID)) {
  322. ATOM_COMMON_RECORD_HEADER
  323. *record =
  324. (ATOM_COMMON_RECORD_HEADER
  325. *)
  326. (ctx->bios + data_offset +
  327. le16_to_cpu(con_obj->
  328. asObjects[j].
  329. usRecordOffset));
  330. ATOM_I2C_RECORD *i2c_record;
  331. while (record->ucRecordType > 0
  332. && record->
  333. ucRecordType <=
  334. ATOM_MAX_OBJECT_RECORD_NUMBER) {
  335. switch (record->
  336. ucRecordType) {
  337. case ATOM_I2C_RECORD_TYPE:
  338. i2c_record =
  339. (ATOM_I2C_RECORD
  340. *) record;
  341. line_mux =
  342. i2c_record->
  343. sucI2cId.
  344. bfI2C_LineMux;
  345. break;
  346. }
  347. record =
  348. (ATOM_COMMON_RECORD_HEADER
  349. *) ((char *)record
  350. +
  351. record->
  352. ucRecordSize);
  353. }
  354. break;
  355. }
  356. }
  357. } else
  358. line_mux = 0;
  359. if ((le16_to_cpu(path->usDeviceTag) ==
  360. ATOM_DEVICE_TV1_SUPPORT)
  361. || (le16_to_cpu(path->usDeviceTag) ==
  362. ATOM_DEVICE_TV2_SUPPORT)
  363. || (le16_to_cpu(path->usDeviceTag) ==
  364. ATOM_DEVICE_CV_SUPPORT))
  365. ddc_bus.valid = false;
  366. else
  367. ddc_bus = radeon_lookup_gpio(dev, line_mux);
  368. conn_id = le16_to_cpu(path->usConnObjectId);
  369. if (!radeon_atom_apply_quirks
  370. (dev, le16_to_cpu(path->usDeviceTag), &connector_type,
  371. &ddc_bus, &conn_id))
  372. continue;
  373. radeon_add_atom_connector(dev,
  374. conn_id,
  375. le16_to_cpu(path->
  376. usDeviceTag),
  377. connector_type, &ddc_bus,
  378. linkb, igp_lane_info);
  379. }
  380. }
  381. radeon_link_encoder_connector(dev);
  382. return true;
  383. }
  384. struct bios_connector {
  385. bool valid;
  386. uint16_t line_mux;
  387. uint16_t devices;
  388. int connector_type;
  389. struct radeon_i2c_bus_rec ddc_bus;
  390. };
  391. bool radeon_get_atom_connector_info_from_supported_devices_table(struct
  392. drm_device
  393. *dev)
  394. {
  395. struct radeon_device *rdev = dev->dev_private;
  396. struct radeon_mode_info *mode_info = &rdev->mode_info;
  397. struct atom_context *ctx = mode_info->atom_context;
  398. int index = GetIndexIntoMasterTable(DATA, SupportedDevicesInfo);
  399. uint16_t size, data_offset;
  400. uint8_t frev, crev;
  401. uint16_t device_support;
  402. uint8_t dac;
  403. union atom_supported_devices *supported_devices;
  404. int i, j;
  405. struct bios_connector bios_connectors[ATOM_MAX_SUPPORTED_DEVICE];
  406. atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset);
  407. supported_devices =
  408. (union atom_supported_devices *)(ctx->bios + data_offset);
  409. device_support = le16_to_cpu(supported_devices->info.usDeviceSupport);
  410. for (i = 0; i < ATOM_MAX_SUPPORTED_DEVICE; i++) {
  411. ATOM_CONNECTOR_INFO_I2C ci =
  412. supported_devices->info.asConnInfo[i];
  413. bios_connectors[i].valid = false;
  414. if (!(device_support & (1 << i))) {
  415. continue;
  416. }
  417. if (i == ATOM_DEVICE_CV_INDEX) {
  418. DRM_DEBUG("Skipping Component Video\n");
  419. continue;
  420. }
  421. bios_connectors[i].connector_type =
  422. supported_devices_connector_convert[ci.sucConnectorInfo.
  423. sbfAccess.
  424. bfConnectorType];
  425. if (bios_connectors[i].connector_type ==
  426. DRM_MODE_CONNECTOR_Unknown)
  427. continue;
  428. dac = ci.sucConnectorInfo.sbfAccess.bfAssociatedDAC;
  429. if ((rdev->family == CHIP_RS690) ||
  430. (rdev->family == CHIP_RS740)) {
  431. if ((i == ATOM_DEVICE_DFP2_INDEX)
  432. && (ci.sucI2cId.sbfAccess.bfI2C_LineMux == 2))
  433. bios_connectors[i].line_mux =
  434. ci.sucI2cId.sbfAccess.bfI2C_LineMux + 1;
  435. else if ((i == ATOM_DEVICE_DFP3_INDEX)
  436. && (ci.sucI2cId.sbfAccess.bfI2C_LineMux == 1))
  437. bios_connectors[i].line_mux =
  438. ci.sucI2cId.sbfAccess.bfI2C_LineMux + 1;
  439. else
  440. bios_connectors[i].line_mux =
  441. ci.sucI2cId.sbfAccess.bfI2C_LineMux;
  442. } else
  443. bios_connectors[i].line_mux =
  444. ci.sucI2cId.sbfAccess.bfI2C_LineMux;
  445. /* give tv unique connector ids */
  446. if (i == ATOM_DEVICE_TV1_INDEX) {
  447. bios_connectors[i].ddc_bus.valid = false;
  448. bios_connectors[i].line_mux = 50;
  449. } else if (i == ATOM_DEVICE_TV2_INDEX) {
  450. bios_connectors[i].ddc_bus.valid = false;
  451. bios_connectors[i].line_mux = 51;
  452. } else if (i == ATOM_DEVICE_CV_INDEX) {
  453. bios_connectors[i].ddc_bus.valid = false;
  454. bios_connectors[i].line_mux = 52;
  455. } else
  456. bios_connectors[i].ddc_bus =
  457. radeon_lookup_gpio(dev,
  458. bios_connectors[i].line_mux);
  459. /* Always set the connector type to VGA for CRT1/CRT2. if they are
  460. * shared with a DVI port, we'll pick up the DVI connector when we
  461. * merge the outputs. Some bioses incorrectly list VGA ports as DVI.
  462. */
  463. if (i == ATOM_DEVICE_CRT1_INDEX || i == ATOM_DEVICE_CRT2_INDEX)
  464. bios_connectors[i].connector_type =
  465. DRM_MODE_CONNECTOR_VGA;
  466. if (!radeon_atom_apply_quirks
  467. (dev, (1 << i), &bios_connectors[i].connector_type,
  468. &bios_connectors[i].ddc_bus, &bios_connectors[i].line_mux))
  469. continue;
  470. bios_connectors[i].valid = true;
  471. bios_connectors[i].devices = (1 << i);
  472. if (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom)
  473. radeon_add_atom_encoder(dev,
  474. radeon_get_encoder_id(dev,
  475. (1 << i),
  476. dac),
  477. (1 << i));
  478. else
  479. radeon_add_legacy_encoder(dev,
  480. radeon_get_encoder_id(dev,
  481. (1 <<
  482. i),
  483. dac),
  484. (1 << i));
  485. }
  486. /* combine shared connectors */
  487. for (i = 0; i < ATOM_MAX_SUPPORTED_DEVICE; i++) {
  488. if (bios_connectors[i].valid) {
  489. for (j = 0; j < ATOM_MAX_SUPPORTED_DEVICE; j++) {
  490. if (bios_connectors[j].valid && (i != j)) {
  491. if (bios_connectors[i].line_mux ==
  492. bios_connectors[j].line_mux) {
  493. if (((bios_connectors[i].
  494. devices &
  495. (ATOM_DEVICE_DFP_SUPPORT))
  496. && (bios_connectors[j].
  497. devices &
  498. (ATOM_DEVICE_CRT_SUPPORT)))
  499. ||
  500. ((bios_connectors[j].
  501. devices &
  502. (ATOM_DEVICE_DFP_SUPPORT))
  503. && (bios_connectors[i].
  504. devices &
  505. (ATOM_DEVICE_CRT_SUPPORT)))) {
  506. bios_connectors[i].
  507. devices |=
  508. bios_connectors[j].
  509. devices;
  510. bios_connectors[i].
  511. connector_type =
  512. DRM_MODE_CONNECTOR_DVII;
  513. bios_connectors[j].
  514. valid = false;
  515. }
  516. }
  517. }
  518. }
  519. }
  520. }
  521. /* add the connectors */
  522. for (i = 0; i < ATOM_MAX_SUPPORTED_DEVICE; i++) {
  523. if (bios_connectors[i].valid)
  524. radeon_add_atom_connector(dev,
  525. bios_connectors[i].line_mux,
  526. bios_connectors[i].devices,
  527. bios_connectors[i].
  528. connector_type,
  529. &bios_connectors[i].ddc_bus,
  530. false, 0);
  531. }
  532. radeon_link_encoder_connector(dev);
  533. return true;
  534. }
  535. union firmware_info {
  536. ATOM_FIRMWARE_INFO info;
  537. ATOM_FIRMWARE_INFO_V1_2 info_12;
  538. ATOM_FIRMWARE_INFO_V1_3 info_13;
  539. ATOM_FIRMWARE_INFO_V1_4 info_14;
  540. };
  541. bool radeon_atom_get_clock_info(struct drm_device *dev)
  542. {
  543. struct radeon_device *rdev = dev->dev_private;
  544. struct radeon_mode_info *mode_info = &rdev->mode_info;
  545. int index = GetIndexIntoMasterTable(DATA, FirmwareInfo);
  546. union firmware_info *firmware_info;
  547. uint8_t frev, crev;
  548. struct radeon_pll *p1pll = &rdev->clock.p1pll;
  549. struct radeon_pll *p2pll = &rdev->clock.p2pll;
  550. struct radeon_pll *spll = &rdev->clock.spll;
  551. struct radeon_pll *mpll = &rdev->clock.mpll;
  552. uint16_t data_offset;
  553. atom_parse_data_header(mode_info->atom_context, index, NULL, &frev,
  554. &crev, &data_offset);
  555. firmware_info =
  556. (union firmware_info *)(mode_info->atom_context->bios +
  557. data_offset);
  558. if (firmware_info) {
  559. /* pixel clocks */
  560. p1pll->reference_freq =
  561. le16_to_cpu(firmware_info->info.usReferenceClock);
  562. p1pll->reference_div = 0;
  563. if (crev < 2)
  564. p1pll->pll_out_min =
  565. le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Output);
  566. else
  567. p1pll->pll_out_min =
  568. le32_to_cpu(firmware_info->info_12.ulMinPixelClockPLL_Output);
  569. p1pll->pll_out_max =
  570. le32_to_cpu(firmware_info->info.ulMaxPixelClockPLL_Output);
  571. if (p1pll->pll_out_min == 0) {
  572. if (ASIC_IS_AVIVO(rdev))
  573. p1pll->pll_out_min = 64800;
  574. else
  575. p1pll->pll_out_min = 20000;
  576. } else if (p1pll->pll_out_min > 64800) {
  577. /* Limiting the pll output range is a good thing generally as
  578. * it limits the number of possible pll combinations for a given
  579. * frequency presumably to the ones that work best on each card.
  580. * However, certain duallink DVI monitors seem to like
  581. * pll combinations that would be limited by this at least on
  582. * pre-DCE 3.0 r6xx hardware. This might need to be adjusted per
  583. * family.
  584. */
  585. p1pll->pll_out_min = 64800;
  586. }
  587. p1pll->pll_in_min =
  588. le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Input);
  589. p1pll->pll_in_max =
  590. le16_to_cpu(firmware_info->info.usMaxPixelClockPLL_Input);
  591. *p2pll = *p1pll;
  592. /* system clock */
  593. spll->reference_freq =
  594. le16_to_cpu(firmware_info->info.usReferenceClock);
  595. spll->reference_div = 0;
  596. spll->pll_out_min =
  597. le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Output);
  598. spll->pll_out_max =
  599. le32_to_cpu(firmware_info->info.ulMaxEngineClockPLL_Output);
  600. /* ??? */
  601. if (spll->pll_out_min == 0) {
  602. if (ASIC_IS_AVIVO(rdev))
  603. spll->pll_out_min = 64800;
  604. else
  605. spll->pll_out_min = 20000;
  606. }
  607. spll->pll_in_min =
  608. le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Input);
  609. spll->pll_in_max =
  610. le16_to_cpu(firmware_info->info.usMaxEngineClockPLL_Input);
  611. /* memory clock */
  612. mpll->reference_freq =
  613. le16_to_cpu(firmware_info->info.usReferenceClock);
  614. mpll->reference_div = 0;
  615. mpll->pll_out_min =
  616. le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Output);
  617. mpll->pll_out_max =
  618. le32_to_cpu(firmware_info->info.ulMaxMemoryClockPLL_Output);
  619. /* ??? */
  620. if (mpll->pll_out_min == 0) {
  621. if (ASIC_IS_AVIVO(rdev))
  622. mpll->pll_out_min = 64800;
  623. else
  624. mpll->pll_out_min = 20000;
  625. }
  626. mpll->pll_in_min =
  627. le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Input);
  628. mpll->pll_in_max =
  629. le16_to_cpu(firmware_info->info.usMaxMemoryClockPLL_Input);
  630. rdev->clock.default_sclk =
  631. le32_to_cpu(firmware_info->info.ulDefaultEngineClock);
  632. rdev->clock.default_mclk =
  633. le32_to_cpu(firmware_info->info.ulDefaultMemoryClock);
  634. return true;
  635. }
  636. return false;
  637. }
  638. bool radeon_atombios_get_tmds_info(struct radeon_encoder *encoder,
  639. struct radeon_encoder_int_tmds *tmds)
  640. {
  641. struct drm_device *dev = encoder->base.dev;
  642. struct radeon_device *rdev = dev->dev_private;
  643. struct radeon_mode_info *mode_info = &rdev->mode_info;
  644. int index = GetIndexIntoMasterTable(DATA, TMDS_Info);
  645. uint16_t data_offset;
  646. struct _ATOM_TMDS_INFO *tmds_info;
  647. uint8_t frev, crev;
  648. uint16_t maxfreq;
  649. int i;
  650. atom_parse_data_header(mode_info->atom_context, index, NULL, &frev,
  651. &crev, &data_offset);
  652. tmds_info =
  653. (struct _ATOM_TMDS_INFO *)(mode_info->atom_context->bios +
  654. data_offset);
  655. if (tmds_info) {
  656. maxfreq = le16_to_cpu(tmds_info->usMaxFrequency);
  657. for (i = 0; i < 4; i++) {
  658. tmds->tmds_pll[i].freq =
  659. le16_to_cpu(tmds_info->asMiscInfo[i].usFrequency);
  660. tmds->tmds_pll[i].value =
  661. tmds_info->asMiscInfo[i].ucPLL_ChargePump & 0x3f;
  662. tmds->tmds_pll[i].value |=
  663. (tmds_info->asMiscInfo[i].
  664. ucPLL_VCO_Gain & 0x3f) << 6;
  665. tmds->tmds_pll[i].value |=
  666. (tmds_info->asMiscInfo[i].
  667. ucPLL_DutyCycle & 0xf) << 12;
  668. tmds->tmds_pll[i].value |=
  669. (tmds_info->asMiscInfo[i].
  670. ucPLL_VoltageSwing & 0xf) << 16;
  671. DRM_DEBUG("TMDS PLL From ATOMBIOS %u %x\n",
  672. tmds->tmds_pll[i].freq,
  673. tmds->tmds_pll[i].value);
  674. if (maxfreq == tmds->tmds_pll[i].freq) {
  675. tmds->tmds_pll[i].freq = 0xffffffff;
  676. break;
  677. }
  678. }
  679. return true;
  680. }
  681. return false;
  682. }
  683. static struct radeon_atom_ss *radeon_atombios_get_ss_info(struct
  684. radeon_encoder
  685. *encoder,
  686. int id)
  687. {
  688. struct drm_device *dev = encoder->base.dev;
  689. struct radeon_device *rdev = dev->dev_private;
  690. struct radeon_mode_info *mode_info = &rdev->mode_info;
  691. int index = GetIndexIntoMasterTable(DATA, PPLL_SS_Info);
  692. uint16_t data_offset;
  693. struct _ATOM_SPREAD_SPECTRUM_INFO *ss_info;
  694. uint8_t frev, crev;
  695. struct radeon_atom_ss *ss = NULL;
  696. if (id > ATOM_MAX_SS_ENTRY)
  697. return NULL;
  698. atom_parse_data_header(mode_info->atom_context, index, NULL, &frev,
  699. &crev, &data_offset);
  700. ss_info =
  701. (struct _ATOM_SPREAD_SPECTRUM_INFO *)(mode_info->atom_context->bios + data_offset);
  702. if (ss_info) {
  703. ss =
  704. kzalloc(sizeof(struct radeon_atom_ss), GFP_KERNEL);
  705. if (!ss)
  706. return NULL;
  707. ss->percentage = le16_to_cpu(ss_info->asSS_Info[id].usSpreadSpectrumPercentage);
  708. ss->type = ss_info->asSS_Info[id].ucSpreadSpectrumType;
  709. ss->step = ss_info->asSS_Info[id].ucSS_Step;
  710. ss->delay = ss_info->asSS_Info[id].ucSS_Delay;
  711. ss->range = ss_info->asSS_Info[id].ucSS_Range;
  712. ss->refdiv = ss_info->asSS_Info[id].ucRecommendedRef_Div;
  713. }
  714. return ss;
  715. }
  716. union lvds_info {
  717. struct _ATOM_LVDS_INFO info;
  718. struct _ATOM_LVDS_INFO_V12 info_12;
  719. };
  720. struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct
  721. radeon_encoder
  722. *encoder)
  723. {
  724. struct drm_device *dev = encoder->base.dev;
  725. struct radeon_device *rdev = dev->dev_private;
  726. struct radeon_mode_info *mode_info = &rdev->mode_info;
  727. int index = GetIndexIntoMasterTable(DATA, LVDS_Info);
  728. uint16_t data_offset;
  729. union lvds_info *lvds_info;
  730. uint8_t frev, crev;
  731. struct radeon_encoder_atom_dig *lvds = NULL;
  732. atom_parse_data_header(mode_info->atom_context, index, NULL, &frev,
  733. &crev, &data_offset);
  734. lvds_info =
  735. (union lvds_info *)(mode_info->atom_context->bios + data_offset);
  736. if (lvds_info) {
  737. lvds =
  738. kzalloc(sizeof(struct radeon_encoder_atom_dig), GFP_KERNEL);
  739. if (!lvds)
  740. return NULL;
  741. lvds->native_mode.clock =
  742. le16_to_cpu(lvds_info->info.sLCDTiming.usPixClk) * 10;
  743. lvds->native_mode.hdisplay =
  744. le16_to_cpu(lvds_info->info.sLCDTiming.usHActive);
  745. lvds->native_mode.vdisplay =
  746. le16_to_cpu(lvds_info->info.sLCDTiming.usVActive);
  747. lvds->native_mode.htotal = lvds->native_mode.hdisplay +
  748. le16_to_cpu(lvds_info->info.sLCDTiming.usHBlanking_Time);
  749. lvds->native_mode.hsync_start = lvds->native_mode.hdisplay +
  750. le16_to_cpu(lvds_info->info.sLCDTiming.usHSyncOffset);
  751. lvds->native_mode.hsync_end = lvds->native_mode.hsync_start +
  752. le16_to_cpu(lvds_info->info.sLCDTiming.usHSyncWidth);
  753. lvds->native_mode.vtotal = lvds->native_mode.vdisplay +
  754. le16_to_cpu(lvds_info->info.sLCDTiming.usVBlanking_Time);
  755. lvds->native_mode.vsync_start = lvds->native_mode.vdisplay +
  756. le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncWidth);
  757. lvds->native_mode.vsync_end = lvds->native_mode.vsync_start +
  758. le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncWidth);
  759. lvds->panel_pwr_delay =
  760. le16_to_cpu(lvds_info->info.usOffDelayInMs);
  761. lvds->lvds_misc = lvds_info->info.ucLVDS_Misc;
  762. /* set crtc values */
  763. drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V);
  764. lvds->ss = radeon_atombios_get_ss_info(encoder, lvds_info->info.ucSS_Id);
  765. encoder->native_mode = lvds->native_mode;
  766. }
  767. return lvds;
  768. }
  769. struct radeon_encoder_primary_dac *
  770. radeon_atombios_get_primary_dac_info(struct radeon_encoder *encoder)
  771. {
  772. struct drm_device *dev = encoder->base.dev;
  773. struct radeon_device *rdev = dev->dev_private;
  774. struct radeon_mode_info *mode_info = &rdev->mode_info;
  775. int index = GetIndexIntoMasterTable(DATA, CompassionateData);
  776. uint16_t data_offset;
  777. struct _COMPASSIONATE_DATA *dac_info;
  778. uint8_t frev, crev;
  779. uint8_t bg, dac;
  780. struct radeon_encoder_primary_dac *p_dac = NULL;
  781. atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset);
  782. dac_info = (struct _COMPASSIONATE_DATA *)(mode_info->atom_context->bios + data_offset);
  783. if (dac_info) {
  784. p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), GFP_KERNEL);
  785. if (!p_dac)
  786. return NULL;
  787. bg = dac_info->ucDAC1_BG_Adjustment;
  788. dac = dac_info->ucDAC1_DAC_Adjustment;
  789. p_dac->ps2_pdac_adj = (bg << 8) | (dac);
  790. }
  791. return p_dac;
  792. }
  793. bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index,
  794. struct drm_display_mode *mode)
  795. {
  796. struct radeon_mode_info *mode_info = &rdev->mode_info;
  797. ATOM_ANALOG_TV_INFO *tv_info;
  798. ATOM_ANALOG_TV_INFO_V1_2 *tv_info_v1_2;
  799. ATOM_DTD_FORMAT *dtd_timings;
  800. int data_index = GetIndexIntoMasterTable(DATA, AnalogTV_Info);
  801. u8 frev, crev;
  802. u16 data_offset, misc;
  803. atom_parse_data_header(mode_info->atom_context, data_index, NULL, &frev, &crev, &data_offset);
  804. switch (crev) {
  805. case 1:
  806. tv_info = (ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset);
  807. if (index > MAX_SUPPORTED_TV_TIMING)
  808. return false;
  809. mode->crtc_htotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Total);
  810. mode->crtc_hdisplay = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Disp);
  811. mode->crtc_hsync_start = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncStart);
  812. mode->crtc_hsync_end = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncStart) +
  813. le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncWidth);
  814. mode->crtc_vtotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_Total);
  815. mode->crtc_vdisplay = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_Disp);
  816. mode->crtc_vsync_start = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncStart);
  817. mode->crtc_vsync_end = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncStart) +
  818. le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncWidth);
  819. mode->flags = 0;
  820. misc = le16_to_cpu(tv_info->aModeTimings[index].susModeMiscInfo.usAccess);
  821. if (misc & ATOM_VSYNC_POLARITY)
  822. mode->flags |= DRM_MODE_FLAG_NVSYNC;
  823. if (misc & ATOM_HSYNC_POLARITY)
  824. mode->flags |= DRM_MODE_FLAG_NHSYNC;
  825. if (misc & ATOM_COMPOSITESYNC)
  826. mode->flags |= DRM_MODE_FLAG_CSYNC;
  827. if (misc & ATOM_INTERLACE)
  828. mode->flags |= DRM_MODE_FLAG_INTERLACE;
  829. if (misc & ATOM_DOUBLE_CLOCK_MODE)
  830. mode->flags |= DRM_MODE_FLAG_DBLSCAN;
  831. mode->clock = le16_to_cpu(tv_info->aModeTimings[index].usPixelClock) * 10;
  832. if (index == 1) {
  833. /* PAL timings appear to have wrong values for totals */
  834. mode->crtc_htotal -= 1;
  835. mode->crtc_vtotal -= 1;
  836. }
  837. break;
  838. case 2:
  839. tv_info_v1_2 = (ATOM_ANALOG_TV_INFO_V1_2 *)(mode_info->atom_context->bios + data_offset);
  840. if (index > MAX_SUPPORTED_TV_TIMING_V1_2)
  841. return false;
  842. dtd_timings = &tv_info_v1_2->aModeTimings[index];
  843. mode->crtc_htotal = le16_to_cpu(dtd_timings->usHActive) +
  844. le16_to_cpu(dtd_timings->usHBlanking_Time);
  845. mode->crtc_hdisplay = le16_to_cpu(dtd_timings->usHActive);
  846. mode->crtc_hsync_start = le16_to_cpu(dtd_timings->usHActive) +
  847. le16_to_cpu(dtd_timings->usHSyncOffset);
  848. mode->crtc_hsync_end = mode->crtc_hsync_start +
  849. le16_to_cpu(dtd_timings->usHSyncWidth);
  850. mode->crtc_vtotal = le16_to_cpu(dtd_timings->usVActive) +
  851. le16_to_cpu(dtd_timings->usVBlanking_Time);
  852. mode->crtc_vdisplay = le16_to_cpu(dtd_timings->usVActive);
  853. mode->crtc_vsync_start = le16_to_cpu(dtd_timings->usVActive) +
  854. le16_to_cpu(dtd_timings->usVSyncOffset);
  855. mode->crtc_vsync_end = mode->crtc_vsync_start +
  856. le16_to_cpu(dtd_timings->usVSyncWidth);
  857. mode->flags = 0;
  858. misc = le16_to_cpu(dtd_timings->susModeMiscInfo.usAccess);
  859. if (misc & ATOM_VSYNC_POLARITY)
  860. mode->flags |= DRM_MODE_FLAG_NVSYNC;
  861. if (misc & ATOM_HSYNC_POLARITY)
  862. mode->flags |= DRM_MODE_FLAG_NHSYNC;
  863. if (misc & ATOM_COMPOSITESYNC)
  864. mode->flags |= DRM_MODE_FLAG_CSYNC;
  865. if (misc & ATOM_INTERLACE)
  866. mode->flags |= DRM_MODE_FLAG_INTERLACE;
  867. if (misc & ATOM_DOUBLE_CLOCK_MODE)
  868. mode->flags |= DRM_MODE_FLAG_DBLSCAN;
  869. mode->clock = le16_to_cpu(dtd_timings->usPixClk) * 10;
  870. break;
  871. }
  872. return true;
  873. }
  874. struct radeon_encoder_tv_dac *
  875. radeon_atombios_get_tv_dac_info(struct radeon_encoder *encoder)
  876. {
  877. struct drm_device *dev = encoder->base.dev;
  878. struct radeon_device *rdev = dev->dev_private;
  879. struct radeon_mode_info *mode_info = &rdev->mode_info;
  880. int index = GetIndexIntoMasterTable(DATA, CompassionateData);
  881. uint16_t data_offset;
  882. struct _COMPASSIONATE_DATA *dac_info;
  883. uint8_t frev, crev;
  884. uint8_t bg, dac;
  885. struct radeon_encoder_tv_dac *tv_dac = NULL;
  886. atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset);
  887. dac_info = (struct _COMPASSIONATE_DATA *)(mode_info->atom_context->bios + data_offset);
  888. if (dac_info) {
  889. tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
  890. if (!tv_dac)
  891. return NULL;
  892. bg = dac_info->ucDAC2_CRT2_BG_Adjustment;
  893. dac = dac_info->ucDAC2_CRT2_DAC_Adjustment;
  894. tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
  895. bg = dac_info->ucDAC2_PAL_BG_Adjustment;
  896. dac = dac_info->ucDAC2_PAL_DAC_Adjustment;
  897. tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
  898. bg = dac_info->ucDAC2_NTSC_BG_Adjustment;
  899. dac = dac_info->ucDAC2_NTSC_DAC_Adjustment;
  900. tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
  901. }
  902. return tv_dac;
  903. }
  904. void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable)
  905. {
  906. DYNAMIC_CLOCK_GATING_PS_ALLOCATION args;
  907. int index = GetIndexIntoMasterTable(COMMAND, DynamicClockGating);
  908. args.ucEnable = enable;
  909. atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
  910. }
  911. void radeon_atom_static_pwrmgt_setup(struct radeon_device *rdev, int enable)
  912. {
  913. ENABLE_ASIC_STATIC_PWR_MGT_PS_ALLOCATION args;
  914. int index = GetIndexIntoMasterTable(COMMAND, EnableASIC_StaticPwrMgt);
  915. args.ucEnable = enable;
  916. atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
  917. }
  918. void radeon_atom_set_engine_clock(struct radeon_device *rdev,
  919. uint32_t eng_clock)
  920. {
  921. SET_ENGINE_CLOCK_PS_ALLOCATION args;
  922. int index = GetIndexIntoMasterTable(COMMAND, SetEngineClock);
  923. args.ulTargetEngineClock = eng_clock; /* 10 khz */
  924. atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
  925. }
  926. void radeon_atom_set_memory_clock(struct radeon_device *rdev,
  927. uint32_t mem_clock)
  928. {
  929. SET_MEMORY_CLOCK_PS_ALLOCATION args;
  930. int index = GetIndexIntoMasterTable(COMMAND, SetMemoryClock);
  931. if (rdev->flags & RADEON_IS_IGP)
  932. return;
  933. args.ulTargetMemoryClock = mem_clock; /* 10 khz */
  934. atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
  935. }
  936. void radeon_atom_initialize_bios_scratch_regs(struct drm_device *dev)
  937. {
  938. struct radeon_device *rdev = dev->dev_private;
  939. uint32_t bios_2_scratch, bios_6_scratch;
  940. if (rdev->family >= CHIP_R600) {
  941. bios_2_scratch = RREG32(R600_BIOS_2_SCRATCH);
  942. bios_6_scratch = RREG32(R600_BIOS_6_SCRATCH);
  943. } else {
  944. bios_2_scratch = RREG32(RADEON_BIOS_2_SCRATCH);
  945. bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
  946. }
  947. /* let the bios control the backlight */
  948. bios_2_scratch &= ~ATOM_S2_VRI_BRIGHT_ENABLE;
  949. /* tell the bios not to handle mode switching */
  950. bios_6_scratch |= (ATOM_S6_ACC_BLOCK_DISPLAY_SWITCH | ATOM_S6_ACC_MODE);
  951. if (rdev->family >= CHIP_R600) {
  952. WREG32(R600_BIOS_2_SCRATCH, bios_2_scratch);
  953. WREG32(R600_BIOS_6_SCRATCH, bios_6_scratch);
  954. } else {
  955. WREG32(RADEON_BIOS_2_SCRATCH, bios_2_scratch);
  956. WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
  957. }
  958. }
  959. void radeon_save_bios_scratch_regs(struct radeon_device *rdev)
  960. {
  961. uint32_t scratch_reg;
  962. int i;
  963. if (rdev->family >= CHIP_R600)
  964. scratch_reg = R600_BIOS_0_SCRATCH;
  965. else
  966. scratch_reg = RADEON_BIOS_0_SCRATCH;
  967. for (i = 0; i < RADEON_BIOS_NUM_SCRATCH; i++)
  968. rdev->bios_scratch[i] = RREG32(scratch_reg + (i * 4));
  969. }
  970. void radeon_restore_bios_scratch_regs(struct radeon_device *rdev)
  971. {
  972. uint32_t scratch_reg;
  973. int i;
  974. if (rdev->family >= CHIP_R600)
  975. scratch_reg = R600_BIOS_0_SCRATCH;
  976. else
  977. scratch_reg = RADEON_BIOS_0_SCRATCH;
  978. for (i = 0; i < RADEON_BIOS_NUM_SCRATCH; i++)
  979. WREG32(scratch_reg + (i * 4), rdev->bios_scratch[i]);
  980. }
  981. void radeon_atom_output_lock(struct drm_encoder *encoder, bool lock)
  982. {
  983. struct drm_device *dev = encoder->dev;
  984. struct radeon_device *rdev = dev->dev_private;
  985. uint32_t bios_6_scratch;
  986. if (rdev->family >= CHIP_R600)
  987. bios_6_scratch = RREG32(R600_BIOS_6_SCRATCH);
  988. else
  989. bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
  990. if (lock)
  991. bios_6_scratch |= ATOM_S6_CRITICAL_STATE;
  992. else
  993. bios_6_scratch &= ~ATOM_S6_CRITICAL_STATE;
  994. if (rdev->family >= CHIP_R600)
  995. WREG32(R600_BIOS_6_SCRATCH, bios_6_scratch);
  996. else
  997. WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
  998. }
  999. /* at some point we may want to break this out into individual functions */
  1000. void
  1001. radeon_atombios_connected_scratch_regs(struct drm_connector *connector,
  1002. struct drm_encoder *encoder,
  1003. bool connected)
  1004. {
  1005. struct drm_device *dev = connector->dev;
  1006. struct radeon_device *rdev = dev->dev_private;
  1007. struct radeon_connector *radeon_connector =
  1008. to_radeon_connector(connector);
  1009. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  1010. uint32_t bios_0_scratch, bios_3_scratch, bios_6_scratch;
  1011. if (rdev->family >= CHIP_R600) {
  1012. bios_0_scratch = RREG32(R600_BIOS_0_SCRATCH);
  1013. bios_3_scratch = RREG32(R600_BIOS_3_SCRATCH);
  1014. bios_6_scratch = RREG32(R600_BIOS_6_SCRATCH);
  1015. } else {
  1016. bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH);
  1017. bios_3_scratch = RREG32(RADEON_BIOS_3_SCRATCH);
  1018. bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
  1019. }
  1020. if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) &&
  1021. (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) {
  1022. if (connected) {
  1023. DRM_DEBUG("TV1 connected\n");
  1024. bios_3_scratch |= ATOM_S3_TV1_ACTIVE;
  1025. bios_6_scratch |= ATOM_S6_ACC_REQ_TV1;
  1026. } else {
  1027. DRM_DEBUG("TV1 disconnected\n");
  1028. bios_0_scratch &= ~ATOM_S0_TV1_MASK;
  1029. bios_3_scratch &= ~ATOM_S3_TV1_ACTIVE;
  1030. bios_6_scratch &= ~ATOM_S6_ACC_REQ_TV1;
  1031. }
  1032. }
  1033. if ((radeon_encoder->devices & ATOM_DEVICE_CV_SUPPORT) &&
  1034. (radeon_connector->devices & ATOM_DEVICE_CV_SUPPORT)) {
  1035. if (connected) {
  1036. DRM_DEBUG("CV connected\n");
  1037. bios_3_scratch |= ATOM_S3_CV_ACTIVE;
  1038. bios_6_scratch |= ATOM_S6_ACC_REQ_CV;
  1039. } else {
  1040. DRM_DEBUG("CV disconnected\n");
  1041. bios_0_scratch &= ~ATOM_S0_CV_MASK;
  1042. bios_3_scratch &= ~ATOM_S3_CV_ACTIVE;
  1043. bios_6_scratch &= ~ATOM_S6_ACC_REQ_CV;
  1044. }
  1045. }
  1046. if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) &&
  1047. (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) {
  1048. if (connected) {
  1049. DRM_DEBUG("LCD1 connected\n");
  1050. bios_0_scratch |= ATOM_S0_LCD1;
  1051. bios_3_scratch |= ATOM_S3_LCD1_ACTIVE;
  1052. bios_6_scratch |= ATOM_S6_ACC_REQ_LCD1;
  1053. } else {
  1054. DRM_DEBUG("LCD1 disconnected\n");
  1055. bios_0_scratch &= ~ATOM_S0_LCD1;
  1056. bios_3_scratch &= ~ATOM_S3_LCD1_ACTIVE;
  1057. bios_6_scratch &= ~ATOM_S6_ACC_REQ_LCD1;
  1058. }
  1059. }
  1060. if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) &&
  1061. (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) {
  1062. if (connected) {
  1063. DRM_DEBUG("CRT1 connected\n");
  1064. bios_0_scratch |= ATOM_S0_CRT1_COLOR;
  1065. bios_3_scratch |= ATOM_S3_CRT1_ACTIVE;
  1066. bios_6_scratch |= ATOM_S6_ACC_REQ_CRT1;
  1067. } else {
  1068. DRM_DEBUG("CRT1 disconnected\n");
  1069. bios_0_scratch &= ~ATOM_S0_CRT1_MASK;
  1070. bios_3_scratch &= ~ATOM_S3_CRT1_ACTIVE;
  1071. bios_6_scratch &= ~ATOM_S6_ACC_REQ_CRT1;
  1072. }
  1073. }
  1074. if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) &&
  1075. (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) {
  1076. if (connected) {
  1077. DRM_DEBUG("CRT2 connected\n");
  1078. bios_0_scratch |= ATOM_S0_CRT2_COLOR;
  1079. bios_3_scratch |= ATOM_S3_CRT2_ACTIVE;
  1080. bios_6_scratch |= ATOM_S6_ACC_REQ_CRT2;
  1081. } else {
  1082. DRM_DEBUG("CRT2 disconnected\n");
  1083. bios_0_scratch &= ~ATOM_S0_CRT2_MASK;
  1084. bios_3_scratch &= ~ATOM_S3_CRT2_ACTIVE;
  1085. bios_6_scratch &= ~ATOM_S6_ACC_REQ_CRT2;
  1086. }
  1087. }
  1088. if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) &&
  1089. (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) {
  1090. if (connected) {
  1091. DRM_DEBUG("DFP1 connected\n");
  1092. bios_0_scratch |= ATOM_S0_DFP1;
  1093. bios_3_scratch |= ATOM_S3_DFP1_ACTIVE;
  1094. bios_6_scratch |= ATOM_S6_ACC_REQ_DFP1;
  1095. } else {
  1096. DRM_DEBUG("DFP1 disconnected\n");
  1097. bios_0_scratch &= ~ATOM_S0_DFP1;
  1098. bios_3_scratch &= ~ATOM_S3_DFP1_ACTIVE;
  1099. bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP1;
  1100. }
  1101. }
  1102. if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) &&
  1103. (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) {
  1104. if (connected) {
  1105. DRM_DEBUG("DFP2 connected\n");
  1106. bios_0_scratch |= ATOM_S0_DFP2;
  1107. bios_3_scratch |= ATOM_S3_DFP2_ACTIVE;
  1108. bios_6_scratch |= ATOM_S6_ACC_REQ_DFP2;
  1109. } else {
  1110. DRM_DEBUG("DFP2 disconnected\n");
  1111. bios_0_scratch &= ~ATOM_S0_DFP2;
  1112. bios_3_scratch &= ~ATOM_S3_DFP2_ACTIVE;
  1113. bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP2;
  1114. }
  1115. }
  1116. if ((radeon_encoder->devices & ATOM_DEVICE_DFP3_SUPPORT) &&
  1117. (radeon_connector->devices & ATOM_DEVICE_DFP3_SUPPORT)) {
  1118. if (connected) {
  1119. DRM_DEBUG("DFP3 connected\n");
  1120. bios_0_scratch |= ATOM_S0_DFP3;
  1121. bios_3_scratch |= ATOM_S3_DFP3_ACTIVE;
  1122. bios_6_scratch |= ATOM_S6_ACC_REQ_DFP3;
  1123. } else {
  1124. DRM_DEBUG("DFP3 disconnected\n");
  1125. bios_0_scratch &= ~ATOM_S0_DFP3;
  1126. bios_3_scratch &= ~ATOM_S3_DFP3_ACTIVE;
  1127. bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP3;
  1128. }
  1129. }
  1130. if ((radeon_encoder->devices & ATOM_DEVICE_DFP4_SUPPORT) &&
  1131. (radeon_connector->devices & ATOM_DEVICE_DFP4_SUPPORT)) {
  1132. if (connected) {
  1133. DRM_DEBUG("DFP4 connected\n");
  1134. bios_0_scratch |= ATOM_S0_DFP4;
  1135. bios_3_scratch |= ATOM_S3_DFP4_ACTIVE;
  1136. bios_6_scratch |= ATOM_S6_ACC_REQ_DFP4;
  1137. } else {
  1138. DRM_DEBUG("DFP4 disconnected\n");
  1139. bios_0_scratch &= ~ATOM_S0_DFP4;
  1140. bios_3_scratch &= ~ATOM_S3_DFP4_ACTIVE;
  1141. bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP4;
  1142. }
  1143. }
  1144. if ((radeon_encoder->devices & ATOM_DEVICE_DFP5_SUPPORT) &&
  1145. (radeon_connector->devices & ATOM_DEVICE_DFP5_SUPPORT)) {
  1146. if (connected) {
  1147. DRM_DEBUG("DFP5 connected\n");
  1148. bios_0_scratch |= ATOM_S0_DFP5;
  1149. bios_3_scratch |= ATOM_S3_DFP5_ACTIVE;
  1150. bios_6_scratch |= ATOM_S6_ACC_REQ_DFP5;
  1151. } else {
  1152. DRM_DEBUG("DFP5 disconnected\n");
  1153. bios_0_scratch &= ~ATOM_S0_DFP5;
  1154. bios_3_scratch &= ~ATOM_S3_DFP5_ACTIVE;
  1155. bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP5;
  1156. }
  1157. }
  1158. if (rdev->family >= CHIP_R600) {
  1159. WREG32(R600_BIOS_0_SCRATCH, bios_0_scratch);
  1160. WREG32(R600_BIOS_3_SCRATCH, bios_3_scratch);
  1161. WREG32(R600_BIOS_6_SCRATCH, bios_6_scratch);
  1162. } else {
  1163. WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch);
  1164. WREG32(RADEON_BIOS_3_SCRATCH, bios_3_scratch);
  1165. WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
  1166. }
  1167. }
  1168. void
  1169. radeon_atombios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc)
  1170. {
  1171. struct drm_device *dev = encoder->dev;
  1172. struct radeon_device *rdev = dev->dev_private;
  1173. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  1174. uint32_t bios_3_scratch;
  1175. if (rdev->family >= CHIP_R600)
  1176. bios_3_scratch = RREG32(R600_BIOS_3_SCRATCH);
  1177. else
  1178. bios_3_scratch = RREG32(RADEON_BIOS_3_SCRATCH);
  1179. if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) {
  1180. bios_3_scratch &= ~ATOM_S3_TV1_CRTC_ACTIVE;
  1181. bios_3_scratch |= (crtc << 18);
  1182. }
  1183. if (radeon_encoder->devices & ATOM_DEVICE_CV_SUPPORT) {
  1184. bios_3_scratch &= ~ATOM_S3_CV_CRTC_ACTIVE;
  1185. bios_3_scratch |= (crtc << 24);
  1186. }
  1187. if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) {
  1188. bios_3_scratch &= ~ATOM_S3_CRT1_CRTC_ACTIVE;
  1189. bios_3_scratch |= (crtc << 16);
  1190. }
  1191. if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) {
  1192. bios_3_scratch &= ~ATOM_S3_CRT2_CRTC_ACTIVE;
  1193. bios_3_scratch |= (crtc << 20);
  1194. }
  1195. if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) {
  1196. bios_3_scratch &= ~ATOM_S3_LCD1_CRTC_ACTIVE;
  1197. bios_3_scratch |= (crtc << 17);
  1198. }
  1199. if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) {
  1200. bios_3_scratch &= ~ATOM_S3_DFP1_CRTC_ACTIVE;
  1201. bios_3_scratch |= (crtc << 19);
  1202. }
  1203. if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) {
  1204. bios_3_scratch &= ~ATOM_S3_DFP2_CRTC_ACTIVE;
  1205. bios_3_scratch |= (crtc << 23);
  1206. }
  1207. if (radeon_encoder->devices & ATOM_DEVICE_DFP3_SUPPORT) {
  1208. bios_3_scratch &= ~ATOM_S3_DFP3_CRTC_ACTIVE;
  1209. bios_3_scratch |= (crtc << 25);
  1210. }
  1211. if (rdev->family >= CHIP_R600)
  1212. WREG32(R600_BIOS_3_SCRATCH, bios_3_scratch);
  1213. else
  1214. WREG32(RADEON_BIOS_3_SCRATCH, bios_3_scratch);
  1215. }
  1216. void
  1217. radeon_atombios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on)
  1218. {
  1219. struct drm_device *dev = encoder->dev;
  1220. struct radeon_device *rdev = dev->dev_private;
  1221. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  1222. uint32_t bios_2_scratch;
  1223. if (rdev->family >= CHIP_R600)
  1224. bios_2_scratch = RREG32(R600_BIOS_2_SCRATCH);
  1225. else
  1226. bios_2_scratch = RREG32(RADEON_BIOS_2_SCRATCH);
  1227. if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) {
  1228. if (on)
  1229. bios_2_scratch &= ~ATOM_S2_TV1_DPMS_STATE;
  1230. else
  1231. bios_2_scratch |= ATOM_S2_TV1_DPMS_STATE;
  1232. }
  1233. if (radeon_encoder->devices & ATOM_DEVICE_CV_SUPPORT) {
  1234. if (on)
  1235. bios_2_scratch &= ~ATOM_S2_CV_DPMS_STATE;
  1236. else
  1237. bios_2_scratch |= ATOM_S2_CV_DPMS_STATE;
  1238. }
  1239. if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) {
  1240. if (on)
  1241. bios_2_scratch &= ~ATOM_S2_CRT1_DPMS_STATE;
  1242. else
  1243. bios_2_scratch |= ATOM_S2_CRT1_DPMS_STATE;
  1244. }
  1245. if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) {
  1246. if (on)
  1247. bios_2_scratch &= ~ATOM_S2_CRT2_DPMS_STATE;
  1248. else
  1249. bios_2_scratch |= ATOM_S2_CRT2_DPMS_STATE;
  1250. }
  1251. if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) {
  1252. if (on)
  1253. bios_2_scratch &= ~ATOM_S2_LCD1_DPMS_STATE;
  1254. else
  1255. bios_2_scratch |= ATOM_S2_LCD1_DPMS_STATE;
  1256. }
  1257. if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) {
  1258. if (on)
  1259. bios_2_scratch &= ~ATOM_S2_DFP1_DPMS_STATE;
  1260. else
  1261. bios_2_scratch |= ATOM_S2_DFP1_DPMS_STATE;
  1262. }
  1263. if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) {
  1264. if (on)
  1265. bios_2_scratch &= ~ATOM_S2_DFP2_DPMS_STATE;
  1266. else
  1267. bios_2_scratch |= ATOM_S2_DFP2_DPMS_STATE;
  1268. }
  1269. if (radeon_encoder->devices & ATOM_DEVICE_DFP3_SUPPORT) {
  1270. if (on)
  1271. bios_2_scratch &= ~ATOM_S2_DFP3_DPMS_STATE;
  1272. else
  1273. bios_2_scratch |= ATOM_S2_DFP3_DPMS_STATE;
  1274. }
  1275. if (radeon_encoder->devices & ATOM_DEVICE_DFP4_SUPPORT) {
  1276. if (on)
  1277. bios_2_scratch &= ~ATOM_S2_DFP4_DPMS_STATE;
  1278. else
  1279. bios_2_scratch |= ATOM_S2_DFP4_DPMS_STATE;
  1280. }
  1281. if (radeon_encoder->devices & ATOM_DEVICE_DFP5_SUPPORT) {
  1282. if (on)
  1283. bios_2_scratch &= ~ATOM_S2_DFP5_DPMS_STATE;
  1284. else
  1285. bios_2_scratch |= ATOM_S2_DFP5_DPMS_STATE;
  1286. }
  1287. if (rdev->family >= CHIP_R600)
  1288. WREG32(R600_BIOS_2_SCRATCH, bios_2_scratch);
  1289. else
  1290. WREG32(RADEON_BIOS_2_SCRATCH, bios_2_scratch);
  1291. }