radeon.h 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638
  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 <linux/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 <ttm/ttm_execbuf_util.h>
  69. #include "radeon_family.h"
  70. #include "radeon_mode.h"
  71. #include "radeon_reg.h"
  72. /*
  73. * Modules parameters.
  74. */
  75. extern int radeon_no_wb;
  76. extern int radeon_modeset;
  77. extern int radeon_dynclks;
  78. extern int radeon_r4xx_atom;
  79. extern int radeon_agpmode;
  80. extern int radeon_vram_limit;
  81. extern int radeon_gart_size;
  82. extern int radeon_benchmarking;
  83. extern int radeon_testing;
  84. extern int radeon_connector_table;
  85. extern int radeon_tv;
  86. extern int radeon_audio;
  87. extern int radeon_disp_priority;
  88. extern int radeon_hw_i2c;
  89. extern int radeon_pcie_gen2;
  90. extern int radeon_msi;
  91. /*
  92. * Copy from radeon_drv.h so we don't have to include both and have conflicting
  93. * symbol;
  94. */
  95. #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */
  96. #define RADEON_FENCE_JIFFIES_TIMEOUT (HZ / 2)
  97. /* RADEON_IB_POOL_SIZE must be a power of 2 */
  98. #define RADEON_IB_POOL_SIZE 16
  99. #define RADEON_DEBUGFS_MAX_COMPONENTS 32
  100. #define RADEONFB_CONN_LIMIT 4
  101. #define RADEON_BIOS_NUM_SCRATCH 8
  102. /* max number of rings */
  103. #define RADEON_NUM_RINGS 3
  104. /* internal ring indices */
  105. /* r1xx+ has gfx CP ring */
  106. #define RADEON_RING_TYPE_GFX_INDEX 0
  107. /* cayman has 2 compute CP rings */
  108. #define CAYMAN_RING_TYPE_CP1_INDEX 1
  109. #define CAYMAN_RING_TYPE_CP2_INDEX 2
  110. /*
  111. * Errata workarounds.
  112. */
  113. enum radeon_pll_errata {
  114. CHIP_ERRATA_R300_CG = 0x00000001,
  115. CHIP_ERRATA_PLL_DUMMYREADS = 0x00000002,
  116. CHIP_ERRATA_PLL_DELAY = 0x00000004
  117. };
  118. struct radeon_device;
  119. /*
  120. * BIOS.
  121. */
  122. #define ATRM_BIOS_PAGE 4096
  123. #if defined(CONFIG_VGA_SWITCHEROO)
  124. bool radeon_atrm_supported(struct pci_dev *pdev);
  125. int radeon_atrm_get_bios_chunk(uint8_t *bios, int offset, int len);
  126. #else
  127. static inline bool radeon_atrm_supported(struct pci_dev *pdev)
  128. {
  129. return false;
  130. }
  131. static inline int radeon_atrm_get_bios_chunk(uint8_t *bios, int offset, int len){
  132. return -EINVAL;
  133. }
  134. #endif
  135. bool radeon_get_bios(struct radeon_device *rdev);
  136. /*
  137. * Dummy page
  138. */
  139. struct radeon_dummy_page {
  140. struct page *page;
  141. dma_addr_t addr;
  142. };
  143. int radeon_dummy_page_init(struct radeon_device *rdev);
  144. void radeon_dummy_page_fini(struct radeon_device *rdev);
  145. /*
  146. * Clocks
  147. */
  148. struct radeon_clock {
  149. struct radeon_pll p1pll;
  150. struct radeon_pll p2pll;
  151. struct radeon_pll dcpll;
  152. struct radeon_pll spll;
  153. struct radeon_pll mpll;
  154. /* 10 Khz units */
  155. uint32_t default_mclk;
  156. uint32_t default_sclk;
  157. uint32_t default_dispclk;
  158. uint32_t dp_extclk;
  159. uint32_t max_pixel_clock;
  160. };
  161. /*
  162. * Power management
  163. */
  164. int radeon_pm_init(struct radeon_device *rdev);
  165. void radeon_pm_fini(struct radeon_device *rdev);
  166. void radeon_pm_compute_clocks(struct radeon_device *rdev);
  167. void radeon_pm_suspend(struct radeon_device *rdev);
  168. void radeon_pm_resume(struct radeon_device *rdev);
  169. void radeon_combios_get_power_modes(struct radeon_device *rdev);
  170. void radeon_atombios_get_power_modes(struct radeon_device *rdev);
  171. void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type);
  172. int radeon_atom_get_max_vddc(struct radeon_device *rdev, u16 *voltage);
  173. void rs690_pm_info(struct radeon_device *rdev);
  174. extern int rv6xx_get_temp(struct radeon_device *rdev);
  175. extern int rv770_get_temp(struct radeon_device *rdev);
  176. extern int evergreen_get_temp(struct radeon_device *rdev);
  177. extern int sumo_get_temp(struct radeon_device *rdev);
  178. /*
  179. * Fences.
  180. */
  181. struct radeon_fence_driver {
  182. uint32_t scratch_reg;
  183. uint64_t gpu_addr;
  184. volatile uint32_t *cpu_addr;
  185. atomic_t seq;
  186. uint32_t last_seq;
  187. unsigned long last_jiffies;
  188. unsigned long last_timeout;
  189. wait_queue_head_t queue;
  190. struct list_head created;
  191. struct list_head emitted;
  192. struct list_head signaled;
  193. bool initialized;
  194. };
  195. struct radeon_fence {
  196. struct radeon_device *rdev;
  197. struct kref kref;
  198. struct list_head list;
  199. /* protected by radeon_fence.lock */
  200. uint32_t seq;
  201. bool emitted;
  202. bool signaled;
  203. /* RB, DMA, etc. */
  204. int ring;
  205. };
  206. int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring);
  207. int radeon_fence_driver_init(struct radeon_device *rdev);
  208. void radeon_fence_driver_fini(struct radeon_device *rdev);
  209. int radeon_fence_create(struct radeon_device *rdev, struct radeon_fence **fence, int ring);
  210. int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence);
  211. void radeon_fence_process(struct radeon_device *rdev, int ring);
  212. bool radeon_fence_signaled(struct radeon_fence *fence);
  213. int radeon_fence_wait(struct radeon_fence *fence, bool interruptible);
  214. int radeon_fence_wait_next(struct radeon_device *rdev, int ring);
  215. int radeon_fence_wait_last(struct radeon_device *rdev, int ring);
  216. struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence);
  217. void radeon_fence_unref(struct radeon_fence **fence);
  218. int radeon_fence_count_emitted(struct radeon_device *rdev, int ring);
  219. /*
  220. * Semaphores.
  221. */
  222. struct radeon_ring;
  223. struct radeon_semaphore_driver {
  224. rwlock_t lock;
  225. struct list_head free;
  226. };
  227. struct radeon_semaphore {
  228. struct radeon_bo *robj;
  229. struct list_head list;
  230. uint64_t gpu_addr;
  231. };
  232. void radeon_semaphore_driver_fini(struct radeon_device *rdev);
  233. int radeon_semaphore_create(struct radeon_device *rdev,
  234. struct radeon_semaphore **semaphore);
  235. void radeon_semaphore_emit_signal(struct radeon_device *rdev, int ring,
  236. struct radeon_semaphore *semaphore);
  237. void radeon_semaphore_emit_wait(struct radeon_device *rdev, int ring,
  238. struct radeon_semaphore *semaphore);
  239. void radeon_semaphore_free(struct radeon_device *rdev,
  240. struct radeon_semaphore *semaphore);
  241. /*
  242. * Tiling registers
  243. */
  244. struct radeon_surface_reg {
  245. struct radeon_bo *bo;
  246. };
  247. #define RADEON_GEM_MAX_SURFACES 8
  248. /*
  249. * TTM.
  250. */
  251. struct radeon_mman {
  252. struct ttm_bo_global_ref bo_global_ref;
  253. struct drm_global_reference mem_global_ref;
  254. struct ttm_bo_device bdev;
  255. bool mem_global_referenced;
  256. bool initialized;
  257. };
  258. struct radeon_bo {
  259. /* Protected by gem.mutex */
  260. struct list_head list;
  261. /* Protected by tbo.reserved */
  262. u32 placements[3];
  263. struct ttm_placement placement;
  264. struct ttm_buffer_object tbo;
  265. struct ttm_bo_kmap_obj kmap;
  266. unsigned pin_count;
  267. void *kptr;
  268. u32 tiling_flags;
  269. u32 pitch;
  270. int surface_reg;
  271. /* Constant after initialization */
  272. struct radeon_device *rdev;
  273. struct drm_gem_object gem_base;
  274. };
  275. #define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base)
  276. struct radeon_bo_list {
  277. struct ttm_validate_buffer tv;
  278. struct radeon_bo *bo;
  279. uint64_t gpu_offset;
  280. unsigned rdomain;
  281. unsigned wdomain;
  282. u32 tiling_flags;
  283. };
  284. /* sub-allocation manager, it has to be protected by another lock.
  285. * By conception this is an helper for other part of the driver
  286. * like the indirect buffer or semaphore, which both have their
  287. * locking.
  288. *
  289. * Principe is simple, we keep a list of sub allocation in offset
  290. * order (first entry has offset == 0, last entry has the highest
  291. * offset).
  292. *
  293. * When allocating new object we first check if there is room at
  294. * the end total_size - (last_object_offset + last_object_size) >=
  295. * alloc_size. If so we allocate new object there.
  296. *
  297. * When there is not enough room at the end, we start waiting for
  298. * each sub object until we reach object_offset+object_size >=
  299. * alloc_size, this object then become the sub object we return.
  300. *
  301. * Alignment can't be bigger than page size.
  302. *
  303. * Hole are not considered for allocation to keep things simple.
  304. * Assumption is that there won't be hole (all object on same
  305. * alignment).
  306. */
  307. struct radeon_sa_manager {
  308. struct radeon_bo *bo;
  309. struct list_head sa_bo;
  310. unsigned size;
  311. uint64_t gpu_addr;
  312. void *cpu_ptr;
  313. uint32_t domain;
  314. };
  315. struct radeon_sa_bo;
  316. /* sub-allocation buffer */
  317. struct radeon_sa_bo {
  318. struct list_head list;
  319. struct radeon_sa_manager *manager;
  320. unsigned offset;
  321. unsigned size;
  322. };
  323. /*
  324. * GEM objects.
  325. */
  326. struct radeon_gem {
  327. struct mutex mutex;
  328. struct list_head objects;
  329. };
  330. int radeon_gem_init(struct radeon_device *rdev);
  331. void radeon_gem_fini(struct radeon_device *rdev);
  332. int radeon_gem_object_create(struct radeon_device *rdev, int size,
  333. int alignment, int initial_domain,
  334. bool discardable, bool kernel,
  335. struct drm_gem_object **obj);
  336. int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain,
  337. uint64_t *gpu_addr);
  338. void radeon_gem_object_unpin(struct drm_gem_object *obj);
  339. int radeon_mode_dumb_create(struct drm_file *file_priv,
  340. struct drm_device *dev,
  341. struct drm_mode_create_dumb *args);
  342. int radeon_mode_dumb_mmap(struct drm_file *filp,
  343. struct drm_device *dev,
  344. uint32_t handle, uint64_t *offset_p);
  345. int radeon_mode_dumb_destroy(struct drm_file *file_priv,
  346. struct drm_device *dev,
  347. uint32_t handle);
  348. /*
  349. * GART structures, functions & helpers
  350. */
  351. struct radeon_mc;
  352. #define RADEON_GPU_PAGE_SIZE 4096
  353. #define RADEON_GPU_PAGE_MASK (RADEON_GPU_PAGE_SIZE - 1)
  354. #define RADEON_GPU_PAGE_SHIFT 12
  355. struct radeon_gart {
  356. dma_addr_t table_addr;
  357. struct radeon_bo *robj;
  358. void *ptr;
  359. unsigned num_gpu_pages;
  360. unsigned num_cpu_pages;
  361. unsigned table_size;
  362. struct page **pages;
  363. dma_addr_t *pages_addr;
  364. bool ready;
  365. };
  366. int radeon_gart_table_ram_alloc(struct radeon_device *rdev);
  367. void radeon_gart_table_ram_free(struct radeon_device *rdev);
  368. int radeon_gart_table_vram_alloc(struct radeon_device *rdev);
  369. void radeon_gart_table_vram_free(struct radeon_device *rdev);
  370. int radeon_gart_table_vram_pin(struct radeon_device *rdev);
  371. void radeon_gart_table_vram_unpin(struct radeon_device *rdev);
  372. int radeon_gart_init(struct radeon_device *rdev);
  373. void radeon_gart_fini(struct radeon_device *rdev);
  374. void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset,
  375. int pages);
  376. int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
  377. int pages, struct page **pagelist,
  378. dma_addr_t *dma_addr);
  379. void radeon_gart_restore(struct radeon_device *rdev);
  380. /*
  381. * GPU MC structures, functions & helpers
  382. */
  383. struct radeon_mc {
  384. resource_size_t aper_size;
  385. resource_size_t aper_base;
  386. resource_size_t agp_base;
  387. /* for some chips with <= 32MB we need to lie
  388. * about vram size near mc fb location */
  389. u64 mc_vram_size;
  390. u64 visible_vram_size;
  391. u64 gtt_size;
  392. u64 gtt_start;
  393. u64 gtt_end;
  394. u64 vram_start;
  395. u64 vram_end;
  396. unsigned vram_width;
  397. u64 real_vram_size;
  398. int vram_mtrr;
  399. bool vram_is_ddr;
  400. bool igp_sideport_enabled;
  401. u64 gtt_base_align;
  402. };
  403. bool radeon_combios_sideport_present(struct radeon_device *rdev);
  404. bool radeon_atombios_sideport_present(struct radeon_device *rdev);
  405. /*
  406. * GPU scratch registers structures, functions & helpers
  407. */
  408. struct radeon_scratch {
  409. unsigned num_reg;
  410. uint32_t reg_base;
  411. bool free[32];
  412. uint32_t reg[32];
  413. };
  414. int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg);
  415. void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg);
  416. /*
  417. * IRQS.
  418. */
  419. struct radeon_unpin_work {
  420. struct work_struct work;
  421. struct radeon_device *rdev;
  422. int crtc_id;
  423. struct radeon_fence *fence;
  424. struct drm_pending_vblank_event *event;
  425. struct radeon_bo *old_rbo;
  426. u64 new_crtc_base;
  427. };
  428. struct r500_irq_stat_regs {
  429. u32 disp_int;
  430. };
  431. struct r600_irq_stat_regs {
  432. u32 disp_int;
  433. u32 disp_int_cont;
  434. u32 disp_int_cont2;
  435. u32 d1grph_int;
  436. u32 d2grph_int;
  437. };
  438. struct evergreen_irq_stat_regs {
  439. u32 disp_int;
  440. u32 disp_int_cont;
  441. u32 disp_int_cont2;
  442. u32 disp_int_cont3;
  443. u32 disp_int_cont4;
  444. u32 disp_int_cont5;
  445. u32 d1grph_int;
  446. u32 d2grph_int;
  447. u32 d3grph_int;
  448. u32 d4grph_int;
  449. u32 d5grph_int;
  450. u32 d6grph_int;
  451. };
  452. union radeon_irq_stat_regs {
  453. struct r500_irq_stat_regs r500;
  454. struct r600_irq_stat_regs r600;
  455. struct evergreen_irq_stat_regs evergreen;
  456. };
  457. #define RADEON_MAX_HPD_PINS 6
  458. #define RADEON_MAX_CRTCS 6
  459. #define RADEON_MAX_HDMI_BLOCKS 2
  460. struct radeon_irq {
  461. bool installed;
  462. bool sw_int[RADEON_NUM_RINGS];
  463. bool crtc_vblank_int[RADEON_MAX_CRTCS];
  464. bool pflip[RADEON_MAX_CRTCS];
  465. wait_queue_head_t vblank_queue;
  466. bool hpd[RADEON_MAX_HPD_PINS];
  467. bool gui_idle;
  468. bool gui_idle_acked;
  469. wait_queue_head_t idle_queue;
  470. bool hdmi[RADEON_MAX_HDMI_BLOCKS];
  471. spinlock_t sw_lock;
  472. int sw_refcount[RADEON_NUM_RINGS];
  473. union radeon_irq_stat_regs stat_regs;
  474. spinlock_t pflip_lock[RADEON_MAX_CRTCS];
  475. int pflip_refcount[RADEON_MAX_CRTCS];
  476. };
  477. int radeon_irq_kms_init(struct radeon_device *rdev);
  478. void radeon_irq_kms_fini(struct radeon_device *rdev);
  479. void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev, int ring);
  480. void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev, int ring);
  481. void radeon_irq_kms_pflip_irq_get(struct radeon_device *rdev, int crtc);
  482. void radeon_irq_kms_pflip_irq_put(struct radeon_device *rdev, int crtc);
  483. /*
  484. * CP & rings.
  485. */
  486. struct radeon_ib {
  487. struct radeon_sa_bo sa_bo;
  488. unsigned idx;
  489. uint32_t length_dw;
  490. uint64_t gpu_addr;
  491. uint32_t *ptr;
  492. struct radeon_fence *fence;
  493. };
  494. /*
  495. * locking -
  496. * mutex protects scheduled_ibs, ready, alloc_bm
  497. */
  498. struct radeon_ib_pool {
  499. struct mutex mutex;
  500. struct radeon_sa_manager sa_manager;
  501. struct radeon_ib ibs[RADEON_IB_POOL_SIZE];
  502. bool ready;
  503. unsigned head_id;
  504. };
  505. struct radeon_ring {
  506. struct radeon_bo *ring_obj;
  507. volatile uint32_t *ring;
  508. unsigned rptr;
  509. unsigned rptr_offs;
  510. unsigned rptr_reg;
  511. unsigned wptr;
  512. unsigned wptr_old;
  513. unsigned wptr_reg;
  514. unsigned ring_size;
  515. unsigned ring_free_dw;
  516. int count_dw;
  517. uint64_t gpu_addr;
  518. uint32_t align_mask;
  519. uint32_t ptr_mask;
  520. struct mutex mutex;
  521. bool ready;
  522. u32 ptr_reg_shift;
  523. u32 ptr_reg_mask;
  524. u32 nop;
  525. };
  526. /*
  527. * R6xx+ IH ring
  528. */
  529. struct r600_ih {
  530. struct radeon_bo *ring_obj;
  531. volatile uint32_t *ring;
  532. unsigned rptr;
  533. unsigned rptr_offs;
  534. unsigned wptr;
  535. unsigned wptr_old;
  536. unsigned ring_size;
  537. uint64_t gpu_addr;
  538. uint32_t ptr_mask;
  539. spinlock_t lock;
  540. bool enabled;
  541. };
  542. struct r600_blit_cp_primitives {
  543. void (*set_render_target)(struct radeon_device *rdev, int format,
  544. int w, int h, u64 gpu_addr);
  545. void (*cp_set_surface_sync)(struct radeon_device *rdev,
  546. u32 sync_type, u32 size,
  547. u64 mc_addr);
  548. void (*set_shaders)(struct radeon_device *rdev);
  549. void (*set_vtx_resource)(struct radeon_device *rdev, u64 gpu_addr);
  550. void (*set_tex_resource)(struct radeon_device *rdev,
  551. int format, int w, int h, int pitch,
  552. u64 gpu_addr, u32 size);
  553. void (*set_scissors)(struct radeon_device *rdev, int x1, int y1,
  554. int x2, int y2);
  555. void (*draw_auto)(struct radeon_device *rdev);
  556. void (*set_default_state)(struct radeon_device *rdev);
  557. };
  558. struct r600_blit {
  559. struct mutex mutex;
  560. struct radeon_bo *shader_obj;
  561. struct r600_blit_cp_primitives primitives;
  562. int max_dim;
  563. int ring_size_common;
  564. int ring_size_per_loop;
  565. u64 shader_gpu_addr;
  566. u32 vs_offset, ps_offset;
  567. u32 state_offset;
  568. u32 state_len;
  569. u32 vb_used, vb_total;
  570. struct radeon_ib *vb_ib;
  571. };
  572. void r600_blit_suspend(struct radeon_device *rdev);
  573. int radeon_ib_get(struct radeon_device *rdev, int ring, struct radeon_ib **ib);
  574. void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib);
  575. int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib);
  576. int radeon_ib_pool_init(struct radeon_device *rdev);
  577. void radeon_ib_pool_fini(struct radeon_device *rdev);
  578. int radeon_ib_pool_start(struct radeon_device *rdev);
  579. int radeon_ib_pool_suspend(struct radeon_device *rdev);
  580. int radeon_ib_test(struct radeon_device *rdev);
  581. /* Ring access between begin & end cannot sleep */
  582. int radeon_ring_index(struct radeon_device *rdev, struct radeon_ring *cp);
  583. void radeon_ring_free_size(struct radeon_device *rdev, struct radeon_ring *cp);
  584. int radeon_ring_alloc(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ndw);
  585. int radeon_ring_lock(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ndw);
  586. void radeon_ring_commit(struct radeon_device *rdev, struct radeon_ring *cp);
  587. void radeon_ring_unlock_commit(struct radeon_device *rdev, struct radeon_ring *cp);
  588. void radeon_ring_unlock_undo(struct radeon_device *rdev, struct radeon_ring *cp);
  589. int radeon_ring_test(struct radeon_device *rdev, struct radeon_ring *cp);
  590. int radeon_ring_init(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ring_size,
  591. unsigned rptr_offs, unsigned rptr_reg, unsigned wptr_reg,
  592. u32 ptr_reg_shift, u32 ptr_reg_mask, u32 nop);
  593. void radeon_ring_fini(struct radeon_device *rdev, struct radeon_ring *cp);
  594. /*
  595. * CS.
  596. */
  597. struct radeon_cs_reloc {
  598. struct drm_gem_object *gobj;
  599. struct radeon_bo *robj;
  600. struct radeon_bo_list lobj;
  601. uint32_t handle;
  602. uint32_t flags;
  603. };
  604. struct radeon_cs_chunk {
  605. uint32_t chunk_id;
  606. uint32_t length_dw;
  607. int kpage_idx[2];
  608. uint32_t *kpage[2];
  609. uint32_t *kdata;
  610. void __user *user_ptr;
  611. int last_copied_page;
  612. int last_page_index;
  613. };
  614. struct radeon_cs_parser {
  615. struct device *dev;
  616. struct radeon_device *rdev;
  617. struct drm_file *filp;
  618. /* chunks */
  619. unsigned nchunks;
  620. struct radeon_cs_chunk *chunks;
  621. uint64_t *chunks_array;
  622. /* IB */
  623. unsigned idx;
  624. /* relocations */
  625. unsigned nrelocs;
  626. struct radeon_cs_reloc *relocs;
  627. struct radeon_cs_reloc **relocs_ptr;
  628. struct list_head validated;
  629. /* indices of various chunks */
  630. int chunk_ib_idx;
  631. int chunk_relocs_idx;
  632. struct radeon_ib *ib;
  633. void *track;
  634. unsigned family;
  635. int parser_error;
  636. bool keep_tiling_flags;
  637. };
  638. extern int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx);
  639. extern int radeon_cs_finish_pages(struct radeon_cs_parser *p);
  640. extern u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx);
  641. struct radeon_cs_packet {
  642. unsigned idx;
  643. unsigned type;
  644. unsigned reg;
  645. unsigned opcode;
  646. int count;
  647. unsigned one_reg_wr;
  648. };
  649. typedef int (*radeon_packet0_check_t)(struct radeon_cs_parser *p,
  650. struct radeon_cs_packet *pkt,
  651. unsigned idx, unsigned reg);
  652. typedef int (*radeon_packet3_check_t)(struct radeon_cs_parser *p,
  653. struct radeon_cs_packet *pkt);
  654. /*
  655. * AGP
  656. */
  657. int radeon_agp_init(struct radeon_device *rdev);
  658. void radeon_agp_resume(struct radeon_device *rdev);
  659. void radeon_agp_suspend(struct radeon_device *rdev);
  660. void radeon_agp_fini(struct radeon_device *rdev);
  661. /*
  662. * Writeback
  663. */
  664. struct radeon_wb {
  665. struct radeon_bo *wb_obj;
  666. volatile uint32_t *wb;
  667. uint64_t gpu_addr;
  668. bool enabled;
  669. bool use_event;
  670. };
  671. #define RADEON_WB_SCRATCH_OFFSET 0
  672. #define RADEON_WB_CP_RPTR_OFFSET 1024
  673. #define RADEON_WB_CP1_RPTR_OFFSET 1280
  674. #define RADEON_WB_CP2_RPTR_OFFSET 1536
  675. #define R600_WB_IH_WPTR_OFFSET 2048
  676. #define R600_WB_EVENT_OFFSET 3072
  677. /**
  678. * struct radeon_pm - power management datas
  679. * @max_bandwidth: maximum bandwidth the gpu has (MByte/s)
  680. * @igp_sideport_mclk: sideport memory clock Mhz (rs690,rs740,rs780,rs880)
  681. * @igp_system_mclk: system clock Mhz (rs690,rs740,rs780,rs880)
  682. * @igp_ht_link_clk: ht link clock Mhz (rs690,rs740,rs780,rs880)
  683. * @igp_ht_link_width: ht link width in bits (rs690,rs740,rs780,rs880)
  684. * @k8_bandwidth: k8 bandwidth the gpu has (MByte/s) (IGP)
  685. * @sideport_bandwidth: sideport bandwidth the gpu has (MByte/s) (IGP)
  686. * @ht_bandwidth: ht bandwidth the gpu has (MByte/s) (IGP)
  687. * @core_bandwidth: core GPU bandwidth the gpu has (MByte/s) (IGP)
  688. * @sclk: GPU clock Mhz (core bandwidth depends of this clock)
  689. * @needed_bandwidth: current bandwidth needs
  690. *
  691. * It keeps track of various data needed to take powermanagement decision.
  692. * Bandwidth need is used to determine minimun clock of the GPU and memory.
  693. * Equation between gpu/memory clock and available bandwidth is hw dependent
  694. * (type of memory, bus size, efficiency, ...)
  695. */
  696. enum radeon_pm_method {
  697. PM_METHOD_PROFILE,
  698. PM_METHOD_DYNPM,
  699. };
  700. enum radeon_dynpm_state {
  701. DYNPM_STATE_DISABLED,
  702. DYNPM_STATE_MINIMUM,
  703. DYNPM_STATE_PAUSED,
  704. DYNPM_STATE_ACTIVE,
  705. DYNPM_STATE_SUSPENDED,
  706. };
  707. enum radeon_dynpm_action {
  708. DYNPM_ACTION_NONE,
  709. DYNPM_ACTION_MINIMUM,
  710. DYNPM_ACTION_DOWNCLOCK,
  711. DYNPM_ACTION_UPCLOCK,
  712. DYNPM_ACTION_DEFAULT
  713. };
  714. enum radeon_voltage_type {
  715. VOLTAGE_NONE = 0,
  716. VOLTAGE_GPIO,
  717. VOLTAGE_VDDC,
  718. VOLTAGE_SW
  719. };
  720. enum radeon_pm_state_type {
  721. POWER_STATE_TYPE_DEFAULT,
  722. POWER_STATE_TYPE_POWERSAVE,
  723. POWER_STATE_TYPE_BATTERY,
  724. POWER_STATE_TYPE_BALANCED,
  725. POWER_STATE_TYPE_PERFORMANCE,
  726. };
  727. enum radeon_pm_profile_type {
  728. PM_PROFILE_DEFAULT,
  729. PM_PROFILE_AUTO,
  730. PM_PROFILE_LOW,
  731. PM_PROFILE_MID,
  732. PM_PROFILE_HIGH,
  733. };
  734. #define PM_PROFILE_DEFAULT_IDX 0
  735. #define PM_PROFILE_LOW_SH_IDX 1
  736. #define PM_PROFILE_MID_SH_IDX 2
  737. #define PM_PROFILE_HIGH_SH_IDX 3
  738. #define PM_PROFILE_LOW_MH_IDX 4
  739. #define PM_PROFILE_MID_MH_IDX 5
  740. #define PM_PROFILE_HIGH_MH_IDX 6
  741. #define PM_PROFILE_MAX 7
  742. struct radeon_pm_profile {
  743. int dpms_off_ps_idx;
  744. int dpms_on_ps_idx;
  745. int dpms_off_cm_idx;
  746. int dpms_on_cm_idx;
  747. };
  748. enum radeon_int_thermal_type {
  749. THERMAL_TYPE_NONE,
  750. THERMAL_TYPE_RV6XX,
  751. THERMAL_TYPE_RV770,
  752. THERMAL_TYPE_EVERGREEN,
  753. THERMAL_TYPE_SUMO,
  754. THERMAL_TYPE_NI,
  755. };
  756. struct radeon_voltage {
  757. enum radeon_voltage_type type;
  758. /* gpio voltage */
  759. struct radeon_gpio_rec gpio;
  760. u32 delay; /* delay in usec from voltage drop to sclk change */
  761. bool active_high; /* voltage drop is active when bit is high */
  762. /* VDDC voltage */
  763. u8 vddc_id; /* index into vddc voltage table */
  764. u8 vddci_id; /* index into vddci voltage table */
  765. bool vddci_enabled;
  766. /* r6xx+ sw */
  767. u16 voltage;
  768. /* evergreen+ vddci */
  769. u16 vddci;
  770. };
  771. /* clock mode flags */
  772. #define RADEON_PM_MODE_NO_DISPLAY (1 << 0)
  773. struct radeon_pm_clock_info {
  774. /* memory clock */
  775. u32 mclk;
  776. /* engine clock */
  777. u32 sclk;
  778. /* voltage info */
  779. struct radeon_voltage voltage;
  780. /* standardized clock flags */
  781. u32 flags;
  782. };
  783. /* state flags */
  784. #define RADEON_PM_STATE_SINGLE_DISPLAY_ONLY (1 << 0)
  785. struct radeon_power_state {
  786. enum radeon_pm_state_type type;
  787. struct radeon_pm_clock_info *clock_info;
  788. /* number of valid clock modes in this power state */
  789. int num_clock_modes;
  790. struct radeon_pm_clock_info *default_clock_mode;
  791. /* standardized state flags */
  792. u32 flags;
  793. u32 misc; /* vbios specific flags */
  794. u32 misc2; /* vbios specific flags */
  795. int pcie_lanes; /* pcie lanes */
  796. };
  797. /*
  798. * Some modes are overclocked by very low value, accept them
  799. */
  800. #define RADEON_MODE_OVERCLOCK_MARGIN 500 /* 5 MHz */
  801. struct radeon_pm {
  802. struct mutex mutex;
  803. u32 active_crtcs;
  804. int active_crtc_count;
  805. int req_vblank;
  806. bool vblank_sync;
  807. bool gui_idle;
  808. fixed20_12 max_bandwidth;
  809. fixed20_12 igp_sideport_mclk;
  810. fixed20_12 igp_system_mclk;
  811. fixed20_12 igp_ht_link_clk;
  812. fixed20_12 igp_ht_link_width;
  813. fixed20_12 k8_bandwidth;
  814. fixed20_12 sideport_bandwidth;
  815. fixed20_12 ht_bandwidth;
  816. fixed20_12 core_bandwidth;
  817. fixed20_12 sclk;
  818. fixed20_12 mclk;
  819. fixed20_12 needed_bandwidth;
  820. struct radeon_power_state *power_state;
  821. /* number of valid power states */
  822. int num_power_states;
  823. int current_power_state_index;
  824. int current_clock_mode_index;
  825. int requested_power_state_index;
  826. int requested_clock_mode_index;
  827. int default_power_state_index;
  828. u32 current_sclk;
  829. u32 current_mclk;
  830. u16 current_vddc;
  831. u16 current_vddci;
  832. u32 default_sclk;
  833. u32 default_mclk;
  834. u16 default_vddc;
  835. u16 default_vddci;
  836. struct radeon_i2c_chan *i2c_bus;
  837. /* selected pm method */
  838. enum radeon_pm_method pm_method;
  839. /* dynpm power management */
  840. struct delayed_work dynpm_idle_work;
  841. enum radeon_dynpm_state dynpm_state;
  842. enum radeon_dynpm_action dynpm_planned_action;
  843. unsigned long dynpm_action_timeout;
  844. bool dynpm_can_upclock;
  845. bool dynpm_can_downclock;
  846. /* profile-based power management */
  847. enum radeon_pm_profile_type profile;
  848. int profile_index;
  849. struct radeon_pm_profile profiles[PM_PROFILE_MAX];
  850. /* internal thermal controller on rv6xx+ */
  851. enum radeon_int_thermal_type int_thermal_type;
  852. struct device *int_hwmon_dev;
  853. };
  854. int radeon_pm_get_type_index(struct radeon_device *rdev,
  855. enum radeon_pm_state_type ps_type,
  856. int instance);
  857. /*
  858. * Benchmarking
  859. */
  860. void radeon_benchmark(struct radeon_device *rdev, int test_number);
  861. /*
  862. * Testing
  863. */
  864. void radeon_test_moves(struct radeon_device *rdev);
  865. void radeon_test_ring_sync(struct radeon_device *rdev,
  866. struct radeon_ring *cpA,
  867. struct radeon_ring *cpB);
  868. void radeon_test_syncing(struct radeon_device *rdev);
  869. /*
  870. * Debugfs
  871. */
  872. struct radeon_debugfs {
  873. struct drm_info_list *files;
  874. unsigned num_files;
  875. };
  876. int radeon_debugfs_add_files(struct radeon_device *rdev,
  877. struct drm_info_list *files,
  878. unsigned nfiles);
  879. int radeon_debugfs_fence_init(struct radeon_device *rdev);
  880. /*
  881. * ASIC specific functions.
  882. */
  883. struct radeon_asic {
  884. int (*init)(struct radeon_device *rdev);
  885. void (*fini)(struct radeon_device *rdev);
  886. int (*resume)(struct radeon_device *rdev);
  887. int (*suspend)(struct radeon_device *rdev);
  888. void (*vga_set_state)(struct radeon_device *rdev, bool state);
  889. bool (*gpu_is_lockup)(struct radeon_device *rdev, struct radeon_ring *cp);
  890. int (*asic_reset)(struct radeon_device *rdev);
  891. void (*gart_tlb_flush)(struct radeon_device *rdev);
  892. int (*gart_set_page)(struct radeon_device *rdev, int i, uint64_t addr);
  893. int (*cp_init)(struct radeon_device *rdev, unsigned ring_size);
  894. void (*cp_fini)(struct radeon_device *rdev);
  895. void (*cp_disable)(struct radeon_device *rdev);
  896. void (*ring_start)(struct radeon_device *rdev);
  897. struct {
  898. void (*ib_execute)(struct radeon_device *rdev, struct radeon_ib *ib);
  899. void (*emit_fence)(struct radeon_device *rdev, struct radeon_fence *fence);
  900. void (*emit_semaphore)(struct radeon_device *rdev, struct radeon_ring *cp,
  901. struct radeon_semaphore *semaphore, bool emit_wait);
  902. } ring[RADEON_NUM_RINGS];
  903. int (*ring_test)(struct radeon_device *rdev, struct radeon_ring *cp);
  904. int (*irq_set)(struct radeon_device *rdev);
  905. int (*irq_process)(struct radeon_device *rdev);
  906. u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
  907. int (*cs_parse)(struct radeon_cs_parser *p);
  908. int (*copy_blit)(struct radeon_device *rdev,
  909. uint64_t src_offset,
  910. uint64_t dst_offset,
  911. unsigned num_gpu_pages,
  912. struct radeon_fence *fence);
  913. int (*copy_dma)(struct radeon_device *rdev,
  914. uint64_t src_offset,
  915. uint64_t dst_offset,
  916. unsigned num_gpu_pages,
  917. struct radeon_fence *fence);
  918. int (*copy)(struct radeon_device *rdev,
  919. uint64_t src_offset,
  920. uint64_t dst_offset,
  921. unsigned num_gpu_pages,
  922. struct radeon_fence *fence);
  923. uint32_t (*get_engine_clock)(struct radeon_device *rdev);
  924. void (*set_engine_clock)(struct radeon_device *rdev, uint32_t eng_clock);
  925. uint32_t (*get_memory_clock)(struct radeon_device *rdev);
  926. void (*set_memory_clock)(struct radeon_device *rdev, uint32_t mem_clock);
  927. int (*get_pcie_lanes)(struct radeon_device *rdev);
  928. void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes);
  929. void (*set_clock_gating)(struct radeon_device *rdev, int enable);
  930. int (*set_surface_reg)(struct radeon_device *rdev, int reg,
  931. uint32_t tiling_flags, uint32_t pitch,
  932. uint32_t offset, uint32_t obj_size);
  933. void (*clear_surface_reg)(struct radeon_device *rdev, int reg);
  934. void (*bandwidth_update)(struct radeon_device *rdev);
  935. void (*hpd_init)(struct radeon_device *rdev);
  936. void (*hpd_fini)(struct radeon_device *rdev);
  937. bool (*hpd_sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
  938. void (*hpd_set_polarity)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
  939. /* ioctl hw specific callback. Some hw might want to perform special
  940. * operation on specific ioctl. For instance on wait idle some hw
  941. * might want to perform and HDP flush through MMIO as it seems that
  942. * some R6XX/R7XX hw doesn't take HDP flush into account if programmed
  943. * through ring.
  944. */
  945. void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo *bo);
  946. bool (*gui_idle)(struct radeon_device *rdev);
  947. /* power management */
  948. void (*pm_misc)(struct radeon_device *rdev);
  949. void (*pm_prepare)(struct radeon_device *rdev);
  950. void (*pm_finish)(struct radeon_device *rdev);
  951. void (*pm_init_profile)(struct radeon_device *rdev);
  952. void (*pm_get_dynpm_state)(struct radeon_device *rdev);
  953. /* pageflipping */
  954. void (*pre_page_flip)(struct radeon_device *rdev, int crtc);
  955. u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 crtc_base);
  956. void (*post_page_flip)(struct radeon_device *rdev, int crtc);
  957. };
  958. /*
  959. * Asic structures
  960. */
  961. struct r100_gpu_lockup {
  962. unsigned long last_jiffies;
  963. u32 last_cp_rptr;
  964. };
  965. struct r100_asic {
  966. const unsigned *reg_safe_bm;
  967. unsigned reg_safe_bm_size;
  968. u32 hdp_cntl;
  969. struct r100_gpu_lockup lockup;
  970. };
  971. struct r300_asic {
  972. const unsigned *reg_safe_bm;
  973. unsigned reg_safe_bm_size;
  974. u32 resync_scratch;
  975. u32 hdp_cntl;
  976. struct r100_gpu_lockup lockup;
  977. };
  978. struct r600_asic {
  979. unsigned max_pipes;
  980. unsigned max_tile_pipes;
  981. unsigned max_simds;
  982. unsigned max_backends;
  983. unsigned max_gprs;
  984. unsigned max_threads;
  985. unsigned max_stack_entries;
  986. unsigned max_hw_contexts;
  987. unsigned max_gs_threads;
  988. unsigned sx_max_export_size;
  989. unsigned sx_max_export_pos_size;
  990. unsigned sx_max_export_smx_size;
  991. unsigned sq_num_cf_insts;
  992. unsigned tiling_nbanks;
  993. unsigned tiling_npipes;
  994. unsigned tiling_group_size;
  995. unsigned tile_config;
  996. unsigned backend_map;
  997. struct r100_gpu_lockup lockup;
  998. };
  999. struct rv770_asic {
  1000. unsigned max_pipes;
  1001. unsigned max_tile_pipes;
  1002. unsigned max_simds;
  1003. unsigned max_backends;
  1004. unsigned max_gprs;
  1005. unsigned max_threads;
  1006. unsigned max_stack_entries;
  1007. unsigned max_hw_contexts;
  1008. unsigned max_gs_threads;
  1009. unsigned sx_max_export_size;
  1010. unsigned sx_max_export_pos_size;
  1011. unsigned sx_max_export_smx_size;
  1012. unsigned sq_num_cf_insts;
  1013. unsigned sx_num_of_sets;
  1014. unsigned sc_prim_fifo_size;
  1015. unsigned sc_hiz_tile_fifo_size;
  1016. unsigned sc_earlyz_tile_fifo_fize;
  1017. unsigned tiling_nbanks;
  1018. unsigned tiling_npipes;
  1019. unsigned tiling_group_size;
  1020. unsigned tile_config;
  1021. unsigned backend_map;
  1022. struct r100_gpu_lockup lockup;
  1023. };
  1024. struct evergreen_asic {
  1025. unsigned num_ses;
  1026. unsigned max_pipes;
  1027. unsigned max_tile_pipes;
  1028. unsigned max_simds;
  1029. unsigned max_backends;
  1030. unsigned max_gprs;
  1031. unsigned max_threads;
  1032. unsigned max_stack_entries;
  1033. unsigned max_hw_contexts;
  1034. unsigned max_gs_threads;
  1035. unsigned sx_max_export_size;
  1036. unsigned sx_max_export_pos_size;
  1037. unsigned sx_max_export_smx_size;
  1038. unsigned sq_num_cf_insts;
  1039. unsigned sx_num_of_sets;
  1040. unsigned sc_prim_fifo_size;
  1041. unsigned sc_hiz_tile_fifo_size;
  1042. unsigned sc_earlyz_tile_fifo_size;
  1043. unsigned tiling_nbanks;
  1044. unsigned tiling_npipes;
  1045. unsigned tiling_group_size;
  1046. unsigned tile_config;
  1047. unsigned backend_map;
  1048. struct r100_gpu_lockup lockup;
  1049. };
  1050. struct cayman_asic {
  1051. unsigned max_shader_engines;
  1052. unsigned max_pipes_per_simd;
  1053. unsigned max_tile_pipes;
  1054. unsigned max_simds_per_se;
  1055. unsigned max_backends_per_se;
  1056. unsigned max_texture_channel_caches;
  1057. unsigned max_gprs;
  1058. unsigned max_threads;
  1059. unsigned max_gs_threads;
  1060. unsigned max_stack_entries;
  1061. unsigned sx_num_of_sets;
  1062. unsigned sx_max_export_size;
  1063. unsigned sx_max_export_pos_size;
  1064. unsigned sx_max_export_smx_size;
  1065. unsigned max_hw_contexts;
  1066. unsigned sq_num_cf_insts;
  1067. unsigned sc_prim_fifo_size;
  1068. unsigned sc_hiz_tile_fifo_size;
  1069. unsigned sc_earlyz_tile_fifo_size;
  1070. unsigned num_shader_engines;
  1071. unsigned num_shader_pipes_per_simd;
  1072. unsigned num_tile_pipes;
  1073. unsigned num_simds_per_se;
  1074. unsigned num_backends_per_se;
  1075. unsigned backend_disable_mask_per_asic;
  1076. unsigned backend_map;
  1077. unsigned num_texture_channel_caches;
  1078. unsigned mem_max_burst_length_bytes;
  1079. unsigned mem_row_size_in_kb;
  1080. unsigned shader_engine_tile_size;
  1081. unsigned num_gpus;
  1082. unsigned multi_gpu_tile_size;
  1083. unsigned tile_config;
  1084. struct r100_gpu_lockup lockup;
  1085. };
  1086. union radeon_asic_config {
  1087. struct r300_asic r300;
  1088. struct r100_asic r100;
  1089. struct r600_asic r600;
  1090. struct rv770_asic rv770;
  1091. struct evergreen_asic evergreen;
  1092. struct cayman_asic cayman;
  1093. };
  1094. /*
  1095. * asic initizalization from radeon_asic.c
  1096. */
  1097. void radeon_agp_disable(struct radeon_device *rdev);
  1098. int radeon_asic_init(struct radeon_device *rdev);
  1099. /*
  1100. * IOCTL.
  1101. */
  1102. int radeon_gem_info_ioctl(struct drm_device *dev, void *data,
  1103. struct drm_file *filp);
  1104. int radeon_gem_create_ioctl(struct drm_device *dev, void *data,
  1105. struct drm_file *filp);
  1106. int radeon_gem_pin_ioctl(struct drm_device *dev, void *data,
  1107. struct drm_file *file_priv);
  1108. int radeon_gem_unpin_ioctl(struct drm_device *dev, void *data,
  1109. struct drm_file *file_priv);
  1110. int radeon_gem_pwrite_ioctl(struct drm_device *dev, void *data,
  1111. struct drm_file *file_priv);
  1112. int radeon_gem_pread_ioctl(struct drm_device *dev, void *data,
  1113. struct drm_file *file_priv);
  1114. int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data,
  1115. struct drm_file *filp);
  1116. int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data,
  1117. struct drm_file *filp);
  1118. int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
  1119. struct drm_file *filp);
  1120. int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
  1121. struct drm_file *filp);
  1122. int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);
  1123. int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data,
  1124. struct drm_file *filp);
  1125. int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data,
  1126. struct drm_file *filp);
  1127. /* VRAM scratch page for HDP bug, default vram page */
  1128. struct r600_vram_scratch {
  1129. struct radeon_bo *robj;
  1130. volatile uint32_t *ptr;
  1131. u64 gpu_addr;
  1132. };
  1133. /*
  1134. * Mutex which allows recursive locking from the same process.
  1135. */
  1136. struct radeon_mutex {
  1137. struct mutex mutex;
  1138. struct task_struct *owner;
  1139. int level;
  1140. };
  1141. static inline void radeon_mutex_init(struct radeon_mutex *mutex)
  1142. {
  1143. mutex_init(&mutex->mutex);
  1144. mutex->owner = NULL;
  1145. mutex->level = 0;
  1146. }
  1147. static inline void radeon_mutex_lock(struct radeon_mutex *mutex)
  1148. {
  1149. if (mutex_trylock(&mutex->mutex)) {
  1150. /* The mutex was unlocked before, so it's ours now */
  1151. mutex->owner = current;
  1152. } else if (mutex->owner != current) {
  1153. /* Another process locked the mutex, take it */
  1154. mutex_lock(&mutex->mutex);
  1155. mutex->owner = current;
  1156. }
  1157. /* Otherwise the mutex was already locked by this process */
  1158. mutex->level++;
  1159. }
  1160. static inline void radeon_mutex_unlock(struct radeon_mutex *mutex)
  1161. {
  1162. if (--mutex->level > 0)
  1163. return;
  1164. mutex->owner = NULL;
  1165. mutex_unlock(&mutex->mutex);
  1166. }
  1167. /*
  1168. * Core structure, functions and helpers.
  1169. */
  1170. typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t);
  1171. typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t);
  1172. struct radeon_device {
  1173. struct device *dev;
  1174. struct drm_device *ddev;
  1175. struct pci_dev *pdev;
  1176. /* ASIC */
  1177. union radeon_asic_config config;
  1178. enum radeon_family family;
  1179. unsigned long flags;
  1180. int usec_timeout;
  1181. enum radeon_pll_errata pll_errata;
  1182. int num_gb_pipes;
  1183. int num_z_pipes;
  1184. int disp_priority;
  1185. /* BIOS */
  1186. uint8_t *bios;
  1187. bool is_atom_bios;
  1188. uint16_t bios_header_start;
  1189. struct radeon_bo *stollen_vga_memory;
  1190. /* Register mmio */
  1191. resource_size_t rmmio_base;
  1192. resource_size_t rmmio_size;
  1193. void __iomem *rmmio;
  1194. radeon_rreg_t mc_rreg;
  1195. radeon_wreg_t mc_wreg;
  1196. radeon_rreg_t pll_rreg;
  1197. radeon_wreg_t pll_wreg;
  1198. uint32_t pcie_reg_mask;
  1199. radeon_rreg_t pciep_rreg;
  1200. radeon_wreg_t pciep_wreg;
  1201. /* io port */
  1202. void __iomem *rio_mem;
  1203. resource_size_t rio_mem_size;
  1204. struct radeon_clock clock;
  1205. struct radeon_mc mc;
  1206. struct radeon_gart gart;
  1207. struct radeon_mode_info mode_info;
  1208. struct radeon_scratch scratch;
  1209. struct radeon_mman mman;
  1210. rwlock_t fence_lock;
  1211. struct radeon_fence_driver fence_drv[RADEON_NUM_RINGS];
  1212. struct radeon_semaphore_driver semaphore_drv;
  1213. struct radeon_ring ring[RADEON_NUM_RINGS];
  1214. struct radeon_ib_pool ib_pool;
  1215. struct radeon_irq irq;
  1216. struct radeon_asic *asic;
  1217. struct radeon_gem gem;
  1218. struct radeon_pm pm;
  1219. uint32_t bios_scratch[RADEON_BIOS_NUM_SCRATCH];
  1220. struct radeon_mutex cs_mutex;
  1221. struct radeon_wb wb;
  1222. struct radeon_dummy_page dummy_page;
  1223. bool gpu_lockup;
  1224. bool shutdown;
  1225. bool suspend;
  1226. bool need_dma32;
  1227. bool accel_working;
  1228. struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES];
  1229. const struct firmware *me_fw; /* all family ME firmware */
  1230. const struct firmware *pfp_fw; /* r6/700 PFP firmware */
  1231. const struct firmware *rlc_fw; /* r6/700 RLC firmware */
  1232. const struct firmware *mc_fw; /* NI MC firmware */
  1233. struct r600_blit r600_blit;
  1234. struct r600_vram_scratch vram_scratch;
  1235. int msi_enabled; /* msi enabled */
  1236. struct r600_ih ih; /* r6/700 interrupt ring */
  1237. struct work_struct hotplug_work;
  1238. int num_crtc; /* number of crtcs */
  1239. struct mutex dc_hw_i2c_mutex; /* display controller hw i2c mutex */
  1240. struct mutex vram_mutex;
  1241. /* audio stuff */
  1242. bool audio_enabled;
  1243. struct timer_list audio_timer;
  1244. int audio_channels;
  1245. int audio_rate;
  1246. int audio_bits_per_sample;
  1247. uint8_t audio_status_bits;
  1248. uint8_t audio_category_code;
  1249. struct notifier_block acpi_nb;
  1250. /* only one userspace can use Hyperz features or CMASK at a time */
  1251. struct drm_file *hyperz_filp;
  1252. struct drm_file *cmask_filp;
  1253. /* i2c buses */
  1254. struct radeon_i2c_chan *i2c_bus[RADEON_MAX_I2C_BUS];
  1255. /* debugfs */
  1256. struct radeon_debugfs debugfs[RADEON_DEBUGFS_MAX_COMPONENTS];
  1257. unsigned debugfs_count;
  1258. };
  1259. int radeon_device_init(struct radeon_device *rdev,
  1260. struct drm_device *ddev,
  1261. struct pci_dev *pdev,
  1262. uint32_t flags);
  1263. void radeon_device_fini(struct radeon_device *rdev);
  1264. int radeon_gpu_wait_for_idle(struct radeon_device *rdev);
  1265. uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg);
  1266. void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v);
  1267. u32 r100_io_rreg(struct radeon_device *rdev, u32 reg);
  1268. void r100_io_wreg(struct radeon_device *rdev, u32 reg, u32 v);
  1269. /*
  1270. * Cast helper
  1271. */
  1272. #define to_radeon_fence(p) ((struct radeon_fence *)(p))
  1273. /*
  1274. * Registers read & write functions.
  1275. */
  1276. #define RREG8(reg) readb((rdev->rmmio) + (reg))
  1277. #define WREG8(reg, v) writeb(v, (rdev->rmmio) + (reg))
  1278. #define RREG16(reg) readw((rdev->rmmio) + (reg))
  1279. #define WREG16(reg, v) writew(v, (rdev->rmmio) + (reg))
  1280. #define RREG32(reg) r100_mm_rreg(rdev, (reg))
  1281. #define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", r100_mm_rreg(rdev, (reg)))
  1282. #define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v))
  1283. #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
  1284. #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
  1285. #define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg))
  1286. #define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v))
  1287. #define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg))
  1288. #define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v))
  1289. #define RREG32_PCIE(reg) rv370_pcie_rreg(rdev, (reg))
  1290. #define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v))
  1291. #define RREG32_PCIE_P(reg) rdev->pciep_rreg(rdev, (reg))
  1292. #define WREG32_PCIE_P(reg, v) rdev->pciep_wreg(rdev, (reg), (v))
  1293. #define WREG32_P(reg, val, mask) \
  1294. do { \
  1295. uint32_t tmp_ = RREG32(reg); \
  1296. tmp_ &= (mask); \
  1297. tmp_ |= ((val) & ~(mask)); \
  1298. WREG32(reg, tmp_); \
  1299. } while (0)
  1300. #define WREG32_PLL_P(reg, val, mask) \
  1301. do { \
  1302. uint32_t tmp_ = RREG32_PLL(reg); \
  1303. tmp_ &= (mask); \
  1304. tmp_ |= ((val) & ~(mask)); \
  1305. WREG32_PLL(reg, tmp_); \
  1306. } while (0)
  1307. #define DREG32_SYS(sqf, rdev, reg) seq_printf((sqf), #reg " : 0x%08X\n", r100_mm_rreg((rdev), (reg)))
  1308. #define RREG32_IO(reg) r100_io_rreg(rdev, (reg))
  1309. #define WREG32_IO(reg, v) r100_io_wreg(rdev, (reg), (v))
  1310. /*
  1311. * Indirect registers accessor
  1312. */
  1313. static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg)
  1314. {
  1315. uint32_t r;
  1316. WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
  1317. r = RREG32(RADEON_PCIE_DATA);
  1318. return r;
  1319. }
  1320. static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
  1321. {
  1322. WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
  1323. WREG32(RADEON_PCIE_DATA, (v));
  1324. }
  1325. void r100_pll_errata_after_index(struct radeon_device *rdev);
  1326. /*
  1327. * ASICs helpers.
  1328. */
  1329. #define ASIC_IS_RN50(rdev) ((rdev->pdev->device == 0x515e) || \
  1330. (rdev->pdev->device == 0x5969))
  1331. #define ASIC_IS_RV100(rdev) ((rdev->family == CHIP_RV100) || \
  1332. (rdev->family == CHIP_RV200) || \
  1333. (rdev->family == CHIP_RS100) || \
  1334. (rdev->family == CHIP_RS200) || \
  1335. (rdev->family == CHIP_RV250) || \
  1336. (rdev->family == CHIP_RV280) || \
  1337. (rdev->family == CHIP_RS300))
  1338. #define ASIC_IS_R300(rdev) ((rdev->family == CHIP_R300) || \
  1339. (rdev->family == CHIP_RV350) || \
  1340. (rdev->family == CHIP_R350) || \
  1341. (rdev->family == CHIP_RV380) || \
  1342. (rdev->family == CHIP_R420) || \
  1343. (rdev->family == CHIP_R423) || \
  1344. (rdev->family == CHIP_RV410) || \
  1345. (rdev->family == CHIP_RS400) || \
  1346. (rdev->family == CHIP_RS480))
  1347. #define ASIC_IS_X2(rdev) ((rdev->ddev->pdev->device == 0x9441) || \
  1348. (rdev->ddev->pdev->device == 0x9443) || \
  1349. (rdev->ddev->pdev->device == 0x944B) || \
  1350. (rdev->ddev->pdev->device == 0x9506) || \
  1351. (rdev->ddev->pdev->device == 0x9509) || \
  1352. (rdev->ddev->pdev->device == 0x950F) || \
  1353. (rdev->ddev->pdev->device == 0x689C) || \
  1354. (rdev->ddev->pdev->device == 0x689D))
  1355. #define ASIC_IS_AVIVO(rdev) ((rdev->family >= CHIP_RS600))
  1356. #define ASIC_IS_DCE2(rdev) ((rdev->family == CHIP_RS600) || \
  1357. (rdev->family == CHIP_RS690) || \
  1358. (rdev->family == CHIP_RS740) || \
  1359. (rdev->family >= CHIP_R600))
  1360. #define ASIC_IS_DCE3(rdev) ((rdev->family >= CHIP_RV620))
  1361. #define ASIC_IS_DCE32(rdev) ((rdev->family >= CHIP_RV730))
  1362. #define ASIC_IS_DCE4(rdev) ((rdev->family >= CHIP_CEDAR))
  1363. #define ASIC_IS_DCE41(rdev) ((rdev->family >= CHIP_PALM) && \
  1364. (rdev->flags & RADEON_IS_IGP))
  1365. #define ASIC_IS_DCE5(rdev) ((rdev->family >= CHIP_BARTS))
  1366. /*
  1367. * BIOS helpers.
  1368. */
  1369. #define RBIOS8(i) (rdev->bios[i])
  1370. #define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8))
  1371. #define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16))
  1372. int radeon_combios_init(struct radeon_device *rdev);
  1373. void radeon_combios_fini(struct radeon_device *rdev);
  1374. int radeon_atombios_init(struct radeon_device *rdev);
  1375. void radeon_atombios_fini(struct radeon_device *rdev);
  1376. /*
  1377. * RING helpers.
  1378. */
  1379. #if DRM_DEBUG_CODE == 0
  1380. static inline void radeon_ring_write(struct radeon_ring *ring, uint32_t v)
  1381. {
  1382. ring->ring[ring->wptr++] = v;
  1383. ring->wptr &= ring->ptr_mask;
  1384. ring->count_dw--;
  1385. ring->ring_free_dw--;
  1386. }
  1387. #else
  1388. /* With debugging this is just too big to inline */
  1389. void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
  1390. #endif
  1391. /*
  1392. * ASICs macro.
  1393. */
  1394. #define radeon_init(rdev) (rdev)->asic->init((rdev))
  1395. #define radeon_fini(rdev) (rdev)->asic->fini((rdev))
  1396. #define radeon_resume(rdev) (rdev)->asic->resume((rdev))
  1397. #define radeon_suspend(rdev) (rdev)->asic->suspend((rdev))
  1398. #define radeon_cs_parse(p) rdev->asic->cs_parse((p))
  1399. #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state))
  1400. #define radeon_gpu_is_lockup(rdev, cp) (rdev)->asic->gpu_is_lockup((rdev), (cp))
  1401. #define radeon_asic_reset(rdev) (rdev)->asic->asic_reset((rdev))
  1402. #define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart_tlb_flush((rdev))
  1403. #define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart_set_page((rdev), (i), (p))
  1404. #define radeon_ring_start(rdev) (rdev)->asic->ring_start((rdev))
  1405. #define radeon_ring_test(rdev, cp) (rdev)->asic->ring_test((rdev), (cp))
  1406. #define radeon_ring_ib_execute(rdev, r, ib) (rdev)->asic->ring[(r)].ib_execute((rdev), (ib))
  1407. #define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev))
  1408. #define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev))
  1409. #define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->get_vblank_counter((rdev), (crtc))
  1410. #define radeon_fence_ring_emit(rdev, r, fence) (rdev)->asic->ring[(r)].emit_fence((rdev), (fence))
  1411. #define radeon_semaphore_ring_emit(rdev, r, cp, semaphore, emit_wait) (rdev)->asic->ring[(r)].emit_semaphore((rdev), (cp), (semaphore), (emit_wait))
  1412. #define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy_blit((rdev), (s), (d), (np), (f))
  1413. #define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy_dma((rdev), (s), (d), (np), (f))
  1414. #define radeon_copy(rdev, s, d, np, f) (rdev)->asic->copy((rdev), (s), (d), (np), (f))
  1415. #define radeon_get_engine_clock(rdev) (rdev)->asic->get_engine_clock((rdev))
  1416. #define radeon_set_engine_clock(rdev, e) (rdev)->asic->set_engine_clock((rdev), (e))
  1417. #define radeon_get_memory_clock(rdev) (rdev)->asic->get_memory_clock((rdev))
  1418. #define radeon_set_memory_clock(rdev, e) (rdev)->asic->set_memory_clock((rdev), (e))
  1419. #define radeon_get_pcie_lanes(rdev) (rdev)->asic->get_pcie_lanes((rdev))
  1420. #define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->set_pcie_lanes((rdev), (l))
  1421. #define radeon_set_clock_gating(rdev, e) (rdev)->asic->set_clock_gating((rdev), (e))
  1422. #define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s)))
  1423. #define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->clear_surface_reg((rdev), (r)))
  1424. #define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev))
  1425. #define radeon_hpd_init(rdev) (rdev)->asic->hpd_init((rdev))
  1426. #define radeon_hpd_fini(rdev) (rdev)->asic->hpd_fini((rdev))
  1427. #define radeon_hpd_sense(rdev, hpd) (rdev)->asic->hpd_sense((rdev), (hpd))
  1428. #define radeon_hpd_set_polarity(rdev, hpd) (rdev)->asic->hpd_set_polarity((rdev), (hpd))
  1429. #define radeon_gui_idle(rdev) (rdev)->asic->gui_idle((rdev))
  1430. #define radeon_pm_misc(rdev) (rdev)->asic->pm_misc((rdev))
  1431. #define radeon_pm_prepare(rdev) (rdev)->asic->pm_prepare((rdev))
  1432. #define radeon_pm_finish(rdev) (rdev)->asic->pm_finish((rdev))
  1433. #define radeon_pm_init_profile(rdev) (rdev)->asic->pm_init_profile((rdev))
  1434. #define radeon_pm_get_dynpm_state(rdev) (rdev)->asic->pm_get_dynpm_state((rdev))
  1435. #define radeon_pre_page_flip(rdev, crtc) rdev->asic->pre_page_flip((rdev), (crtc))
  1436. #define radeon_page_flip(rdev, crtc, base) rdev->asic->page_flip((rdev), (crtc), (base))
  1437. #define radeon_post_page_flip(rdev, crtc) rdev->asic->post_page_flip((rdev), (crtc))
  1438. /* Common functions */
  1439. /* AGP */
  1440. extern int radeon_gpu_reset(struct radeon_device *rdev);
  1441. extern void radeon_agp_disable(struct radeon_device *rdev);
  1442. extern int radeon_modeset_init(struct radeon_device *rdev);
  1443. extern void radeon_modeset_fini(struct radeon_device *rdev);
  1444. extern bool radeon_card_posted(struct radeon_device *rdev);
  1445. extern void radeon_update_bandwidth_info(struct radeon_device *rdev);
  1446. extern void radeon_update_display_priority(struct radeon_device *rdev);
  1447. extern bool radeon_boot_test_post_card(struct radeon_device *rdev);
  1448. extern void radeon_scratch_init(struct radeon_device *rdev);
  1449. extern void radeon_wb_fini(struct radeon_device *rdev);
  1450. extern int radeon_wb_init(struct radeon_device *rdev);
  1451. extern void radeon_wb_disable(struct radeon_device *rdev);
  1452. extern void radeon_surface_init(struct radeon_device *rdev);
  1453. extern int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data);
  1454. extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable);
  1455. extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable);
  1456. extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain);
  1457. extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo);
  1458. extern void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base);
  1459. extern void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc);
  1460. extern int radeon_resume_kms(struct drm_device *dev);
  1461. extern int radeon_suspend_kms(struct drm_device *dev, pm_message_t state);
  1462. extern void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size);
  1463. /*
  1464. * R600 vram scratch functions
  1465. */
  1466. int r600_vram_scratch_init(struct radeon_device *rdev);
  1467. void r600_vram_scratch_fini(struct radeon_device *rdev);
  1468. /*
  1469. * r600 functions used by radeon_encoder.c
  1470. */
  1471. extern void r600_hdmi_enable(struct drm_encoder *encoder);
  1472. extern void r600_hdmi_disable(struct drm_encoder *encoder);
  1473. extern void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode);
  1474. extern int ni_init_microcode(struct radeon_device *rdev);
  1475. extern int ni_mc_load_microcode(struct radeon_device *rdev);
  1476. /* radeon_acpi.c */
  1477. #if defined(CONFIG_ACPI)
  1478. extern int radeon_acpi_init(struct radeon_device *rdev);
  1479. #else
  1480. static inline int radeon_acpi_init(struct radeon_device *rdev) { return 0; }
  1481. #endif
  1482. #include "radeon_object.h"
  1483. #endif