Commit | Line | Data |
---|---|---|
639c308e BS |
1 | #ifndef __NVKM_FB_H__ |
2 | #define __NVKM_FB_H__ | |
861d2107 | 3 | #include <core/subdev.h> |
3863c9bc | 4 | |
5ce3bf3c | 5 | #include <subdev/mmu.h> |
861d2107 BS |
6 | |
7 | /* memory type/access flags, do not match hardware values */ | |
8 | #define NV_MEM_ACCESS_RO 1 | |
9 | #define NV_MEM_ACCESS_WO 2 | |
10 | #define NV_MEM_ACCESS_RW (NV_MEM_ACCESS_RO | NV_MEM_ACCESS_WO) | |
11 | #define NV_MEM_ACCESS_SYS 4 | |
12 | #define NV_MEM_ACCESS_VM 8 | |
13 | #define NV_MEM_ACCESS_NOSNOOP 16 | |
14 | ||
15 | #define NV_MEM_TARGET_VRAM 0 | |
16 | #define NV_MEM_TARGET_PCI 1 | |
17 | #define NV_MEM_TARGET_PCI_NOSNOOP 2 | |
18 | #define NV_MEM_TARGET_VM 3 | |
19 | #define NV_MEM_TARGET_GART 4 | |
20 | ||
d36a99d2 | 21 | #define NVKM_RAM_TYPE_VM 0x7f |
861d2107 BS |
22 | #define NV_MEM_COMP_VM 0x03 |
23 | ||
639c308e | 24 | struct nvkm_mem { |
861d2107 BS |
25 | struct drm_device *dev; |
26 | ||
639c308e BS |
27 | struct nvkm_vma bar_vma; |
28 | struct nvkm_vma vma[2]; | |
861d2107 BS |
29 | u8 page_shift; |
30 | ||
639c308e | 31 | struct nvkm_mm_node *tag; |
861d2107 BS |
32 | struct list_head regions; |
33 | dma_addr_t *pages; | |
34 | u32 memtype; | |
35 | u64 offset; | |
36 | u64 size; | |
37 | struct sg_table *sg; | |
38 | }; | |
39 | ||
639c308e BS |
40 | struct nvkm_fb_tile { |
41 | struct nvkm_mm_node *tag; | |
861d2107 BS |
42 | u32 addr; |
43 | u32 limit; | |
44 | u32 pitch; | |
45 | u32 zcomp; | |
46 | }; | |
47 | ||
639c308e | 48 | struct nvkm_fb { |
03c8952f | 49 | const struct nvkm_fb_func *func; |
b1e4553c | 50 | struct nvkm_subdev subdev; |
861d2107 | 51 | |
639c308e | 52 | struct nvkm_ram *ram; |
861d2107 | 53 | |
861d2107 | 54 | struct { |
639c308e | 55 | struct nvkm_fb_tile region[16]; |
861d2107 | 56 | int regions; |
861d2107 | 57 | } tile; |
99c59172 | 58 | |
c73baa83 BS |
59 | u8 page; |
60 | ||
99c59172 BS |
61 | struct nvkm_memory *mmu_rd; |
62 | struct nvkm_memory *mmu_wr; | |
861d2107 BS |
63 | }; |
64 | ||
03c8952f BS |
65 | bool nvkm_fb_memtype_valid(struct nvkm_fb *, u32 memtype); |
66 | void nvkm_fb_tile_init(struct nvkm_fb *, int region, u32 addr, u32 size, | |
67 | u32 pitch, u32 flags, struct nvkm_fb_tile *); | |
68 | void nvkm_fb_tile_fini(struct nvkm_fb *, int region, struct nvkm_fb_tile *); | |
69 | void nvkm_fb_tile_prog(struct nvkm_fb *, int region, struct nvkm_fb_tile *); | |
70 | ||
71 | int nv04_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
72 | int nv10_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
73 | int nv1a_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
74 | int nv20_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
75 | int nv25_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
76 | int nv30_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
77 | int nv35_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
78 | int nv36_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
79 | int nv40_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
80 | int nv41_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
81 | int nv44_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
82 | int nv46_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
83 | int nv47_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
84 | int nv49_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
85 | int nv4e_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
86 | int nv50_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
87 | int g84_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
88 | int gt215_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
89 | int mcp77_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
90 | int mcp89_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
91 | int gf100_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
92 | int gk104_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
93 | int gk20a_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
94 | int gm107_fb_new(struct nvkm_device *, int, struct nvkm_fb **); | |
e976278a | 95 | int gm200_fb_new(struct nvkm_device *, int, struct nvkm_fb **); |
7ff51f82 | 96 | int gp100_fb_new(struct nvkm_device *, int, struct nvkm_fb **); |
861d2107 | 97 | |
d390b480 | 98 | #include <subdev/bios.h> |
b655f2bb BS |
99 | #include <subdev/bios/ramcfg.h> |
100 | ||
639c308e | 101 | struct nvkm_ram_data { |
d26e7489 | 102 | struct list_head head; |
b655f2bb | 103 | struct nvbios_ramcfg bios; |
46bf1c38 | 104 | u32 freq; |
b655f2bb BS |
105 | }; |
106 | ||
d36a99d2 BS |
107 | enum nvkm_ram_type { |
108 | NVKM_RAM_TYPE_UNKNOWN = 0, | |
109 | NVKM_RAM_TYPE_STOLEN, | |
110 | NVKM_RAM_TYPE_SGRAM, | |
111 | NVKM_RAM_TYPE_SDRAM, | |
112 | NVKM_RAM_TYPE_DDR1, | |
113 | NVKM_RAM_TYPE_DDR2, | |
114 | NVKM_RAM_TYPE_DDR3, | |
115 | NVKM_RAM_TYPE_GDDR2, | |
116 | NVKM_RAM_TYPE_GDDR3, | |
117 | NVKM_RAM_TYPE_GDDR4, | |
118 | NVKM_RAM_TYPE_GDDR5 | |
119 | }; | |
120 | ||
639c308e | 121 | struct nvkm_ram { |
d36a99d2 BS |
122 | const struct nvkm_ram_func *func; |
123 | struct nvkm_fb *fb; | |
124 | enum nvkm_ram_type type; | |
dceef5d8 | 125 | u64 size; |
d36a99d2 BS |
126 | |
127 | #define NVKM_RAM_MM_SHIFT 12 | |
128 | struct nvkm_mm vram; | |
129 | struct nvkm_mm tags; | |
130 | u64 stolen; | |
5f8e2567 | 131 | |
dceef5d8 BS |
132 | int ranks; |
133 | int parts; | |
de1c4e28 | 134 | int part_mask; |
150ccf16 | 135 | |
aae95ca7 BS |
136 | u32 freq; |
137 | u32 mr[16]; | |
d394fb12 | 138 | u32 mr1_nuts; |
b655f2bb | 139 | |
639c308e BS |
140 | struct nvkm_ram_data *next; |
141 | struct nvkm_ram_data former; | |
142 | struct nvkm_ram_data xition; | |
143 | struct nvkm_ram_data target; | |
dceef5d8 | 144 | }; |
d36a99d2 BS |
145 | |
146 | struct nvkm_ram_func { | |
147 | void *(*dtor)(struct nvkm_ram *); | |
148 | int (*init)(struct nvkm_ram *); | |
149 | ||
150 | int (*get)(struct nvkm_ram *, u64 size, u32 align, u32 size_nc, | |
151 | u32 type, struct nvkm_mem **); | |
152 | void (*put)(struct nvkm_ram *, struct nvkm_mem **); | |
153 | ||
154 | int (*calc)(struct nvkm_ram *, u32 freq); | |
155 | int (*prog)(struct nvkm_ram *); | |
156 | void (*tidy)(struct nvkm_ram *); | |
157 | }; | |
861d2107 | 158 | #endif |