fb.h 5.0 KB
Newer Older
1 2
#ifndef __NVKM_FB_H__
#define __NVKM_FB_H__
3
#include <core/subdev.h>
4

5
#include <subdev/mmu.h>
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

/* memory type/access flags, do not match hardware values */
#define NV_MEM_ACCESS_RO  1
#define NV_MEM_ACCESS_WO  2
#define NV_MEM_ACCESS_RW (NV_MEM_ACCESS_RO | NV_MEM_ACCESS_WO)
#define NV_MEM_ACCESS_SYS 4
#define NV_MEM_ACCESS_VM  8
#define NV_MEM_ACCESS_NOSNOOP 16

#define NV_MEM_TARGET_VRAM        0
#define NV_MEM_TARGET_PCI         1
#define NV_MEM_TARGET_PCI_NOSNOOP 2
#define NV_MEM_TARGET_VM          3
#define NV_MEM_TARGET_GART        4

21
#define NVKM_RAM_TYPE_VM 0x7f
22 23
#define NV_MEM_COMP_VM 0x03

24 25
struct nvkm_mem {
	struct nvkm_mm_node *tag;
26
	struct nvkm_mm_node *mem;
27 28 29 30 31 32 33
	dma_addr_t *pages;
	u32 memtype;
	u64 offset;
	u64 size;
	struct sg_table *sg;
};

34 35
struct nvkm_fb_tile {
	struct nvkm_mm_node *tag;
36 37 38 39 40 41
	u32 addr;
	u32 limit;
	u32 pitch;
	u32 zcomp;
};

42
struct nvkm_fb {
43
	const struct nvkm_fb_func *func;
B
Ben Skeggs 已提交
44
	struct nvkm_subdev subdev;
45

46
	struct nvkm_ram *ram;
47
	struct nvkm_mm tags;
48 49

	struct {
50
		struct nvkm_fb_tile region[16];
51 52
		int regions;
	} tile;
53

54 55
	u8 page;

56 57
	struct nvkm_memory *mmu_rd;
	struct nvkm_memory *mmu_wr;
58 59
};

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
bool nvkm_fb_memtype_valid(struct nvkm_fb *, u32 memtype);
void nvkm_fb_tile_init(struct nvkm_fb *, int region, u32 addr, u32 size,
		       u32 pitch, u32 flags, struct nvkm_fb_tile *);
void nvkm_fb_tile_fini(struct nvkm_fb *, int region, struct nvkm_fb_tile *);
void nvkm_fb_tile_prog(struct nvkm_fb *, int region, struct nvkm_fb_tile *);

int nv04_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int nv10_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int nv1a_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int nv20_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int nv25_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int nv30_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int nv35_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int nv36_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int nv40_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int nv41_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int nv44_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int nv46_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int nv47_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int nv49_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int nv4e_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int nv50_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int g84_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int gt215_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int mcp77_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int mcp89_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int gf100_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
87
int gf108_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
88 89 90
int gk104_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int gk20a_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
int gm107_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
91
int gm200_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
92
int gm20b_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
93
int gp100_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
94
int gp102_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
95
int gp10b_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
96

97
#include <subdev/bios.h>
98 99
#include <subdev/bios/ramcfg.h>

100
struct nvkm_ram_data {
101
	struct list_head head;
102
	struct nvbios_ramcfg bios;
103
	u32 freq;
104 105
};

106 107 108 109 110 111 112 113 114 115 116 117 118 119
enum nvkm_ram_type {
	NVKM_RAM_TYPE_UNKNOWN = 0,
	NVKM_RAM_TYPE_STOLEN,
	NVKM_RAM_TYPE_SGRAM,
	NVKM_RAM_TYPE_SDRAM,
	NVKM_RAM_TYPE_DDR1,
	NVKM_RAM_TYPE_DDR2,
	NVKM_RAM_TYPE_DDR3,
	NVKM_RAM_TYPE_GDDR2,
	NVKM_RAM_TYPE_GDDR3,
	NVKM_RAM_TYPE_GDDR4,
	NVKM_RAM_TYPE_GDDR5
};

120
struct nvkm_ram {
121 122 123
	const struct nvkm_ram_func *func;
	struct nvkm_fb *fb;
	enum nvkm_ram_type type;
124
	u64 size;
125 126

#define NVKM_RAM_MM_SHIFT 12
127 128 129 130
#define NVKM_RAM_MM_ANY    (NVKM_MM_HEAP_ANY + 0)
#define NVKM_RAM_MM_NORMAL (NVKM_MM_HEAP_ANY + 1)
#define NVKM_RAM_MM_NOMAP  (NVKM_MM_HEAP_ANY + 2)
#define NVKM_RAM_MM_MIXED  (NVKM_MM_HEAP_ANY + 3)
131 132
	struct nvkm_mm vram;
	u64 stolen;
133

134 135
	int ranks;
	int parts;
136
	int part_mask;
137

138 139
	u32 freq;
	u32 mr[16];
140
	u32 mr1_nuts;
141

142 143 144 145
	struct nvkm_ram_data *next;
	struct nvkm_ram_data former;
	struct nvkm_ram_data xition;
	struct nvkm_ram_data target;
146
};
147 148

struct nvkm_ram_func {
149 150 151 152 153 154
	u64 upper;
	u32 (*probe_fbp)(const struct nvkm_ram_func *, struct nvkm_device *,
			 int fbp, int *pltcs);
	u32 (*probe_fbp_amount)(const struct nvkm_ram_func *, u32 fbpao,
				struct nvkm_device *, int fbp, int *pltcs);
	u32 (*probe_fbpa_amount)(struct nvkm_device *, int fbpa);
155 156 157 158 159 160 161 162 163 164 165
	void *(*dtor)(struct nvkm_ram *);
	int (*init)(struct nvkm_ram *);

	int (*get)(struct nvkm_ram *, u64 size, u32 align, u32 size_nc,
		   u32 type, struct nvkm_mem **);
	void (*put)(struct nvkm_ram *, struct nvkm_mem **);

	int (*calc)(struct nvkm_ram *, u32 freq);
	int (*prog)(struct nvkm_ram *);
	void (*tidy)(struct nvkm_ram *);
};
166 167

extern const u8 gf100_pte_storage_type_map[256];
168
#endif