radeon.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134
  1. /*
  2. * Copyright 2008 Advanced Micro Devices, Inc.
  3. * Copyright 2008 Red Hat Inc.
  4. * Copyright 2009 Jerome Glisse.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * Authors: Dave Airlie
  25. * Alex Deucher
  26. * Jerome Glisse
  27. */
  28. #ifndef __RADEON_H__
  29. #define __RADEON_H__
  30. /* TODO: Here are things that needs to be done :
  31. * - surface allocator & initializer : (bit like scratch reg) should
  32. * initialize HDP_ stuff on RS600, R600, R700 hw, well anythings
  33. * related to surface
  34. * - WB : write back stuff (do it bit like scratch reg things)
  35. * - Vblank : look at Jesse's rework and what we should do
  36. * - r600/r700: gart & cp
  37. * - cs : clean cs ioctl use bitmap & things like that.
  38. * - power management stuff
  39. * - Barrier in gart code
  40. * - Unmappabled vram ?
  41. * - TESTING, TESTING, TESTING
  42. */
  43. /* Initialization path:
  44. * We expect that acceleration initialization might fail for various
  45. * reasons even thought we work hard to make it works on most
  46. * configurations. In order to still have a working userspace in such
  47. * situation the init path must succeed up to the memory controller
  48. * initialization point. Failure before this point are considered as
  49. * fatal error. Here is the init callchain :
  50. * radeon_device_init perform common structure, mutex initialization
  51. * asic_init setup the GPU memory layout and perform all
  52. * one time initialization (failure in this
  53. * function are considered fatal)
  54. * asic_startup setup the GPU acceleration, in order to
  55. * follow guideline the first thing this
  56. * function should do is setting the GPU
  57. * memory controller (only MC setup failure
  58. * are considered as fatal)
  59. */
  60. #include <asm/atomic.h>
  61. #include <linux/wait.h>
  62. #include <linux/list.h>
  63. #include <linux/kref.h>
  64. #include <ttm/ttm_bo_api.h>
  65. #include <ttm/ttm_bo_driver.h>
  66. #include <ttm/ttm_placement.h>
  67. #include <ttm/ttm_module.h>
  68. #include "radeon_family.h"
  69. #include "radeon_mode.h"
  70. #include "radeon_reg.h"
  71. /*
  72. * Modules parameters.
  73. */
  74. extern int radeon_no_wb;
  75. extern int radeon_modeset;
  76. extern int radeon_dynclks;
  77. extern int radeon_r4xx_atom;
  78. extern int radeon_agpmode;
  79. extern int radeon_vram_limit;
  80. extern int radeon_gart_size;
  81. extern int radeon_benchmarking;
  82. extern int radeon_testing;
  83. extern int radeon_connector_table;
  84. extern int radeon_tv;
  85. /*
  86. * Copy from radeon_drv.h so we don't have to include both and have conflicting
  87. * symbol;
  88. */
  89. #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */
  90. #define RADEON_IB_POOL_SIZE 16
  91. #define RADEON_DEBUGFS_MAX_NUM_FILES 32
  92. #define RADEONFB_CONN_LIMIT 4
  93. #define RADEON_BIOS_NUM_SCRATCH 8
  94. /*
  95. * Errata workarounds.
  96. */
  97. enum radeon_pll_errata {
  98. CHIP_ERRATA_R300_CG = 0x00000001,
  99. CHIP_ERRATA_PLL_DUMMYREADS = 0x00000002,
  100. CHIP_ERRATA_PLL_DELAY = 0x00000004
  101. };
  102. struct radeon_device;
  103. /*
  104. * BIOS.
  105. */
  106. bool radeon_get_bios(struct radeon_device *rdev);
  107. /*
  108. * Dummy page
  109. */
  110. struct radeon_dummy_page {
  111. struct page *page;
  112. dma_addr_t addr;
  113. };
  114. int radeon_dummy_page_init(struct radeon_device *rdev);
  115. void radeon_dummy_page_fini(struct radeon_device *rdev);
  116. /*
  117. * Clocks
  118. */
  119. struct radeon_clock {
  120. struct radeon_pll p1pll;
  121. struct radeon_pll p2pll;
  122. struct radeon_pll spll;
  123. struct radeon_pll mpll;
  124. /* 10 Khz units */
  125. uint32_t default_mclk;
  126. uint32_t default_sclk;
  127. };
  128. /*
  129. * Power management
  130. */
  131. int radeon_pm_init(struct radeon_device *rdev);
  132. /*
  133. * Fences.
  134. */
  135. struct radeon_fence_driver {
  136. uint32_t scratch_reg;
  137. atomic_t seq;
  138. uint32_t last_seq;
  139. unsigned long count_timeout;
  140. wait_queue_head_t queue;
  141. rwlock_t lock;
  142. struct list_head created;
  143. struct list_head emited;
  144. struct list_head signaled;
  145. };
  146. struct radeon_fence {
  147. struct radeon_device *rdev;
  148. struct kref kref;
  149. struct list_head list;
  150. /* protected by radeon_fence.lock */
  151. uint32_t seq;
  152. unsigned long timeout;
  153. bool emited;
  154. bool signaled;
  155. };
  156. int radeon_fence_driver_init(struct radeon_device *rdev);
  157. void radeon_fence_driver_fini(struct radeon_device *rdev);
  158. int radeon_fence_create(struct radeon_device *rdev, struct radeon_fence **fence);
  159. int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence);
  160. void radeon_fence_process(struct radeon_device *rdev);
  161. bool radeon_fence_signaled(struct radeon_fence *fence);
  162. int radeon_fence_wait(struct radeon_fence *fence, bool interruptible);
  163. int radeon_fence_wait_next(struct radeon_device *rdev);
  164. int radeon_fence_wait_last(struct radeon_device *rdev);
  165. struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence);
  166. void radeon_fence_unref(struct radeon_fence **fence);
  167. /*
  168. * Tiling registers
  169. */
  170. struct radeon_surface_reg {
  171. struct radeon_bo *bo;
  172. };
  173. #define RADEON_GEM_MAX_SURFACES 8
  174. /*
  175. * TTM.
  176. */
  177. struct radeon_mman {
  178. struct ttm_bo_global_ref bo_global_ref;
  179. struct ttm_global_reference mem_global_ref;
  180. bool mem_global_referenced;
  181. struct ttm_bo_device bdev;
  182. };
  183. struct radeon_bo {
  184. /* Protected by gem.mutex */
  185. struct list_head list;
  186. /* Protected by tbo.reserved */
  187. struct ttm_buffer_object tbo;
  188. struct ttm_bo_kmap_obj kmap;
  189. unsigned pin_count;
  190. void *kptr;
  191. u32 tiling_flags;
  192. u32 pitch;
  193. int surface_reg;
  194. /* Constant after initialization */
  195. struct radeon_device *rdev;
  196. struct drm_gem_object *gobj;
  197. };
  198. struct radeon_bo_list {
  199. struct list_head list;
  200. struct radeon_bo *bo;
  201. uint64_t gpu_offset;
  202. unsigned rdomain;
  203. unsigned wdomain;
  204. u32 tiling_flags;
  205. };
  206. /*
  207. * GEM objects.
  208. */
  209. struct radeon_gem {
  210. struct mutex mutex;
  211. struct list_head objects;
  212. };
  213. int radeon_gem_init(struct radeon_device *rdev);
  214. void radeon_gem_fini(struct radeon_device *rdev);
  215. int radeon_gem_object_create(struct radeon_device *rdev, int size,
  216. int alignment, int initial_domain,
  217. bool discardable, bool kernel,
  218. struct drm_gem_object **obj);
  219. int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain,
  220. uint64_t *gpu_addr);
  221. void radeon_gem_object_unpin(struct drm_gem_object *obj);
  222. /*
  223. * GART structures, functions & helpers
  224. */
  225. struct radeon_mc;
  226. struct radeon_gart_table_ram {
  227. volatile uint32_t *ptr;
  228. };
  229. struct radeon_gart_table_vram {
  230. struct radeon_bo *robj;
  231. volatile uint32_t *ptr;
  232. };
  233. union radeon_gart_table {
  234. struct radeon_gart_table_ram ram;
  235. struct radeon_gart_table_vram vram;
  236. };
  237. #define RADEON_GPU_PAGE_SIZE 4096
  238. struct radeon_gart {
  239. dma_addr_t table_addr;
  240. unsigned num_gpu_pages;
  241. unsigned num_cpu_pages;
  242. unsigned table_size;
  243. union radeon_gart_table table;
  244. struct page **pages;
  245. dma_addr_t *pages_addr;
  246. bool ready;
  247. };
  248. int radeon_gart_table_ram_alloc(struct radeon_device *rdev);
  249. void radeon_gart_table_ram_free(struct radeon_device *rdev);
  250. int radeon_gart_table_vram_alloc(struct radeon_device *rdev);
  251. void radeon_gart_table_vram_free(struct radeon_device *rdev);
  252. int radeon_gart_init(struct radeon_device *rdev);
  253. void radeon_gart_fini(struct radeon_device *rdev);
  254. void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset,
  255. int pages);
  256. int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
  257. int pages, struct page **pagelist);
  258. /*
  259. * GPU MC structures, functions & helpers
  260. */
  261. struct radeon_mc {
  262. resource_size_t aper_size;
  263. resource_size_t aper_base;
  264. resource_size_t agp_base;
  265. /* for some chips with <= 32MB we need to lie
  266. * about vram size near mc fb location */
  267. u64 mc_vram_size;
  268. u64 gtt_location;
  269. u64 gtt_size;
  270. u64 gtt_start;
  271. u64 gtt_end;
  272. u64 vram_location;
  273. u64 vram_start;
  274. u64 vram_end;
  275. unsigned vram_width;
  276. u64 real_vram_size;
  277. int vram_mtrr;
  278. bool vram_is_ddr;
  279. };
  280. int radeon_mc_setup(struct radeon_device *rdev);
  281. /*
  282. * GPU scratch registers structures, functions & helpers
  283. */
  284. struct radeon_scratch {
  285. unsigned num_reg;
  286. bool free[32];
  287. uint32_t reg[32];
  288. };
  289. int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg);
  290. void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg);
  291. /*
  292. * IRQS.
  293. */
  294. struct radeon_irq {
  295. bool installed;
  296. bool sw_int;
  297. /* FIXME: use a define max crtc rather than hardcode it */
  298. bool crtc_vblank_int[2];
  299. spinlock_t sw_lock;
  300. int sw_refcount;
  301. };
  302. int radeon_irq_kms_init(struct radeon_device *rdev);
  303. void radeon_irq_kms_fini(struct radeon_device *rdev);
  304. void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev);
  305. void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev);
  306. /*
  307. * CP & ring.
  308. */
  309. struct radeon_ib {
  310. struct list_head list;
  311. unsigned long idx;
  312. uint64_t gpu_addr;
  313. struct radeon_fence *fence;
  314. uint32_t *ptr;
  315. uint32_t length_dw;
  316. };
  317. /*
  318. * locking -
  319. * mutex protects scheduled_ibs, ready, alloc_bm
  320. */
  321. struct radeon_ib_pool {
  322. struct mutex mutex;
  323. struct radeon_bo *robj;
  324. struct list_head scheduled_ibs;
  325. struct radeon_ib ibs[RADEON_IB_POOL_SIZE];
  326. bool ready;
  327. DECLARE_BITMAP(alloc_bm, RADEON_IB_POOL_SIZE);
  328. };
  329. struct radeon_cp {
  330. struct radeon_bo *ring_obj;
  331. volatile uint32_t *ring;
  332. unsigned rptr;
  333. unsigned wptr;
  334. unsigned wptr_old;
  335. unsigned ring_size;
  336. unsigned ring_free_dw;
  337. int count_dw;
  338. uint64_t gpu_addr;
  339. uint32_t align_mask;
  340. uint32_t ptr_mask;
  341. struct mutex mutex;
  342. bool ready;
  343. };
  344. /*
  345. * R6xx+ IH ring
  346. */
  347. struct r600_ih {
  348. struct radeon_bo *ring_obj;
  349. volatile uint32_t *ring;
  350. unsigned rptr;
  351. unsigned wptr;
  352. unsigned wptr_old;
  353. unsigned ring_size;
  354. uint64_t gpu_addr;
  355. uint32_t align_mask;
  356. uint32_t ptr_mask;
  357. spinlock_t lock;
  358. bool enabled;
  359. };
  360. struct r600_blit {
  361. struct radeon_bo *shader_obj;
  362. u64 shader_gpu_addr;
  363. u32 vs_offset, ps_offset;
  364. u32 state_offset;
  365. u32 state_len;
  366. u32 vb_used, vb_total;
  367. struct radeon_ib *vb_ib;
  368. };
  369. int radeon_ib_get(struct radeon_device *rdev, struct radeon_ib **ib);
  370. void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib);
  371. int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib);
  372. int radeon_ib_pool_init(struct radeon_device *rdev);
  373. void radeon_ib_pool_fini(struct radeon_device *rdev);
  374. int radeon_ib_test(struct radeon_device *rdev);
  375. /* Ring access between begin & end cannot sleep */
  376. void radeon_ring_free_size(struct radeon_device *rdev);
  377. int radeon_ring_lock(struct radeon_device *rdev, unsigned ndw);
  378. void radeon_ring_unlock_commit(struct radeon_device *rdev);
  379. void radeon_ring_unlock_undo(struct radeon_device *rdev);
  380. int radeon_ring_test(struct radeon_device *rdev);
  381. int radeon_ring_init(struct radeon_device *rdev, unsigned ring_size);
  382. void radeon_ring_fini(struct radeon_device *rdev);
  383. /*
  384. * CS.
  385. */
  386. struct radeon_cs_reloc {
  387. struct drm_gem_object *gobj;
  388. struct radeon_bo *robj;
  389. struct radeon_bo_list lobj;
  390. uint32_t handle;
  391. uint32_t flags;
  392. };
  393. struct radeon_cs_chunk {
  394. uint32_t chunk_id;
  395. uint32_t length_dw;
  396. int kpage_idx[2];
  397. uint32_t *kpage[2];
  398. uint32_t *kdata;
  399. void __user *user_ptr;
  400. int last_copied_page;
  401. int last_page_index;
  402. };
  403. struct radeon_cs_parser {
  404. struct radeon_device *rdev;
  405. struct drm_file *filp;
  406. /* chunks */
  407. unsigned nchunks;
  408. struct radeon_cs_chunk *chunks;
  409. uint64_t *chunks_array;
  410. /* IB */
  411. unsigned idx;
  412. /* relocations */
  413. unsigned nrelocs;
  414. struct radeon_cs_reloc *relocs;
  415. struct radeon_cs_reloc **relocs_ptr;
  416. struct list_head validated;
  417. /* indices of various chunks */
  418. int chunk_ib_idx;
  419. int chunk_relocs_idx;
  420. struct radeon_ib *ib;
  421. void *track;
  422. unsigned family;
  423. int parser_error;
  424. };
  425. extern int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx);
  426. extern int radeon_cs_finish_pages(struct radeon_cs_parser *p);
  427. static inline u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx)
  428. {
  429. struct radeon_cs_chunk *ibc = &p->chunks[p->chunk_ib_idx];
  430. u32 pg_idx, pg_offset;
  431. u32 idx_value = 0;
  432. int new_page;
  433. pg_idx = (idx * 4) / PAGE_SIZE;
  434. pg_offset = (idx * 4) % PAGE_SIZE;
  435. if (ibc->kpage_idx[0] == pg_idx)
  436. return ibc->kpage[0][pg_offset/4];
  437. if (ibc->kpage_idx[1] == pg_idx)
  438. return ibc->kpage[1][pg_offset/4];
  439. new_page = radeon_cs_update_pages(p, pg_idx);
  440. if (new_page < 0) {
  441. p->parser_error = new_page;
  442. return 0;
  443. }
  444. idx_value = ibc->kpage[new_page][pg_offset/4];
  445. return idx_value;
  446. }
  447. struct radeon_cs_packet {
  448. unsigned idx;
  449. unsigned type;
  450. unsigned reg;
  451. unsigned opcode;
  452. int count;
  453. unsigned one_reg_wr;
  454. };
  455. typedef int (*radeon_packet0_check_t)(struct radeon_cs_parser *p,
  456. struct radeon_cs_packet *pkt,
  457. unsigned idx, unsigned reg);
  458. typedef int (*radeon_packet3_check_t)(struct radeon_cs_parser *p,
  459. struct radeon_cs_packet *pkt);
  460. /*
  461. * AGP
  462. */
  463. int radeon_agp_init(struct radeon_device *rdev);
  464. void radeon_agp_resume(struct radeon_device *rdev);
  465. void radeon_agp_fini(struct radeon_device *rdev);
  466. /*
  467. * Writeback
  468. */
  469. struct radeon_wb {
  470. struct radeon_bo *wb_obj;
  471. volatile uint32_t *wb;
  472. uint64_t gpu_addr;
  473. };
  474. /**
  475. * struct radeon_pm - power management datas
  476. * @max_bandwidth: maximum bandwidth the gpu has (MByte/s)
  477. * @igp_sideport_mclk: sideport memory clock Mhz (rs690,rs740,rs780,rs880)
  478. * @igp_system_mclk: system clock Mhz (rs690,rs740,rs780,rs880)
  479. * @igp_ht_link_clk: ht link clock Mhz (rs690,rs740,rs780,rs880)
  480. * @igp_ht_link_width: ht link width in bits (rs690,rs740,rs780,rs880)
  481. * @k8_bandwidth: k8 bandwidth the gpu has (MByte/s) (IGP)
  482. * @sideport_bandwidth: sideport bandwidth the gpu has (MByte/s) (IGP)
  483. * @ht_bandwidth: ht bandwidth the gpu has (MByte/s) (IGP)
  484. * @core_bandwidth: core GPU bandwidth the gpu has (MByte/s) (IGP)
  485. * @sclk: GPU clock Mhz (core bandwith depends of this clock)
  486. * @needed_bandwidth: current bandwidth needs
  487. *
  488. * It keeps track of various data needed to take powermanagement decision.
  489. * Bandwith need is used to determine minimun clock of the GPU and memory.
  490. * Equation between gpu/memory clock and available bandwidth is hw dependent
  491. * (type of memory, bus size, efficiency, ...)
  492. */
  493. struct radeon_pm {
  494. fixed20_12 max_bandwidth;
  495. fixed20_12 igp_sideport_mclk;
  496. fixed20_12 igp_system_mclk;
  497. fixed20_12 igp_ht_link_clk;
  498. fixed20_12 igp_ht_link_width;
  499. fixed20_12 k8_bandwidth;
  500. fixed20_12 sideport_bandwidth;
  501. fixed20_12 ht_bandwidth;
  502. fixed20_12 core_bandwidth;
  503. fixed20_12 sclk;
  504. fixed20_12 needed_bandwidth;
  505. };
  506. /*
  507. * Benchmarking
  508. */
  509. void radeon_benchmark(struct radeon_device *rdev);
  510. /*
  511. * Testing
  512. */
  513. void radeon_test_moves(struct radeon_device *rdev);
  514. /*
  515. * Debugfs
  516. */
  517. int radeon_debugfs_add_files(struct radeon_device *rdev,
  518. struct drm_info_list *files,
  519. unsigned nfiles);
  520. int radeon_debugfs_fence_init(struct radeon_device *rdev);
  521. int r100_debugfs_rbbm_init(struct radeon_device *rdev);
  522. int r100_debugfs_cp_init(struct radeon_device *rdev);
  523. /*
  524. * ASIC specific functions.
  525. */
  526. struct radeon_asic {
  527. int (*init)(struct radeon_device *rdev);
  528. void (*fini)(struct radeon_device *rdev);
  529. int (*resume)(struct radeon_device *rdev);
  530. int (*suspend)(struct radeon_device *rdev);
  531. void (*vga_set_state)(struct radeon_device *rdev, bool state);
  532. int (*gpu_reset)(struct radeon_device *rdev);
  533. void (*gart_tlb_flush)(struct radeon_device *rdev);
  534. int (*gart_set_page)(struct radeon_device *rdev, int i, uint64_t addr);
  535. int (*cp_init)(struct radeon_device *rdev, unsigned ring_size);
  536. void (*cp_fini)(struct radeon_device *rdev);
  537. void (*cp_disable)(struct radeon_device *rdev);
  538. void (*cp_commit)(struct radeon_device *rdev);
  539. void (*ring_start)(struct radeon_device *rdev);
  540. int (*ring_test)(struct radeon_device *rdev);
  541. void (*ring_ib_execute)(struct radeon_device *rdev, struct radeon_ib *ib);
  542. int (*irq_set)(struct radeon_device *rdev);
  543. int (*irq_process)(struct radeon_device *rdev);
  544. u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
  545. void (*fence_ring_emit)(struct radeon_device *rdev, struct radeon_fence *fence);
  546. int (*cs_parse)(struct radeon_cs_parser *p);
  547. int (*copy_blit)(struct radeon_device *rdev,
  548. uint64_t src_offset,
  549. uint64_t dst_offset,
  550. unsigned num_pages,
  551. struct radeon_fence *fence);
  552. int (*copy_dma)(struct radeon_device *rdev,
  553. uint64_t src_offset,
  554. uint64_t dst_offset,
  555. unsigned num_pages,
  556. struct radeon_fence *fence);
  557. int (*copy)(struct radeon_device *rdev,
  558. uint64_t src_offset,
  559. uint64_t dst_offset,
  560. unsigned num_pages,
  561. struct radeon_fence *fence);
  562. uint32_t (*get_engine_clock)(struct radeon_device *rdev);
  563. void (*set_engine_clock)(struct radeon_device *rdev, uint32_t eng_clock);
  564. uint32_t (*get_memory_clock)(struct radeon_device *rdev);
  565. void (*set_memory_clock)(struct radeon_device *rdev, uint32_t mem_clock);
  566. void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes);
  567. void (*set_clock_gating)(struct radeon_device *rdev, int enable);
  568. int (*set_surface_reg)(struct radeon_device *rdev, int reg,
  569. uint32_t tiling_flags, uint32_t pitch,
  570. uint32_t offset, uint32_t obj_size);
  571. int (*clear_surface_reg)(struct radeon_device *rdev, int reg);
  572. void (*bandwidth_update)(struct radeon_device *rdev);
  573. void (*hdp_flush)(struct radeon_device *rdev);
  574. };
  575. /*
  576. * Asic structures
  577. */
  578. struct r100_asic {
  579. const unsigned *reg_safe_bm;
  580. unsigned reg_safe_bm_size;
  581. };
  582. struct r300_asic {
  583. const unsigned *reg_safe_bm;
  584. unsigned reg_safe_bm_size;
  585. };
  586. struct r600_asic {
  587. unsigned max_pipes;
  588. unsigned max_tile_pipes;
  589. unsigned max_simds;
  590. unsigned max_backends;
  591. unsigned max_gprs;
  592. unsigned max_threads;
  593. unsigned max_stack_entries;
  594. unsigned max_hw_contexts;
  595. unsigned max_gs_threads;
  596. unsigned sx_max_export_size;
  597. unsigned sx_max_export_pos_size;
  598. unsigned sx_max_export_smx_size;
  599. unsigned sq_num_cf_insts;
  600. };
  601. struct rv770_asic {
  602. unsigned max_pipes;
  603. unsigned max_tile_pipes;
  604. unsigned max_simds;
  605. unsigned max_backends;
  606. unsigned max_gprs;
  607. unsigned max_threads;
  608. unsigned max_stack_entries;
  609. unsigned max_hw_contexts;
  610. unsigned max_gs_threads;
  611. unsigned sx_max_export_size;
  612. unsigned sx_max_export_pos_size;
  613. unsigned sx_max_export_smx_size;
  614. unsigned sq_num_cf_insts;
  615. unsigned sx_num_of_sets;
  616. unsigned sc_prim_fifo_size;
  617. unsigned sc_hiz_tile_fifo_size;
  618. unsigned sc_earlyz_tile_fifo_fize;
  619. };
  620. union radeon_asic_config {
  621. struct r300_asic r300;
  622. struct r100_asic r100;
  623. struct r600_asic r600;
  624. struct rv770_asic rv770;
  625. };
  626. /*
  627. * IOCTL.
  628. */
  629. int radeon_gem_info_ioctl(struct drm_device *dev, void *data,
  630. struct drm_file *filp);
  631. int radeon_gem_create_ioctl(struct drm_device *dev, void *data,
  632. struct drm_file *filp);
  633. int radeon_gem_pin_ioctl(struct drm_device *dev, void *data,
  634. struct drm_file *file_priv);
  635. int radeon_gem_unpin_ioctl(struct drm_device *dev, void *data,
  636. struct drm_file *file_priv);
  637. int radeon_gem_pwrite_ioctl(struct drm_device *dev, void *data,
  638. struct drm_file *file_priv);
  639. int radeon_gem_pread_ioctl(struct drm_device *dev, void *data,
  640. struct drm_file *file_priv);
  641. int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data,
  642. struct drm_file *filp);
  643. int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data,
  644. struct drm_file *filp);
  645. int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
  646. struct drm_file *filp);
  647. int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
  648. struct drm_file *filp);
  649. int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);
  650. int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data,
  651. struct drm_file *filp);
  652. int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data,
  653. struct drm_file *filp);
  654. /*
  655. * Core structure, functions and helpers.
  656. */
  657. typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t);
  658. typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t);
  659. struct radeon_device {
  660. struct device *dev;
  661. struct drm_device *ddev;
  662. struct pci_dev *pdev;
  663. /* ASIC */
  664. union radeon_asic_config config;
  665. enum radeon_family family;
  666. unsigned long flags;
  667. int usec_timeout;
  668. enum radeon_pll_errata pll_errata;
  669. int num_gb_pipes;
  670. int num_z_pipes;
  671. int disp_priority;
  672. /* BIOS */
  673. uint8_t *bios;
  674. bool is_atom_bios;
  675. uint16_t bios_header_start;
  676. struct radeon_bo *stollen_vga_memory;
  677. struct fb_info *fbdev_info;
  678. struct radeon_bo *fbdev_rbo;
  679. struct radeon_framebuffer *fbdev_rfb;
  680. /* Register mmio */
  681. resource_size_t rmmio_base;
  682. resource_size_t rmmio_size;
  683. void *rmmio;
  684. radeon_rreg_t mc_rreg;
  685. radeon_wreg_t mc_wreg;
  686. radeon_rreg_t pll_rreg;
  687. radeon_wreg_t pll_wreg;
  688. uint32_t pcie_reg_mask;
  689. radeon_rreg_t pciep_rreg;
  690. radeon_wreg_t pciep_wreg;
  691. struct radeon_clock clock;
  692. struct radeon_mc mc;
  693. struct radeon_gart gart;
  694. struct radeon_mode_info mode_info;
  695. struct radeon_scratch scratch;
  696. struct radeon_mman mman;
  697. struct radeon_fence_driver fence_drv;
  698. struct radeon_cp cp;
  699. struct radeon_ib_pool ib_pool;
  700. struct radeon_irq irq;
  701. struct radeon_asic *asic;
  702. struct radeon_gem gem;
  703. struct radeon_pm pm;
  704. uint32_t bios_scratch[RADEON_BIOS_NUM_SCRATCH];
  705. struct mutex cs_mutex;
  706. struct radeon_wb wb;
  707. struct radeon_dummy_page dummy_page;
  708. bool gpu_lockup;
  709. bool shutdown;
  710. bool suspend;
  711. bool need_dma32;
  712. bool accel_working;
  713. struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES];
  714. const struct firmware *me_fw; /* all family ME firmware */
  715. const struct firmware *pfp_fw; /* r6/700 PFP firmware */
  716. const struct firmware *rlc_fw; /* r6/700 RLC firmware */
  717. struct r600_blit r600_blit;
  718. int msi_enabled; /* msi enabled */
  719. struct r600_ih ih; /* r6/700 interrupt ring */
  720. };
  721. int radeon_device_init(struct radeon_device *rdev,
  722. struct drm_device *ddev,
  723. struct pci_dev *pdev,
  724. uint32_t flags);
  725. void radeon_device_fini(struct radeon_device *rdev);
  726. int radeon_gpu_wait_for_idle(struct radeon_device *rdev);
  727. /* r600 blit */
  728. int r600_blit_prepare_copy(struct radeon_device *rdev, int size_bytes);
  729. void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence *fence);
  730. void r600_kms_blit_copy(struct radeon_device *rdev,
  731. u64 src_gpu_addr, u64 dst_gpu_addr,
  732. int size_bytes);
  733. static inline uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg)
  734. {
  735. if (reg < 0x10000)
  736. return readl(((void __iomem *)rdev->rmmio) + reg);
  737. else {
  738. writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX);
  739. return readl(((void __iomem *)rdev->rmmio) + RADEON_MM_DATA);
  740. }
  741. }
  742. static inline void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
  743. {
  744. if (reg < 0x10000)
  745. writel(v, ((void __iomem *)rdev->rmmio) + reg);
  746. else {
  747. writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX);
  748. writel(v, ((void __iomem *)rdev->rmmio) + RADEON_MM_DATA);
  749. }
  750. }
  751. /*
  752. * Cast helper
  753. */
  754. #define to_radeon_fence(p) ((struct radeon_fence *)(p))
  755. /*
  756. * Registers read & write functions.
  757. */
  758. #define RREG8(reg) readb(((void __iomem *)rdev->rmmio) + (reg))
  759. #define WREG8(reg, v) writeb(v, ((void __iomem *)rdev->rmmio) + (reg))
  760. #define RREG32(reg) r100_mm_rreg(rdev, (reg))
  761. #define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", r100_mm_rreg(rdev, (reg)))
  762. #define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v))
  763. #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
  764. #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
  765. #define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg))
  766. #define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v))
  767. #define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg))
  768. #define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v))
  769. #define RREG32_PCIE(reg) rv370_pcie_rreg(rdev, (reg))
  770. #define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v))
  771. #define WREG32_P(reg, val, mask) \
  772. do { \
  773. uint32_t tmp_ = RREG32(reg); \
  774. tmp_ &= (mask); \
  775. tmp_ |= ((val) & ~(mask)); \
  776. WREG32(reg, tmp_); \
  777. } while (0)
  778. #define WREG32_PLL_P(reg, val, mask) \
  779. do { \
  780. uint32_t tmp_ = RREG32_PLL(reg); \
  781. tmp_ &= (mask); \
  782. tmp_ |= ((val) & ~(mask)); \
  783. WREG32_PLL(reg, tmp_); \
  784. } while (0)
  785. #define DREG32_SYS(sqf, rdev, reg) seq_printf((sqf), #reg " : 0x%08X\n", r100_mm_rreg((rdev), (reg)))
  786. /*
  787. * Indirect registers accessor
  788. */
  789. static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg)
  790. {
  791. uint32_t r;
  792. WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
  793. r = RREG32(RADEON_PCIE_DATA);
  794. return r;
  795. }
  796. static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
  797. {
  798. WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
  799. WREG32(RADEON_PCIE_DATA, (v));
  800. }
  801. void r100_pll_errata_after_index(struct radeon_device *rdev);
  802. /*
  803. * ASICs helpers.
  804. */
  805. #define ASIC_IS_RN50(rdev) ((rdev->pdev->device == 0x515e) || \
  806. (rdev->pdev->device == 0x5969))
  807. #define ASIC_IS_RV100(rdev) ((rdev->family == CHIP_RV100) || \
  808. (rdev->family == CHIP_RV200) || \
  809. (rdev->family == CHIP_RS100) || \
  810. (rdev->family == CHIP_RS200) || \
  811. (rdev->family == CHIP_RV250) || \
  812. (rdev->family == CHIP_RV280) || \
  813. (rdev->family == CHIP_RS300))
  814. #define ASIC_IS_R300(rdev) ((rdev->family == CHIP_R300) || \
  815. (rdev->family == CHIP_RV350) || \
  816. (rdev->family == CHIP_R350) || \
  817. (rdev->family == CHIP_RV380) || \
  818. (rdev->family == CHIP_R420) || \
  819. (rdev->family == CHIP_R423) || \
  820. (rdev->family == CHIP_RV410) || \
  821. (rdev->family == CHIP_RS400) || \
  822. (rdev->family == CHIP_RS480))
  823. #define ASIC_IS_AVIVO(rdev) ((rdev->family >= CHIP_RS600))
  824. #define ASIC_IS_DCE3(rdev) ((rdev->family >= CHIP_RV620))
  825. #define ASIC_IS_DCE32(rdev) ((rdev->family >= CHIP_RV730))
  826. /*
  827. * BIOS helpers.
  828. */
  829. #define RBIOS8(i) (rdev->bios[i])
  830. #define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8))
  831. #define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16))
  832. int radeon_combios_init(struct radeon_device *rdev);
  833. void radeon_combios_fini(struct radeon_device *rdev);
  834. int radeon_atombios_init(struct radeon_device *rdev);
  835. void radeon_atombios_fini(struct radeon_device *rdev);
  836. /*
  837. * RING helpers.
  838. */
  839. static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v)
  840. {
  841. #if DRM_DEBUG_CODE
  842. if (rdev->cp.count_dw <= 0) {
  843. DRM_ERROR("radeon: writting more dword to ring than expected !\n");
  844. }
  845. #endif
  846. rdev->cp.ring[rdev->cp.wptr++] = v;
  847. rdev->cp.wptr &= rdev->cp.ptr_mask;
  848. rdev->cp.count_dw--;
  849. rdev->cp.ring_free_dw--;
  850. }
  851. /*
  852. * ASICs macro.
  853. */
  854. #define radeon_init(rdev) (rdev)->asic->init((rdev))
  855. #define radeon_fini(rdev) (rdev)->asic->fini((rdev))
  856. #define radeon_resume(rdev) (rdev)->asic->resume((rdev))
  857. #define radeon_suspend(rdev) (rdev)->asic->suspend((rdev))
  858. #define radeon_cs_parse(p) rdev->asic->cs_parse((p))
  859. #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state))
  860. #define radeon_gpu_reset(rdev) (rdev)->asic->gpu_reset((rdev))
  861. #define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart_tlb_flush((rdev))
  862. #define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart_set_page((rdev), (i), (p))
  863. #define radeon_cp_commit(rdev) (rdev)->asic->cp_commit((rdev))
  864. #define radeon_ring_start(rdev) (rdev)->asic->ring_start((rdev))
  865. #define radeon_ring_test(rdev) (rdev)->asic->ring_test((rdev))
  866. #define radeon_ring_ib_execute(rdev, ib) (rdev)->asic->ring_ib_execute((rdev), (ib))
  867. #define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev))
  868. #define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev))
  869. #define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->get_vblank_counter((rdev), (crtc))
  870. #define radeon_fence_ring_emit(rdev, fence) (rdev)->asic->fence_ring_emit((rdev), (fence))
  871. #define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy_blit((rdev), (s), (d), (np), (f))
  872. #define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy_dma((rdev), (s), (d), (np), (f))
  873. #define radeon_copy(rdev, s, d, np, f) (rdev)->asic->copy((rdev), (s), (d), (np), (f))
  874. #define radeon_get_engine_clock(rdev) (rdev)->asic->get_engine_clock((rdev))
  875. #define radeon_set_engine_clock(rdev, e) (rdev)->asic->set_engine_clock((rdev), (e))
  876. #define radeon_get_memory_clock(rdev) (rdev)->asic->get_memory_clock((rdev))
  877. #define radeon_set_memory_clock(rdev, e) (rdev)->asic->set_engine_clock((rdev), (e))
  878. #define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->set_pcie_lanes((rdev), (l))
  879. #define radeon_set_clock_gating(rdev, e) (rdev)->asic->set_clock_gating((rdev), (e))
  880. #define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s)))
  881. #define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->clear_surface_reg((rdev), (r)))
  882. #define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev))
  883. #define radeon_hdp_flush(rdev) (rdev)->asic->hdp_flush((rdev))
  884. /* Common functions */
  885. extern int radeon_gart_table_vram_pin(struct radeon_device *rdev);
  886. extern int radeon_modeset_init(struct radeon_device *rdev);
  887. extern void radeon_modeset_fini(struct radeon_device *rdev);
  888. extern bool radeon_card_posted(struct radeon_device *rdev);
  889. extern bool radeon_boot_test_post_card(struct radeon_device *rdev);
  890. extern int radeon_clocks_init(struct radeon_device *rdev);
  891. extern void radeon_clocks_fini(struct radeon_device *rdev);
  892. extern void radeon_scratch_init(struct radeon_device *rdev);
  893. extern void radeon_surface_init(struct radeon_device *rdev);
  894. extern int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data);
  895. extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable);
  896. extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable);
  897. /* r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280 */
  898. struct r100_mc_save {
  899. u32 GENMO_WT;
  900. u32 CRTC_EXT_CNTL;
  901. u32 CRTC_GEN_CNTL;
  902. u32 CRTC2_GEN_CNTL;
  903. u32 CUR_OFFSET;
  904. u32 CUR2_OFFSET;
  905. };
  906. extern void r100_cp_disable(struct radeon_device *rdev);
  907. extern int r100_cp_init(struct radeon_device *rdev, unsigned ring_size);
  908. extern void r100_cp_fini(struct radeon_device *rdev);
  909. extern void r100_pci_gart_tlb_flush(struct radeon_device *rdev);
  910. extern int r100_pci_gart_init(struct radeon_device *rdev);
  911. extern void r100_pci_gart_fini(struct radeon_device *rdev);
  912. extern int r100_pci_gart_enable(struct radeon_device *rdev);
  913. extern void r100_pci_gart_disable(struct radeon_device *rdev);
  914. extern int r100_pci_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr);
  915. extern int r100_debugfs_mc_info_init(struct radeon_device *rdev);
  916. extern int r100_gui_wait_for_idle(struct radeon_device *rdev);
  917. extern void r100_ib_fini(struct radeon_device *rdev);
  918. extern int r100_ib_init(struct radeon_device *rdev);
  919. extern void r100_irq_disable(struct radeon_device *rdev);
  920. extern int r100_irq_set(struct radeon_device *rdev);
  921. extern void r100_mc_stop(struct radeon_device *rdev, struct r100_mc_save *save);
  922. extern void r100_mc_resume(struct radeon_device *rdev, struct r100_mc_save *save);
  923. extern void r100_vram_init_sizes(struct radeon_device *rdev);
  924. extern void r100_wb_disable(struct radeon_device *rdev);
  925. extern void r100_wb_fini(struct radeon_device *rdev);
  926. extern int r100_wb_init(struct radeon_device *rdev);
  927. extern void r100_hdp_reset(struct radeon_device *rdev);
  928. extern int r100_rb2d_reset(struct radeon_device *rdev);
  929. extern int r100_cp_reset(struct radeon_device *rdev);
  930. extern void r100_vga_render_disable(struct radeon_device *rdev);
  931. extern int r100_cs_track_check_pkt3_indx_buffer(struct radeon_cs_parser *p,
  932. struct radeon_cs_packet *pkt,
  933. struct radeon_bo *robj);
  934. extern int r100_cs_parse_packet0(struct radeon_cs_parser *p,
  935. struct radeon_cs_packet *pkt,
  936. const unsigned *auth, unsigned n,
  937. radeon_packet0_check_t check);
  938. extern int r100_cs_packet_parse(struct radeon_cs_parser *p,
  939. struct radeon_cs_packet *pkt,
  940. unsigned idx);
  941. extern void r100_enable_bm(struct radeon_device *rdev);
  942. /* rv200,rv250,rv280 */
  943. extern void r200_set_safe_registers(struct radeon_device *rdev);
  944. /* r300,r350,rv350,rv370,rv380 */
  945. extern void r300_set_reg_safe(struct radeon_device *rdev);
  946. extern void r300_mc_program(struct radeon_device *rdev);
  947. extern void r300_vram_info(struct radeon_device *rdev);
  948. extern void r300_clock_startup(struct radeon_device *rdev);
  949. extern int r300_mc_wait_for_idle(struct radeon_device *rdev);
  950. extern int rv370_pcie_gart_init(struct radeon_device *rdev);
  951. extern void rv370_pcie_gart_fini(struct radeon_device *rdev);
  952. extern int rv370_pcie_gart_enable(struct radeon_device *rdev);
  953. extern void rv370_pcie_gart_disable(struct radeon_device *rdev);
  954. /* r420,r423,rv410 */
  955. extern int r420_mc_init(struct radeon_device *rdev);
  956. extern u32 r420_mc_rreg(struct radeon_device *rdev, u32 reg);
  957. extern void r420_mc_wreg(struct radeon_device *rdev, u32 reg, u32 v);
  958. extern int r420_debugfs_pipes_info_init(struct radeon_device *rdev);
  959. extern void r420_pipes_init(struct radeon_device *rdev);
  960. /* rv515 */
  961. struct rv515_mc_save {
  962. u32 d1vga_control;
  963. u32 d2vga_control;
  964. u32 vga_render_control;
  965. u32 vga_hdp_control;
  966. u32 d1crtc_control;
  967. u32 d2crtc_control;
  968. };
  969. extern void rv515_bandwidth_avivo_update(struct radeon_device *rdev);
  970. extern void rv515_vga_render_disable(struct radeon_device *rdev);
  971. extern void rv515_set_safe_registers(struct radeon_device *rdev);
  972. extern void rv515_mc_stop(struct radeon_device *rdev, struct rv515_mc_save *save);
  973. extern void rv515_mc_resume(struct radeon_device *rdev, struct rv515_mc_save *save);
  974. extern void rv515_clock_startup(struct radeon_device *rdev);
  975. extern void rv515_debugfs(struct radeon_device *rdev);
  976. extern int rv515_suspend(struct radeon_device *rdev);
  977. /* rs400 */
  978. extern int rs400_gart_init(struct radeon_device *rdev);
  979. extern int rs400_gart_enable(struct radeon_device *rdev);
  980. extern void rs400_gart_adjust_size(struct radeon_device *rdev);
  981. extern void rs400_gart_disable(struct radeon_device *rdev);
  982. extern void rs400_gart_fini(struct radeon_device *rdev);
  983. /* rs600 */
  984. extern void rs600_set_safe_registers(struct radeon_device *rdev);
  985. extern int rs600_irq_set(struct radeon_device *rdev);
  986. extern void rs600_irq_disable(struct radeon_device *rdev);
  987. /* rs690, rs740 */
  988. extern void rs690_line_buffer_adjust(struct radeon_device *rdev,
  989. struct drm_display_mode *mode1,
  990. struct drm_display_mode *mode2);
  991. /* r600, rv610, rv630, rv620, rv635, rv670, rs780, rs880 */
  992. extern bool r600_card_posted(struct radeon_device *rdev);
  993. extern void r600_cp_stop(struct radeon_device *rdev);
  994. extern void r600_ring_init(struct radeon_device *rdev, unsigned ring_size);
  995. extern int r600_cp_resume(struct radeon_device *rdev);
  996. extern int r600_count_pipe_bits(uint32_t val);
  997. extern int r600_gart_clear_page(struct radeon_device *rdev, int i);
  998. extern int r600_mc_wait_for_idle(struct radeon_device *rdev);
  999. extern int r600_pcie_gart_init(struct radeon_device *rdev);
  1000. extern void r600_pcie_gart_tlb_flush(struct radeon_device *rdev);
  1001. extern int r600_ib_test(struct radeon_device *rdev);
  1002. extern int r600_ring_test(struct radeon_device *rdev);
  1003. extern void r600_wb_fini(struct radeon_device *rdev);
  1004. extern int r600_wb_enable(struct radeon_device *rdev);
  1005. extern void r600_wb_disable(struct radeon_device *rdev);
  1006. extern void r600_scratch_init(struct radeon_device *rdev);
  1007. extern int r600_blit_init(struct radeon_device *rdev);
  1008. extern void r600_blit_fini(struct radeon_device *rdev);
  1009. extern int r600_init_microcode(struct radeon_device *rdev);
  1010. extern int r600_gpu_reset(struct radeon_device *rdev);
  1011. /* r600 irq */
  1012. extern int r600_irq_init(struct radeon_device *rdev);
  1013. extern void r600_irq_fini(struct radeon_device *rdev);
  1014. extern void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size);
  1015. extern int r600_irq_set(struct radeon_device *rdev);
  1016. #include "radeon_object.h"
  1017. #endif