1 | #ifndef __NOUVEAU_FB_H__ |
2 | #define __NOUVEAU_FB_H__ |
3 | |
4 | #include <core/subdev.h> |
5 | #include <core/device.h> |
6 | #include <core/mm.h> |
7 | |
8 | #include <subdev/vm.h> |
9 | |
10 | /* memory type/access flags, do not match hardware values */ |
11 | #define NV_MEM_ACCESS_RO 1 |
12 | #define NV_MEM_ACCESS_WO 2 |
13 | #define NV_MEM_ACCESS_RW (NV_MEM_ACCESS_RO | NV_MEM_ACCESS_WO) |
14 | #define NV_MEM_ACCESS_SYS 4 |
15 | #define NV_MEM_ACCESS_VM 8 |
16 | #define NV_MEM_ACCESS_NOSNOOP 16 |
17 | |
18 | #define NV_MEM_TARGET_VRAM 0 |
19 | #define NV_MEM_TARGET_PCI 1 |
20 | #define NV_MEM_TARGET_PCI_NOSNOOP 2 |
21 | #define NV_MEM_TARGET_VM 3 |
22 | #define NV_MEM_TARGET_GART 4 |
23 | |
24 | #define NV_MEM_TYPE_VM 0x7f |
25 | #define NV_MEM_COMP_VM 0x03 |
26 | |
27 | struct nouveau_mem { |
28 | struct drm_device *dev; |
29 | |
30 | struct nouveau_vma bar_vma; |
31 | struct nouveau_vma vma[2]; |
32 | u8 page_shift; |
33 | |
34 | struct nouveau_mm_node *tag; |
35 | struct list_head regions; |
36 | #ifdef __NetBSD__ |
37 | bus_dmamap_t pages; |
38 | #else |
39 | dma_addr_t *pages; |
40 | #endif |
41 | u32 memtype; |
42 | u64 offset; |
43 | u64 size; |
44 | struct sg_table *sg; |
45 | }; |
46 | |
47 | struct nouveau_fb_tile { |
48 | struct nouveau_mm_node *tag; |
49 | u32 addr; |
50 | u32 limit; |
51 | u32 pitch; |
52 | u32 zcomp; |
53 | }; |
54 | |
55 | struct nouveau_fb { |
56 | struct nouveau_subdev base; |
57 | |
58 | bool (*memtype_valid)(struct nouveau_fb *, u32 memtype); |
59 | |
60 | struct nouveau_ram *ram; |
61 | |
62 | struct nouveau_mm vram; |
63 | struct nouveau_mm tags; |
64 | |
65 | struct { |
66 | struct nouveau_fb_tile region[16]; |
67 | int regions; |
68 | void (*init)(struct nouveau_fb *, int i, u32 addr, u32 size, |
69 | u32 pitch, u32 flags, struct nouveau_fb_tile *); |
70 | void (*comp)(struct nouveau_fb *, int i, u32 size, u32 flags, |
71 | struct nouveau_fb_tile *); |
72 | void (*fini)(struct nouveau_fb *, int i, |
73 | struct nouveau_fb_tile *); |
74 | void (*prog)(struct nouveau_fb *, int i, |
75 | struct nouveau_fb_tile *); |
76 | } tile; |
77 | }; |
78 | |
79 | static inline struct nouveau_fb * |
80 | nouveau_fb(void *obj) |
81 | { |
82 | /* fbram uses this before device subdev pointer is valid */ |
83 | if (nv_iclass(obj, NV_SUBDEV_CLASS) && |
84 | nv_subidx(obj) == NVDEV_SUBDEV_FB) |
85 | return obj; |
86 | |
87 | return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_FB]; |
88 | } |
89 | |
90 | extern struct nouveau_oclass *nv04_fb_oclass; |
91 | extern struct nouveau_oclass *nv10_fb_oclass; |
92 | extern struct nouveau_oclass *nv1a_fb_oclass; |
93 | extern struct nouveau_oclass *nv20_fb_oclass; |
94 | extern struct nouveau_oclass *nv25_fb_oclass; |
95 | extern struct nouveau_oclass *nv30_fb_oclass; |
96 | extern struct nouveau_oclass *nv35_fb_oclass; |
97 | extern struct nouveau_oclass *nv36_fb_oclass; |
98 | extern struct nouveau_oclass *nv40_fb_oclass; |
99 | extern struct nouveau_oclass *nv41_fb_oclass; |
100 | extern struct nouveau_oclass *nv44_fb_oclass; |
101 | extern struct nouveau_oclass *nv46_fb_oclass; |
102 | extern struct nouveau_oclass *nv47_fb_oclass; |
103 | extern struct nouveau_oclass *nv49_fb_oclass; |
104 | extern struct nouveau_oclass *nv4e_fb_oclass; |
105 | extern struct nouveau_oclass *nv50_fb_oclass; |
106 | extern struct nouveau_oclass *nv84_fb_oclass; |
107 | extern struct nouveau_oclass *nva3_fb_oclass; |
108 | extern struct nouveau_oclass *nvaa_fb_oclass; |
109 | extern struct nouveau_oclass *nvaf_fb_oclass; |
110 | extern struct nouveau_oclass *nvc0_fb_oclass; |
111 | extern struct nouveau_oclass *nve0_fb_oclass; |
112 | extern struct nouveau_oclass *gk20a_fb_oclass; |
113 | extern struct nouveau_oclass *gm107_fb_oclass; |
114 | |
115 | #include <subdev/bios/ramcfg.h> |
116 | |
117 | struct nouveau_ram_data { |
118 | struct nvbios_ramcfg bios; |
119 | u32 freq; |
120 | }; |
121 | |
122 | struct nouveau_ram { |
123 | struct nouveau_object base; |
124 | enum { |
125 | NV_MEM_TYPE_UNKNOWN = 0, |
126 | NV_MEM_TYPE_STOLEN, |
127 | NV_MEM_TYPE_SGRAM, |
128 | NV_MEM_TYPE_SDRAM, |
129 | NV_MEM_TYPE_DDR1, |
130 | NV_MEM_TYPE_DDR2, |
131 | NV_MEM_TYPE_DDR3, |
132 | NV_MEM_TYPE_GDDR2, |
133 | NV_MEM_TYPE_GDDR3, |
134 | NV_MEM_TYPE_GDDR4, |
135 | NV_MEM_TYPE_GDDR5 |
136 | } type; |
137 | u64 stolen; |
138 | u64 size; |
139 | u32 tags; |
140 | |
141 | int ranks; |
142 | int parts; |
143 | |
144 | int (*get)(struct nouveau_fb *, u64 size, u32 align, |
145 | u32 size_nc, u32 type, struct nouveau_mem **); |
146 | void (*put)(struct nouveau_fb *, struct nouveau_mem **); |
147 | |
148 | int (*calc)(struct nouveau_fb *, u32 freq); |
149 | int (*prog)(struct nouveau_fb *); |
150 | void (*tidy)(struct nouveau_fb *); |
151 | struct { |
152 | u8 version; |
153 | u32 data; |
154 | u8 size; |
155 | } rammap, ramcfg, timing; |
156 | u32 freq; |
157 | u32 mr[16]; |
158 | u32 mr1_nuts; |
159 | |
160 | struct nouveau_ram_data *next; |
161 | struct nouveau_ram_data former; |
162 | struct nouveau_ram_data xition; |
163 | struct nouveau_ram_data target; |
164 | }; |
165 | |
166 | #endif |
167 | |