radeon_atombios.c 44 KB

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