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