1#ifndef __NVKM_DEVICE_H__ 2#define __NVKM_DEVICE_H__ 3#include <core/engine.h> 4#include <core/event.h> 5 6struct nvkm_device { 7 struct nvkm_engine engine; 8 struct list_head head; 9 10 struct pci_dev *pdev; 11 struct platform_device *platformdev; 12 u64 handle; 13 14 struct nvkm_event event; 15 16 const char *cfgopt; 17 const char *dbgopt; 18 const char *name; 19 const char *cname; 20 u64 disable_mask; 21 22 enum { 23 NV_04 = 0x04, 24 NV_10 = 0x10, 25 NV_11 = 0x11, 26 NV_20 = 0x20, 27 NV_30 = 0x30, 28 NV_40 = 0x40, 29 NV_50 = 0x50, 30 NV_C0 = 0xc0, 31 NV_E0 = 0xe0, 32 GM100 = 0x110, 33 } card_type; 34 u32 chipset; 35 u8 chiprev; 36 u32 crystal; 37 38 struct nvkm_oclass *oclass[NVDEV_SUBDEV_NR]; 39 struct nvkm_object *subdev[NVDEV_SUBDEV_NR]; 40 41 struct { 42 struct notifier_block nb; 43 } acpi; 44}; 45 46struct nvkm_device *nvkm_device_find(u64 name); 47int nvkm_device_list(u64 *name, int size); 48 49struct nvkm_device *nv_device(void *obj); 50 51static inline bool 52nv_device_match(struct nvkm_object *object, u16 dev, u16 ven, u16 sub) 53{ 54 struct nvkm_device *device = nv_device(object); 55 return device->pdev->device == dev && 56 device->pdev->subsystem_vendor == ven && 57 device->pdev->subsystem_device == sub; 58} 59 60static inline bool 61nv_device_is_pci(struct nvkm_device *device) 62{ 63 return device->pdev != NULL; 64} 65 66static inline bool 67nv_device_is_cpu_coherent(struct nvkm_device *device) 68{ 69 return (!IS_ENABLED(CONFIG_ARM) && nv_device_is_pci(device)); 70} 71 72static inline struct device * 73nv_device_base(struct nvkm_device *device) 74{ 75 return nv_device_is_pci(device) ? &device->pdev->dev : 76 &device->platformdev->dev; 77} 78 79resource_size_t 80nv_device_resource_start(struct nvkm_device *device, unsigned int bar); 81 82resource_size_t 83nv_device_resource_len(struct nvkm_device *device, unsigned int bar); 84 85int 86nv_device_get_irq(struct nvkm_device *device, bool stall); 87 88struct platform_device; 89 90enum nv_bus_type { 91 NVKM_BUS_PCI, 92 NVKM_BUS_PLATFORM, 93}; 94 95#define nvkm_device_create(p,t,n,s,c,d,u) \ 96 nvkm_device_create_((void *)(p), (t), (n), (s), (c), (d), \ 97 sizeof(**u), (void **)u) 98int nvkm_device_create_(void *, enum nv_bus_type type, u64 name, 99 const char *sname, const char *cfg, const char *dbg, 100 int, void **); 101#endif 102