1 #ifndef __NVKM_DEVICE_H__
2 #define __NVKM_DEVICE_H__
3 #include <core/event.h>
4 #include <core/object.h>
36 NVKM_ENGINE_CE_LAST = NVKM_ENGINE_CE2,
53 NVKM_ENGINE_NVENC_LAST = NVKM_ENGINE_NVENC1,
65 enum nvkm_device_type {
73 const struct nvkm_device_func *func;
74 const struct nvkm_device_quirk *quirk;
76 enum nvkm_device_type type;
82 struct list_head head;
88 struct nvkm_event event;
93 const struct nvkm_device_chip *chip;
111 struct notifier_block nb;
114 struct nvkm_bar *bar;
115 struct nvkm_bios *bios;
116 struct nvkm_bus *bus;
117 struct nvkm_clk *clk;
118 struct nvkm_devinit *devinit;
120 struct nvkm_fuse *fuse;
121 struct nvkm_gpio *gpio;
122 struct nvkm_i2c *i2c;
123 struct nvkm_subdev *ibus;
124 struct nvkm_iccsense *iccsense;
125 struct nvkm_instmem *imem;
126 struct nvkm_ltc *ltc;
128 struct nvkm_mmu *mmu;
129 struct nvkm_subdev *mxm;
130 struct nvkm_pci *pci;
131 struct nvkm_pmu *pmu;
132 struct nvkm_secboot *secboot;
133 struct nvkm_therm *therm;
134 struct nvkm_timer *timer;
135 struct nvkm_top *top;
136 struct nvkm_volt *volt;
138 struct nvkm_engine *bsp;
139 struct nvkm_engine *ce[3];
140 struct nvkm_engine *cipher;
141 struct nvkm_disp *disp;
142 struct nvkm_dma *dma;
143 struct nvkm_fifo *fifo;
145 struct nvkm_engine *ifb;
146 struct nvkm_engine *me;
147 struct nvkm_engine *mpeg;
148 struct nvkm_engine *msenc;
149 struct nvkm_engine *mspdec;
150 struct nvkm_engine *msppp;
151 struct nvkm_engine *msvld;
152 struct nvkm_engine *nvenc[2];
153 struct nvkm_engine *nvdec;
155 struct nvkm_engine *sec;
157 struct nvkm_engine *vic;
158 struct nvkm_engine *vp;
161 struct nvkm_subdev *nvkm_device_subdev(struct nvkm_device *, int index);
162 struct nvkm_engine *nvkm_device_engine(struct nvkm_device *, int index);
164 struct nvkm_device_func {
165 struct nvkm_device_pci *(*pci)(struct nvkm_device *);
166 struct nvkm_device_tegra *(*tegra)(struct nvkm_device *);
167 void *(*dtor)(struct nvkm_device *);
168 int (*preinit)(struct nvkm_device *);
169 int (*init)(struct nvkm_device *);
170 void (*fini)(struct nvkm_device *, bool suspend);
171 resource_size_t (*resource_addr)(struct nvkm_device *, unsigned bar);
172 resource_size_t (*resource_size)(struct nvkm_device *, unsigned bar);
176 struct nvkm_device_quirk {
181 struct nvkm_device_chip {
184 int (*bar )(struct nvkm_device *, int idx, struct nvkm_bar **);
185 int (*bios )(struct nvkm_device *, int idx, struct nvkm_bios **);
186 int (*bus )(struct nvkm_device *, int idx, struct nvkm_bus **);
187 int (*clk )(struct nvkm_device *, int idx, struct nvkm_clk **);
188 int (*devinit )(struct nvkm_device *, int idx, struct nvkm_devinit **);
189 int (*fb )(struct nvkm_device *, int idx, struct nvkm_fb **);
190 int (*fuse )(struct nvkm_device *, int idx, struct nvkm_fuse **);
191 int (*gpio )(struct nvkm_device *, int idx, struct nvkm_gpio **);
192 int (*i2c )(struct nvkm_device *, int idx, struct nvkm_i2c **);
193 int (*ibus )(struct nvkm_device *, int idx, struct nvkm_subdev **);
194 int (*iccsense)(struct nvkm_device *, int idx, struct nvkm_iccsense **);
195 int (*imem )(struct nvkm_device *, int idx, struct nvkm_instmem **);
196 int (*ltc )(struct nvkm_device *, int idx, struct nvkm_ltc **);
197 int (*mc )(struct nvkm_device *, int idx, struct nvkm_mc **);
198 int (*mmu )(struct nvkm_device *, int idx, struct nvkm_mmu **);
199 int (*mxm )(struct nvkm_device *, int idx, struct nvkm_subdev **);
200 int (*pci )(struct nvkm_device *, int idx, struct nvkm_pci **);
201 int (*pmu )(struct nvkm_device *, int idx, struct nvkm_pmu **);
202 int (*secboot )(struct nvkm_device *, int idx, struct nvkm_secboot **);
203 int (*therm )(struct nvkm_device *, int idx, struct nvkm_therm **);
204 int (*timer )(struct nvkm_device *, int idx, struct nvkm_timer **);
205 int (*top )(struct nvkm_device *, int idx, struct nvkm_top **);
206 int (*volt )(struct nvkm_device *, int idx, struct nvkm_volt **);
208 int (*bsp )(struct nvkm_device *, int idx, struct nvkm_engine **);
209 int (*ce[3] )(struct nvkm_device *, int idx, struct nvkm_engine **);
210 int (*cipher )(struct nvkm_device *, int idx, struct nvkm_engine **);
211 int (*disp )(struct nvkm_device *, int idx, struct nvkm_disp **);
212 int (*dma )(struct nvkm_device *, int idx, struct nvkm_dma **);
213 int (*fifo )(struct nvkm_device *, int idx, struct nvkm_fifo **);
214 int (*gr )(struct nvkm_device *, int idx, struct nvkm_gr **);
215 int (*ifb )(struct nvkm_device *, int idx, struct nvkm_engine **);
216 int (*me )(struct nvkm_device *, int idx, struct nvkm_engine **);
217 int (*mpeg )(struct nvkm_device *, int idx, struct nvkm_engine **);
218 int (*msenc )(struct nvkm_device *, int idx, struct nvkm_engine **);
219 int (*mspdec )(struct nvkm_device *, int idx, struct nvkm_engine **);
220 int (*msppp )(struct nvkm_device *, int idx, struct nvkm_engine **);
221 int (*msvld )(struct nvkm_device *, int idx, struct nvkm_engine **);
222 int (*nvenc[2])(struct nvkm_device *, int idx, struct nvkm_engine **);
223 int (*nvdec )(struct nvkm_device *, int idx, struct nvkm_engine **);
224 int (*pm )(struct nvkm_device *, int idx, struct nvkm_pm **);
225 int (*sec )(struct nvkm_device *, int idx, struct nvkm_engine **);
226 int (*sw )(struct nvkm_device *, int idx, struct nvkm_sw **);
227 int (*vic )(struct nvkm_device *, int idx, struct nvkm_engine **);
228 int (*vp )(struct nvkm_device *, int idx, struct nvkm_engine **);
231 struct nvkm_device *nvkm_device_find(u64 name);
232 int nvkm_device_list(u64 *name, int size);
234 /* privileged register interface accessor macros */
235 #define nvkm_rd08(d,a) ioread8((d)->pri + (a))
236 #define nvkm_rd16(d,a) ioread16_native((d)->pri + (a))
237 #define nvkm_rd32(d,a) ioread32_native((d)->pri + (a))
238 #define nvkm_wr08(d,a,v) iowrite8((v), (d)->pri + (a))
239 #define nvkm_wr16(d,a,v) iowrite16_native((v), (d)->pri + (a))
240 #define nvkm_wr32(d,a,v) iowrite32_native((v), (d)->pri + (a))
241 #define nvkm_mask(d,a,m,v) ({ \
242 struct nvkm_device *_device = (d); \
243 u32 _addr = (a), _temp = nvkm_rd32(_device, _addr); \
244 nvkm_wr32(_device, _addr, (_temp & ~(m)) | (v)); \
248 void nvkm_device_del(struct nvkm_device **);
250 struct nvkm_device_oclass {
251 int (*ctor)(struct nvkm_device *, const struct nvkm_oclass *,
252 void *data, u32 size, struct nvkm_object **);
253 struct nvkm_sclass base;
256 extern const struct nvkm_sclass nvkm_udevice_sclass;
259 #define nvdev_printk_(d,l,p,f,a...) do { \
260 struct nvkm_device *_device = (d); \
261 if (_device->debug >= (l)) \
262 dev_##p(_device->dev, f, ##a); \
264 #define nvdev_printk(d,l,p,f,a...) nvdev_printk_((d), NV_DBG_##l, p, f, ##a)
265 #define nvdev_fatal(d,f,a...) nvdev_printk((d), FATAL, crit, f, ##a)
266 #define nvdev_error(d,f,a...) nvdev_printk((d), ERROR, err, f, ##a)
267 #define nvdev_warn(d,f,a...) nvdev_printk((d), WARN, notice, f, ##a)
268 #define nvdev_info(d,f,a...) nvdev_printk((d), INFO, info, f, ##a)
269 #define nvdev_debug(d,f,a...) nvdev_printk((d), DEBUG, info, f, ##a)
270 #define nvdev_trace(d,f,a...) nvdev_printk((d), TRACE, info, f, ##a)
271 #define nvdev_spam(d,f,a...) nvdev_printk((d), SPAM, dbg, f, ##a)