1 #ifndef __NVKM_DEVICE_H__
2 #define __NVKM_DEVICE_H__
3 #include <core/engine.h>
4 #include <core/event.h>
10 /* All subdevs from DEVINIT to DEVINIT_LAST will be created before
11 * *any* of them are initialised. This subdev category is used
12 * for any subdevs that the VBIOS init table parsing may call out
19 NVDEV_SUBDEV_DEVINIT_LAST = NVDEV_SUBDEV_I2C,
21 /* This grouping of subdevs are initialised right after they've
22 * been created, and are allowed to assume any subdevs in the
23 * list above them exist and have been initialised.
41 NVDEV_ENGINE_DMAOBJ = NVDEV_ENGINE_FIRST,
67 struct nvkm_engine engine;
68 struct list_head head;
71 struct platform_device *platformdev;
77 struct nvkm_event event;
101 struct nvkm_oclass *oclass[NVDEV_SUBDEV_NR];
102 struct nvkm_object *subdev[NVDEV_SUBDEV_NR];
105 struct notifier_block nb;
108 struct nvkm_bar *bar;
109 struct nvkm_bios *bios;
110 struct nvkm_bus *bus;
111 struct nvkm_clk *clk;
112 struct nvkm_devinit *devinit;
114 struct nvkm_fuse *fuse;
115 struct nvkm_gpio *gpio;
116 struct nvkm_i2c *i2c;
117 struct nvkm_subdev *ibus;
118 struct nvkm_instmem *imem;
119 struct nvkm_ltc *ltc;
121 struct nvkm_mmu *mmu;
122 struct nvkm_subdev *mxm;
123 struct nvkm_pmu *pmu;
124 struct nvkm_therm *therm;
125 struct nvkm_timer *timer;
126 struct nvkm_volt *volt;
128 struct nvkm_engine *bsp;
129 struct nvkm_engine *ce[3];
130 struct nvkm_engine *cipher;
131 struct nvkm_disp *disp;
132 struct nvkm_dmaeng *dma;
133 struct nvkm_fifo *fifo;
135 struct nvkm_engine *ifb;
136 struct nvkm_engine *me;
137 struct nvkm_engine *mpeg;
138 struct nvkm_engine *msenc;
139 struct nvkm_engine *mspdec;
140 struct nvkm_engine *msppp;
141 struct nvkm_engine *msvld;
143 struct nvkm_engine *sec;
145 struct nvkm_engine *vic;
146 struct nvkm_engine *vp;
149 struct nvkm_device *nvkm_device_find(u64 name);
150 int nvkm_device_list(u64 *name, int size);
152 /* privileged register interface accessor macros */
153 #define nvkm_rd08(d,a) ioread8((d)->pri + (a))
154 #define nvkm_rd16(d,a) ioread16_native((d)->pri + (a))
155 #define nvkm_rd32(d,a) ioread32_native((d)->pri + (a))
156 #define nvkm_wr08(d,a,v) iowrite8((v), (d)->pri + (a))
157 #define nvkm_wr16(d,a,v) iowrite16_native((v), (d)->pri + (a))
158 #define nvkm_wr32(d,a,v) iowrite32_native((v), (d)->pri + (a))
159 #define nvkm_mask(d,a,m,v) ({ \
160 struct nvkm_device *_device = (d); \
161 u32 _addr = (a), _temp = nvkm_rd32(_device, _addr); \
162 nvkm_wr32(_device, _addr, (_temp & ~(m)) | (v)); \
166 struct nvkm_device *nv_device(void *obj);
169 nv_device_match(struct nvkm_device *device, u16 dev, u16 ven, u16 sub)
171 return device->pdev->device == dev &&
172 device->pdev->subsystem_vendor == ven &&
173 device->pdev->subsystem_device == sub;
177 nv_device_is_pci(struct nvkm_device *device)
179 return device->pdev != NULL;
183 nv_device_is_cpu_coherent(struct nvkm_device *device)
185 return (!IS_ENABLED(CONFIG_ARM) && nv_device_is_pci(device));
188 static inline struct device *
189 nv_device_base(struct nvkm_device *device)
191 return nv_device_is_pci(device) ? &device->pdev->dev :
192 &device->platformdev->dev;
196 nv_device_resource_start(struct nvkm_device *device, unsigned int bar);
199 nv_device_resource_len(struct nvkm_device *device, unsigned int bar);
202 nv_device_get_irq(struct nvkm_device *device, bool stall);
204 struct platform_device;
211 #define nvkm_device_create(p,t,n,s,c,d,u) \
212 nvkm_device_create_((void *)(p), (t), (n), (s), (c), (d), \
213 sizeof(**u), (void **)u)
214 int nvkm_device_create_(void *, enum nv_bus_type type, u64 name,
215 const char *sname, const char *cfg, const char *dbg,
219 #define nvdev_printk_(d,l,p,f,a...) do { \
220 struct nvkm_device *_device = (d); \
221 if (_device->engine.subdev.debug >= (l)) \
222 dev_##p(_device->dev, f, ##a); \
224 #define nvdev_printk(d,l,p,f,a...) nvdev_printk_((d), NV_DBG_##l, p, f, ##a)
225 #define nvdev_fatal(d,f,a...) nvdev_printk((d), FATAL, crit, f, ##a)
226 #define nvdev_error(d,f,a...) nvdev_printk((d), ERROR, err, f, ##a)
227 #define nvdev_warn(d,f,a...) nvdev_printk((d), WARN, notice, f, ##a)
228 #define nvdev_info(d,f,a...) nvdev_printk((d), INFO, info, f, ##a)
229 #define nvdev_debug(d,f,a...) nvdev_printk((d), DEBUG, info, f, ##a)
230 #define nvdev_trace(d,f,a...) nvdev_printk((d), TRACE, info, f, ##a)
231 #define nvdev_spam(d,f,a...) nvdev_printk((d), SPAM, dbg, f, ##a)