aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/radeon.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon.h')
-rw-r--r--drivers/gpu/drm/radeon/radeon.h165
1 files changed, 103 insertions, 62 deletions
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 224506a2f7b1..c938bb54123c 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -28,8 +28,6 @@
28#ifndef __RADEON_H__ 28#ifndef __RADEON_H__
29#define __RADEON_H__ 29#define __RADEON_H__
30 30
31#include "radeon_object.h"
32
33/* TODO: Here are things that needs to be done : 31/* TODO: Here are things that needs to be done :
34 * - surface allocator & initializer : (bit like scratch reg) should 32 * - surface allocator & initializer : (bit like scratch reg) should
35 * initialize HDP_ stuff on RS600, R600, R700 hw, well anythings 33 * initialize HDP_ stuff on RS600, R600, R700 hw, well anythings
@@ -67,6 +65,11 @@
67#include <linux/list.h> 65#include <linux/list.h>
68#include <linux/kref.h> 66#include <linux/kref.h>
69 67
68#include <ttm/ttm_bo_api.h>
69#include <ttm/ttm_bo_driver.h>
70#include <ttm/ttm_placement.h>
71#include <ttm/ttm_module.h>
72
70#include "radeon_family.h" 73#include "radeon_family.h"
71#include "radeon_mode.h" 74#include "radeon_mode.h"
72#include "radeon_reg.h" 75#include "radeon_reg.h"
@@ -85,6 +88,7 @@ extern int radeon_benchmarking;
85extern int radeon_testing; 88extern int radeon_testing;
86extern int radeon_connector_table; 89extern int radeon_connector_table;
87extern int radeon_tv; 90extern int radeon_tv;
91extern int radeon_new_pll;
88 92
89/* 93/*
90 * Copy from radeon_drv.h so we don't have to include both and have conflicting 94 * Copy from radeon_drv.h so we don't have to include both and have conflicting
@@ -186,76 +190,62 @@ void radeon_fence_unref(struct radeon_fence **fence);
186 * Tiling registers 190 * Tiling registers
187 */ 191 */
188struct radeon_surface_reg { 192struct radeon_surface_reg {
189 struct radeon_object *robj; 193 struct radeon_bo *bo;
190}; 194};
191 195
192#define RADEON_GEM_MAX_SURFACES 8 196#define RADEON_GEM_MAX_SURFACES 8
193 197
194/* 198/*
195 * Radeon buffer. 199 * TTM.
196 */ 200 */
197struct radeon_object; 201struct radeon_mman {
202 struct ttm_bo_global_ref bo_global_ref;
203 struct ttm_global_reference mem_global_ref;
204 bool mem_global_referenced;
205 struct ttm_bo_device bdev;
206};
207
208struct radeon_bo {
209 /* Protected by gem.mutex */
210 struct list_head list;
211 /* Protected by tbo.reserved */
212 u32 placements[3];
213 struct ttm_placement placement;
214 struct ttm_buffer_object tbo;
215 struct ttm_bo_kmap_obj kmap;
216 unsigned pin_count;
217 void *kptr;
218 u32 tiling_flags;
219 u32 pitch;
220 int surface_reg;
221 /* Constant after initialization */
222 struct radeon_device *rdev;
223 struct drm_gem_object *gobj;
224};
198 225
199struct radeon_object_list { 226struct radeon_bo_list {
200 struct list_head list; 227 struct list_head list;
201 struct radeon_object *robj; 228 struct radeon_bo *bo;
202 uint64_t gpu_offset; 229 uint64_t gpu_offset;
203 unsigned rdomain; 230 unsigned rdomain;
204 unsigned wdomain; 231 unsigned wdomain;
205 uint32_t tiling_flags; 232 u32 tiling_flags;
206}; 233};
207 234
208int radeon_object_init(struct radeon_device *rdev);
209void radeon_object_fini(struct radeon_device *rdev);
210int radeon_object_create(struct radeon_device *rdev,
211 struct drm_gem_object *gobj,
212 unsigned long size,
213 bool kernel,
214 uint32_t domain,
215 bool interruptible,
216 struct radeon_object **robj_ptr);
217int radeon_object_kmap(struct radeon_object *robj, void **ptr);
218void radeon_object_kunmap(struct radeon_object *robj);
219void radeon_object_unref(struct radeon_object **robj);
220int radeon_object_pin(struct radeon_object *robj, uint32_t domain,
221 uint64_t *gpu_addr);
222void radeon_object_unpin(struct radeon_object *robj);
223int radeon_object_wait(struct radeon_object *robj);
224int radeon_object_busy_domain(struct radeon_object *robj, uint32_t *cur_placement);
225int radeon_object_evict_vram(struct radeon_device *rdev);
226int radeon_object_mmap(struct radeon_object *robj, uint64_t *offset);
227void radeon_object_force_delete(struct radeon_device *rdev);
228void radeon_object_list_add_object(struct radeon_object_list *lobj,
229 struct list_head *head);
230int radeon_object_list_validate(struct list_head *head, void *fence);
231void radeon_object_list_unvalidate(struct list_head *head);
232void radeon_object_list_clean(struct list_head *head);
233int radeon_object_fbdev_mmap(struct radeon_object *robj,
234 struct vm_area_struct *vma);
235unsigned long radeon_object_size(struct radeon_object *robj);
236void radeon_object_clear_surface_reg(struct radeon_object *robj);
237int radeon_object_check_tiling(struct radeon_object *robj, bool has_moved,
238 bool force_drop);
239void radeon_object_set_tiling_flags(struct radeon_object *robj,
240 uint32_t tiling_flags, uint32_t pitch);
241void radeon_object_get_tiling_flags(struct radeon_object *robj, uint32_t *tiling_flags, uint32_t *pitch);
242void radeon_bo_move_notify(struct ttm_buffer_object *bo,
243 struct ttm_mem_reg *mem);
244void radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
245/* 235/*
246 * GEM objects. 236 * GEM objects.
247 */ 237 */
248struct radeon_gem { 238struct radeon_gem {
239 struct mutex mutex;
249 struct list_head objects; 240 struct list_head objects;
250}; 241};
251 242
252int radeon_gem_init(struct radeon_device *rdev); 243int radeon_gem_init(struct radeon_device *rdev);
253void radeon_gem_fini(struct radeon_device *rdev); 244void radeon_gem_fini(struct radeon_device *rdev);
254int radeon_gem_object_create(struct radeon_device *rdev, int size, 245int radeon_gem_object_create(struct radeon_device *rdev, int size,
255 int alignment, int initial_domain, 246 int alignment, int initial_domain,
256 bool discardable, bool kernel, 247 bool discardable, bool kernel,
257 bool interruptible, 248 struct drm_gem_object **obj);
258 struct drm_gem_object **obj);
259int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain, 249int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain,
260 uint64_t *gpu_addr); 250 uint64_t *gpu_addr);
261void radeon_gem_object_unpin(struct drm_gem_object *obj); 251void radeon_gem_object_unpin(struct drm_gem_object *obj);
@@ -271,7 +261,7 @@ struct radeon_gart_table_ram {
271}; 261};
272 262
273struct radeon_gart_table_vram { 263struct radeon_gart_table_vram {
274 struct radeon_object *robj; 264 struct radeon_bo *robj;
275 volatile uint32_t *ptr; 265 volatile uint32_t *ptr;
276}; 266};
277 267
@@ -352,11 +342,16 @@ struct radeon_irq {
352 bool sw_int; 342 bool sw_int;
353 /* FIXME: use a define max crtc rather than hardcode it */ 343 /* FIXME: use a define max crtc rather than hardcode it */
354 bool crtc_vblank_int[2]; 344 bool crtc_vblank_int[2];
345 /* FIXME: use defines for max hpd/dacs */
346 bool hpd[6];
347 spinlock_t sw_lock;
348 int sw_refcount;
355}; 349};
356 350
357int radeon_irq_kms_init(struct radeon_device *rdev); 351int radeon_irq_kms_init(struct radeon_device *rdev);
358void radeon_irq_kms_fini(struct radeon_device *rdev); 352void radeon_irq_kms_fini(struct radeon_device *rdev);
359 353void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev);
354void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev);
360 355
361/* 356/*
362 * CP & ring. 357 * CP & ring.
@@ -376,7 +371,7 @@ struct radeon_ib {
376 */ 371 */
377struct radeon_ib_pool { 372struct radeon_ib_pool {
378 struct mutex mutex; 373 struct mutex mutex;
379 struct radeon_object *robj; 374 struct radeon_bo *robj;
380 struct list_head scheduled_ibs; 375 struct list_head scheduled_ibs;
381 struct radeon_ib ibs[RADEON_IB_POOL_SIZE]; 376 struct radeon_ib ibs[RADEON_IB_POOL_SIZE];
382 bool ready; 377 bool ready;
@@ -384,7 +379,7 @@ struct radeon_ib_pool {
384}; 379};
385 380
386struct radeon_cp { 381struct radeon_cp {
387 struct radeon_object *ring_obj; 382 struct radeon_bo *ring_obj;
388 volatile uint32_t *ring; 383 volatile uint32_t *ring;
389 unsigned rptr; 384 unsigned rptr;
390 unsigned wptr; 385 unsigned wptr;
@@ -399,8 +394,25 @@ struct radeon_cp {
399 bool ready; 394 bool ready;
400}; 395};
401 396
397/*
398 * R6xx+ IH ring
399 */
400struct r600_ih {
401 struct radeon_bo *ring_obj;
402 volatile uint32_t *ring;
403 unsigned rptr;
404 unsigned wptr;
405 unsigned wptr_old;
406 unsigned ring_size;
407 uint64_t gpu_addr;
408 uint32_t align_mask;
409 uint32_t ptr_mask;
410 spinlock_t lock;
411 bool enabled;
412};
413
402struct r600_blit { 414struct r600_blit {
403 struct radeon_object *shader_obj; 415 struct radeon_bo *shader_obj;
404 u64 shader_gpu_addr; 416 u64 shader_gpu_addr;
405 u32 vs_offset, ps_offset; 417 u32 vs_offset, ps_offset;
406 u32 state_offset; 418 u32 state_offset;
@@ -430,8 +442,8 @@ void radeon_ring_fini(struct radeon_device *rdev);
430 */ 442 */
431struct radeon_cs_reloc { 443struct radeon_cs_reloc {
432 struct drm_gem_object *gobj; 444 struct drm_gem_object *gobj;
433 struct radeon_object *robj; 445 struct radeon_bo *robj;
434 struct radeon_object_list lobj; 446 struct radeon_bo_list lobj;
435 uint32_t handle; 447 uint32_t handle;
436 uint32_t flags; 448 uint32_t flags;
437}; 449};
@@ -527,7 +539,7 @@ void radeon_agp_fini(struct radeon_device *rdev);
527 * Writeback 539 * Writeback
528 */ 540 */
529struct radeon_wb { 541struct radeon_wb {
530 struct radeon_object *wb_obj; 542 struct radeon_bo *wb_obj;
531 volatile uint32_t *wb; 543 volatile uint32_t *wb;
532 uint64_t gpu_addr; 544 uint64_t gpu_addr;
533}; 545};
@@ -639,6 +651,11 @@ struct radeon_asic {
639 uint32_t offset, uint32_t obj_size); 651 uint32_t offset, uint32_t obj_size);
640 int (*clear_surface_reg)(struct radeon_device *rdev, int reg); 652 int (*clear_surface_reg)(struct radeon_device *rdev, int reg);
641 void (*bandwidth_update)(struct radeon_device *rdev); 653 void (*bandwidth_update)(struct radeon_device *rdev);
654 void (*hdp_flush)(struct radeon_device *rdev);
655 void (*hpd_init)(struct radeon_device *rdev);
656 void (*hpd_fini)(struct radeon_device *rdev);
657 bool (*hpd_sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
658 void (*hpd_set_polarity)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
642}; 659};
643 660
644/* 661/*
@@ -751,9 +768,9 @@ struct radeon_device {
751 uint8_t *bios; 768 uint8_t *bios;
752 bool is_atom_bios; 769 bool is_atom_bios;
753 uint16_t bios_header_start; 770 uint16_t bios_header_start;
754 struct radeon_object *stollen_vga_memory; 771 struct radeon_bo *stollen_vga_memory;
755 struct fb_info *fbdev_info; 772 struct fb_info *fbdev_info;
756 struct radeon_object *fbdev_robj; 773 struct radeon_bo *fbdev_rbo;
757 struct radeon_framebuffer *fbdev_rfb; 774 struct radeon_framebuffer *fbdev_rfb;
758 /* Register mmio */ 775 /* Register mmio */
759 resource_size_t rmmio_base; 776 resource_size_t rmmio_base;
@@ -791,8 +808,12 @@ struct radeon_device {
791 struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES]; 808 struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES];
792 const struct firmware *me_fw; /* all family ME firmware */ 809 const struct firmware *me_fw; /* all family ME firmware */
793 const struct firmware *pfp_fw; /* r6/700 PFP firmware */ 810 const struct firmware *pfp_fw; /* r6/700 PFP firmware */
811 const struct firmware *rlc_fw; /* r6/700 RLC firmware */
794 struct r600_blit r600_blit; 812 struct r600_blit r600_blit;
795 int msi_enabled; /* msi enabled */ 813 int msi_enabled; /* msi enabled */
814 struct r600_ih ih; /* r6/700 interrupt ring */
815 struct workqueue_struct *wq;
816 struct work_struct hotplug_work;
796}; 817};
797 818
798int radeon_device_init(struct radeon_device *rdev, 819int radeon_device_init(struct radeon_device *rdev,
@@ -829,6 +850,10 @@ static inline void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32
829 } 850 }
830} 851}
831 852
853/*
854 * Cast helper
855 */
856#define to_radeon_fence(p) ((struct radeon_fence *)(p))
832 857
833/* 858/*
834 * Registers read & write functions. 859 * Registers read & write functions.
@@ -965,18 +990,24 @@ static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v)
965#define radeon_get_engine_clock(rdev) (rdev)->asic->get_engine_clock((rdev)) 990#define radeon_get_engine_clock(rdev) (rdev)->asic->get_engine_clock((rdev))
966#define radeon_set_engine_clock(rdev, e) (rdev)->asic->set_engine_clock((rdev), (e)) 991#define radeon_set_engine_clock(rdev, e) (rdev)->asic->set_engine_clock((rdev), (e))
967#define radeon_get_memory_clock(rdev) (rdev)->asic->get_memory_clock((rdev)) 992#define radeon_get_memory_clock(rdev) (rdev)->asic->get_memory_clock((rdev))
968#define radeon_set_memory_clock(rdev, e) (rdev)->asic->set_engine_clock((rdev), (e)) 993#define radeon_set_memory_clock(rdev, e) (rdev)->asic->set_memory_clock((rdev), (e))
969#define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->set_pcie_lanes((rdev), (l)) 994#define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->set_pcie_lanes((rdev), (l))
970#define radeon_set_clock_gating(rdev, e) (rdev)->asic->set_clock_gating((rdev), (e)) 995#define radeon_set_clock_gating(rdev, e) (rdev)->asic->set_clock_gating((rdev), (e))
971#define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s))) 996#define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s)))
972#define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->clear_surface_reg((rdev), (r))) 997#define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->clear_surface_reg((rdev), (r)))
973#define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev)) 998#define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev))
999#define radeon_hdp_flush(rdev) (rdev)->asic->hdp_flush((rdev))
1000#define radeon_hpd_init(rdev) (rdev)->asic->hpd_init((rdev))
1001#define radeon_hpd_fini(rdev) (rdev)->asic->hpd_fini((rdev))
1002#define radeon_hpd_sense(rdev, hpd) (rdev)->asic->hpd_sense((rdev), (hpd))
1003#define radeon_hpd_set_polarity(rdev, hpd) (rdev)->asic->hpd_set_polarity((rdev), (hpd))
974 1004
975/* Common functions */ 1005/* Common functions */
976extern int radeon_gart_table_vram_pin(struct radeon_device *rdev); 1006extern int radeon_gart_table_vram_pin(struct radeon_device *rdev);
977extern int radeon_modeset_init(struct radeon_device *rdev); 1007extern int radeon_modeset_init(struct radeon_device *rdev);
978extern void radeon_modeset_fini(struct radeon_device *rdev); 1008extern void radeon_modeset_fini(struct radeon_device *rdev);
979extern bool radeon_card_posted(struct radeon_device *rdev); 1009extern bool radeon_card_posted(struct radeon_device *rdev);
1010extern bool radeon_boot_test_post_card(struct radeon_device *rdev);
980extern int radeon_clocks_init(struct radeon_device *rdev); 1011extern int radeon_clocks_init(struct radeon_device *rdev);
981extern void radeon_clocks_fini(struct radeon_device *rdev); 1012extern void radeon_clocks_fini(struct radeon_device *rdev);
982extern void radeon_scratch_init(struct radeon_device *rdev); 1013extern void radeon_scratch_init(struct radeon_device *rdev);
@@ -984,6 +1015,7 @@ extern void radeon_surface_init(struct radeon_device *rdev);
984extern int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data); 1015extern int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data);
985extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable); 1016extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable);
986extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable); 1017extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable);
1018extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain);
987 1019
988/* r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280 */ 1020/* r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280 */
989struct r100_mc_save { 1021struct r100_mc_save {
@@ -1021,7 +1053,7 @@ extern int r100_cp_reset(struct radeon_device *rdev);
1021extern void r100_vga_render_disable(struct radeon_device *rdev); 1053extern void r100_vga_render_disable(struct radeon_device *rdev);
1022extern int r100_cs_track_check_pkt3_indx_buffer(struct radeon_cs_parser *p, 1054extern int r100_cs_track_check_pkt3_indx_buffer(struct radeon_cs_parser *p,
1023 struct radeon_cs_packet *pkt, 1055 struct radeon_cs_packet *pkt,
1024 struct radeon_object *robj); 1056 struct radeon_bo *robj);
1025extern int r100_cs_parse_packet0(struct radeon_cs_parser *p, 1057extern int r100_cs_parse_packet0(struct radeon_cs_parser *p,
1026 struct radeon_cs_packet *pkt, 1058 struct radeon_cs_packet *pkt,
1027 const unsigned *auth, unsigned n, 1059 const unsigned *auth, unsigned n,
@@ -1029,6 +1061,8 @@ extern int r100_cs_parse_packet0(struct radeon_cs_parser *p,
1029extern int r100_cs_packet_parse(struct radeon_cs_parser *p, 1061extern int r100_cs_packet_parse(struct radeon_cs_parser *p,
1030 struct radeon_cs_packet *pkt, 1062 struct radeon_cs_packet *pkt,
1031 unsigned idx); 1063 unsigned idx);
1064extern void r100_enable_bm(struct radeon_device *rdev);
1065extern void r100_set_common_regs(struct radeon_device *rdev);
1032 1066
1033/* rv200,rv250,rv280 */ 1067/* rv200,rv250,rv280 */
1034extern void r200_set_safe_registers(struct radeon_device *rdev); 1068extern void r200_set_safe_registers(struct radeon_device *rdev);
@@ -1104,7 +1138,14 @@ extern void r600_wb_disable(struct radeon_device *rdev);
1104extern void r600_scratch_init(struct radeon_device *rdev); 1138extern void r600_scratch_init(struct radeon_device *rdev);
1105extern int r600_blit_init(struct radeon_device *rdev); 1139extern int r600_blit_init(struct radeon_device *rdev);
1106extern void r600_blit_fini(struct radeon_device *rdev); 1140extern void r600_blit_fini(struct radeon_device *rdev);
1107extern int r600_cp_init_microcode(struct radeon_device *rdev); 1141extern int r600_init_microcode(struct radeon_device *rdev);
1108extern int r600_gpu_reset(struct radeon_device *rdev); 1142extern int r600_gpu_reset(struct radeon_device *rdev);
1143/* r600 irq */
1144extern int r600_irq_init(struct radeon_device *rdev);
1145extern void r600_irq_fini(struct radeon_device *rdev);
1146extern void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size);
1147extern int r600_irq_set(struct radeon_device *rdev);
1148
1149#include "radeon_object.h"
1109 1150
1110#endif 1151#endif