linux/drivers/gpu/drm/nouveau/include/nvkm/core/device.h
<<
>>
Prefs
   1#ifndef __NVKM_DEVICE_H__
   2#define __NVKM_DEVICE_H__
   3#include <core/event.h>
   4#include <core/object.h>
   5
   6enum nvkm_devidx {
   7        NVKM_SUBDEV_PCI,
   8        NVKM_SUBDEV_VBIOS,
   9        NVKM_SUBDEV_DEVINIT,
  10        NVKM_SUBDEV_TOP,
  11        NVKM_SUBDEV_IBUS,
  12        NVKM_SUBDEV_GPIO,
  13        NVKM_SUBDEV_I2C,
  14        NVKM_SUBDEV_FUSE,
  15        NVKM_SUBDEV_MXM,
  16        NVKM_SUBDEV_MC,
  17        NVKM_SUBDEV_BUS,
  18        NVKM_SUBDEV_TIMER,
  19        NVKM_SUBDEV_INSTMEM,
  20        NVKM_SUBDEV_FB,
  21        NVKM_SUBDEV_LTC,
  22        NVKM_SUBDEV_MMU,
  23        NVKM_SUBDEV_BAR,
  24        NVKM_SUBDEV_PMU,
  25        NVKM_SUBDEV_VOLT,
  26        NVKM_SUBDEV_ICCSENSE,
  27        NVKM_SUBDEV_THERM,
  28        NVKM_SUBDEV_CLK,
  29        NVKM_SUBDEV_SECBOOT,
  30
  31        NVKM_ENGINE_BSP,
  32
  33        NVKM_ENGINE_CE0,
  34        NVKM_ENGINE_CE1,
  35        NVKM_ENGINE_CE2,
  36        NVKM_ENGINE_CE3,
  37        NVKM_ENGINE_CE4,
  38        NVKM_ENGINE_CE5,
  39        NVKM_ENGINE_CE_LAST = NVKM_ENGINE_CE5,
  40
  41        NVKM_ENGINE_CIPHER,
  42        NVKM_ENGINE_DISP,
  43        NVKM_ENGINE_DMAOBJ,
  44        NVKM_ENGINE_FIFO,
  45        NVKM_ENGINE_GR,
  46        NVKM_ENGINE_IFB,
  47        NVKM_ENGINE_ME,
  48        NVKM_ENGINE_MPEG,
  49        NVKM_ENGINE_MSENC,
  50        NVKM_ENGINE_MSPDEC,
  51        NVKM_ENGINE_MSPPP,
  52        NVKM_ENGINE_MSVLD,
  53
  54        NVKM_ENGINE_NVENC0,
  55        NVKM_ENGINE_NVENC1,
  56        NVKM_ENGINE_NVENC2,
  57        NVKM_ENGINE_NVENC_LAST = NVKM_ENGINE_NVENC2,
  58
  59        NVKM_ENGINE_NVDEC,
  60        NVKM_ENGINE_PM,
  61        NVKM_ENGINE_SEC,
  62        NVKM_ENGINE_SW,
  63        NVKM_ENGINE_VIC,
  64        NVKM_ENGINE_VP,
  65
  66        NVKM_SUBDEV_NR
  67};
  68
  69enum nvkm_device_type {
  70        NVKM_DEVICE_PCI,
  71        NVKM_DEVICE_AGP,
  72        NVKM_DEVICE_PCIE,
  73        NVKM_DEVICE_TEGRA,
  74};
  75
  76struct nvkm_device {
  77        const struct nvkm_device_func *func;
  78        const struct nvkm_device_quirk *quirk;
  79        struct device *dev;
  80        enum nvkm_device_type type;
  81        u64 handle;
  82        const char *name;
  83        const char *cfgopt;
  84        const char *dbgopt;
  85
  86        struct list_head head;
  87        struct mutex mutex;
  88        int refcount;
  89
  90        void __iomem *pri;
  91
  92        struct nvkm_event event;
  93
  94        u64 disable_mask;
  95        u32 debug;
  96
  97        const struct nvkm_device_chip *chip;
  98        enum {
  99                NV_04    = 0x04,
 100                NV_10    = 0x10,
 101                NV_11    = 0x11,
 102                NV_20    = 0x20,
 103                NV_30    = 0x30,
 104                NV_40    = 0x40,
 105                NV_50    = 0x50,
 106                NV_C0    = 0xc0,
 107                NV_E0    = 0xe0,
 108                GM100    = 0x110,
 109                GP100    = 0x130,
 110        } card_type;
 111        u32 chipset;
 112        u8  chiprev;
 113        u32 crystal;
 114
 115        struct {
 116                struct notifier_block nb;
 117        } acpi;
 118
 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;
 124        struct nvkm_fb *fb;
 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;
 132        struct nvkm_mc *mc;
 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;
 142
 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;
 149        struct nvkm_gr *gr;
 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;
 159        struct nvkm_pm *pm;
 160        struct nvkm_engine *sec;
 161        struct nvkm_sw *sw;
 162        struct nvkm_engine *vic;
 163        struct nvkm_engine *vp;
 164};
 165
 166struct nvkm_subdev *nvkm_device_subdev(struct nvkm_device *, int index);
 167struct nvkm_engine *nvkm_device_engine(struct nvkm_device *, int index);
 168
 169struct 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);
 178        bool cpu_coherent;
 179};
 180
 181struct nvkm_device_quirk {
 182        u8 tv_pin_mask;
 183        u8 tv_gpio;
 184};
 185
 186struct nvkm_device_chip {
 187        const char *name;
 188
 189        int (*bar     )(struct nvkm_device *, int idx, struct nvkm_bar **);
 190        int (*bios    )(struct nvkm_device *, int idx, struct nvkm_bios **);
 191        int (*bus     )(struct nvkm_device *, int idx, struct nvkm_bus **);
 192        int (*clk     )(struct nvkm_device *, int idx, struct nvkm_clk **);
 193        int (*devinit )(struct nvkm_device *, int idx, struct nvkm_devinit **);
 194        int (*fb      )(struct nvkm_device *, int idx, struct nvkm_fb **);
 195        int (*fuse    )(struct nvkm_device *, int idx, struct nvkm_fuse **);
 196        int (*gpio    )(struct nvkm_device *, int idx, struct nvkm_gpio **);
 197        int (*i2c     )(struct nvkm_device *, int idx, struct nvkm_i2c **);
 198        int (*ibus    )(struct nvkm_device *, int idx, struct nvkm_subdev **);
 199        int (*iccsense)(struct nvkm_device *, int idx, struct nvkm_iccsense **);
 200        int (*imem    )(struct nvkm_device *, int idx, struct nvkm_instmem **);
 201        int (*ltc     )(struct nvkm_device *, int idx, struct nvkm_ltc **);
 202        int (*mc      )(struct nvkm_device *, int idx, struct nvkm_mc **);
 203        int (*mmu     )(struct nvkm_device *, int idx, struct nvkm_mmu **);
 204        int (*mxm     )(struct nvkm_device *, int idx, struct nvkm_subdev **);
 205        int (*pci     )(struct nvkm_device *, int idx, struct nvkm_pci **);
 206        int (*pmu     )(struct nvkm_device *, int idx, struct nvkm_pmu **);
 207        int (*secboot )(struct nvkm_device *, int idx, struct nvkm_secboot **);
 208        int (*therm   )(struct nvkm_device *, int idx, struct nvkm_therm **);
 209        int (*timer   )(struct nvkm_device *, int idx, struct nvkm_timer **);
 210        int (*top     )(struct nvkm_device *, int idx, struct nvkm_top **);
 211        int (*volt    )(struct nvkm_device *, int idx, struct nvkm_volt **);
 212
 213        int (*bsp     )(struct nvkm_device *, int idx, struct nvkm_engine **);
 214        int (*ce[6]   )(struct nvkm_device *, int idx, struct nvkm_engine **);
 215        int (*cipher  )(struct nvkm_device *, int idx, struct nvkm_engine **);
 216        int (*disp    )(struct nvkm_device *, int idx, struct nvkm_disp **);
 217        int (*dma     )(struct nvkm_device *, int idx, struct nvkm_dma **);
 218        int (*fifo    )(struct nvkm_device *, int idx, struct nvkm_fifo **);
 219        int (*gr      )(struct nvkm_device *, int idx, struct nvkm_gr **);
 220        int (*ifb     )(struct nvkm_device *, int idx, struct nvkm_engine **);
 221        int (*me      )(struct nvkm_device *, int idx, struct nvkm_engine **);
 222        int (*mpeg    )(struct nvkm_device *, int idx, struct nvkm_engine **);
 223        int (*msenc   )(struct nvkm_device *, int idx, struct nvkm_engine **);
 224        int (*mspdec  )(struct nvkm_device *, int idx, struct nvkm_engine **);
 225        int (*msppp   )(struct nvkm_device *, int idx, struct nvkm_engine **);
 226        int (*msvld   )(struct nvkm_device *, int idx, struct nvkm_engine **);
 227        int (*nvenc[3])(struct nvkm_device *, int idx, struct nvkm_engine **);
 228        int (*nvdec   )(struct nvkm_device *, int idx, struct nvkm_engine **);
 229        int (*pm      )(struct nvkm_device *, int idx, struct nvkm_pm **);
 230        int (*sec     )(struct nvkm_device *, int idx, struct nvkm_engine **);
 231        int (*sw      )(struct nvkm_device *, int idx, struct nvkm_sw **);
 232        int (*vic     )(struct nvkm_device *, int idx, struct nvkm_engine **);
 233        int (*vp      )(struct nvkm_device *, int idx, struct nvkm_engine **);
 234};
 235
 236struct nvkm_device *nvkm_device_find(u64 name);
 237int nvkm_device_list(u64 *name, int size);
 238
 239/* privileged register interface accessor macros */
 240#define nvkm_rd08(d,a) ioread8((d)->pri + (a))
 241#define nvkm_rd16(d,a) ioread16_native((d)->pri + (a))
 242#define nvkm_rd32(d,a) ioread32_native((d)->pri + (a))
 243#define nvkm_wr08(d,a,v) iowrite8((v), (d)->pri + (a))
 244#define nvkm_wr16(d,a,v) iowrite16_native((v), (d)->pri + (a))
 245#define nvkm_wr32(d,a,v) iowrite32_native((v), (d)->pri + (a))
 246#define nvkm_mask(d,a,m,v) ({                                                  \
 247        struct nvkm_device *_device = (d);                                     \
 248        u32 _addr = (a), _temp = nvkm_rd32(_device, _addr);                    \
 249        nvkm_wr32(_device, _addr, (_temp & ~(m)) | (v));                       \
 250        _temp;                                                                 \
 251})
 252
 253void nvkm_device_del(struct nvkm_device **);
 254
 255struct nvkm_device_oclass {
 256        int (*ctor)(struct nvkm_device *, const struct nvkm_oclass *,
 257                    void *data, u32 size, struct nvkm_object **);
 258        struct nvkm_sclass base;
 259};
 260
 261extern const struct nvkm_sclass nvkm_udevice_sclass;
 262
 263/* device logging */
 264#define nvdev_printk_(d,l,p,f,a...) do {                                       \
 265        struct nvkm_device *_device = (d);                                     \
 266        if (_device->debug >= (l))                                             \
 267                dev_##p(_device->dev, f, ##a);                                 \
 268} while(0)
 269#define nvdev_printk(d,l,p,f,a...) nvdev_printk_((d), NV_DBG_##l, p, f, ##a)
 270#define nvdev_fatal(d,f,a...) nvdev_printk((d), FATAL,   crit, f, ##a)
 271#define nvdev_error(d,f,a...) nvdev_printk((d), ERROR,    err, f, ##a)
 272#define nvdev_warn(d,f,a...)  nvdev_printk((d),  WARN, notice, f, ##a)
 273#define nvdev_info(d,f,a...)  nvdev_printk((d),  INFO,   info, f, ##a)
 274#define nvdev_debug(d,f,a...) nvdev_printk((d), DEBUG,   info, f, ##a)
 275#define nvdev_trace(d,f,a...) nvdev_printk((d), TRACE,   info, f, ##a)
 276#define nvdev_spam(d,f,a...)  nvdev_printk((d),  SPAM,    dbg, f, ##a)
 277#endif
 278