fb.h 3.9 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
struct nvkm_mem {
25 26
	struct drm_device *dev;

27 28
	struct nvkm_vma bar_vma;
	struct nvkm_vma vma[2];
29 30
	u8  page_shift;

31
	struct nvkm_mm_node *tag;
32 33 34 35 36 37 38 39
	struct list_head regions;
	dma_addr_t *pages;
	u32 memtype;
	u64 offset;
	u64 size;
	struct sg_table *sg;
};

40 41
struct nvkm_fb_tile {
	struct nvkm_mm_node *tag;
42 43 44 45 46 47
	u32 addr;
	u32 limit;
	u32 pitch;
	u32 zcomp;
};

48
struct nvkm_fb {
B
Ben Skeggs 已提交
49
	struct nvkm_subdev subdev;
50

51
	bool (*memtype_valid)(struct nvkm_fb *, u32 memtype);
52

53
	struct nvkm_ram *ram;
54 55

	struct {
56
		struct nvkm_fb_tile region[16];
57
		int regions;
58 59 60 61 62 63
		void (*init)(struct nvkm_fb *, int i, u32 addr, u32 size,
			     u32 pitch, u32 flags, struct nvkm_fb_tile *);
		void (*comp)(struct nvkm_fb *, int i, u32 size, u32 flags,
			     struct nvkm_fb_tile *);
		void (*fini)(struct nvkm_fb *, int i, struct nvkm_fb_tile *);
		void (*prog)(struct nvkm_fb *, int i, struct nvkm_fb_tile *);
64 65 66
	} tile;
};

67 68
static inline struct nvkm_fb *
nvkm_fb(void *obj)
69
{
70 71 72 73 74
	/* fbram uses this before device subdev pointer is valid */
	if (nv_iclass(obj, NV_SUBDEV_CLASS) &&
	    nv_subidx(obj) == NVDEV_SUBDEV_FB)
		return obj;

75
	return (void *)nvkm_subdev(obj, NVDEV_SUBDEV_FB);
76 77
}

78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
extern struct nvkm_oclass *nv04_fb_oclass;
extern struct nvkm_oclass *nv10_fb_oclass;
extern struct nvkm_oclass *nv1a_fb_oclass;
extern struct nvkm_oclass *nv20_fb_oclass;
extern struct nvkm_oclass *nv25_fb_oclass;
extern struct nvkm_oclass *nv30_fb_oclass;
extern struct nvkm_oclass *nv35_fb_oclass;
extern struct nvkm_oclass *nv36_fb_oclass;
extern struct nvkm_oclass *nv40_fb_oclass;
extern struct nvkm_oclass *nv41_fb_oclass;
extern struct nvkm_oclass *nv44_fb_oclass;
extern struct nvkm_oclass *nv46_fb_oclass;
extern struct nvkm_oclass *nv47_fb_oclass;
extern struct nvkm_oclass *nv49_fb_oclass;
extern struct nvkm_oclass *nv4e_fb_oclass;
extern struct nvkm_oclass *nv50_fb_oclass;
extern struct nvkm_oclass *g84_fb_oclass;
extern struct nvkm_oclass *gt215_fb_oclass;
extern struct nvkm_oclass *mcp77_fb_oclass;
extern struct nvkm_oclass *mcp89_fb_oclass;
extern struct nvkm_oclass *gf100_fb_oclass;
extern struct nvkm_oclass *gk104_fb_oclass;
extern struct nvkm_oclass *gk20a_fb_oclass;
extern struct nvkm_oclass *gm107_fb_oclass;
102

103
#include <subdev/bios.h>
104 105
#include <subdev/bios/ramcfg.h>

106
struct nvkm_ram_data {
107
	struct list_head head;
108
	struct nvbios_ramcfg bios;
109
	u32 freq;
110 111
};

112 113 114 115 116 117 118 119 120 121 122 123 124 125
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
};

126
struct nvkm_ram {
127 128 129
	const struct nvkm_ram_func *func;
	struct nvkm_fb *fb;
	enum nvkm_ram_type type;
130
	u64 size;
131 132 133 134 135

#define NVKM_RAM_MM_SHIFT 12
	struct nvkm_mm vram;
	struct nvkm_mm tags;
	u64 stolen;
136

137 138
	int ranks;
	int parts;
139
	int part_mask;
140

141 142
	u32 freq;
	u32 mr[16];
143
	u32 mr1_nuts;
144

145 146 147 148
	struct nvkm_ram_data *next;
	struct nvkm_ram_data former;
	struct nvkm_ram_data xition;
	struct nvkm_ram_data target;
149
};
150 151 152 153 154 155 156 157 158 159 160 161 162

struct nvkm_ram_func {
	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 *);
};
163
#endif