1 #include "nouveau_drm.h"
2 #include "nouveau_compat.h"
4 #include <subdev/bios.h>
5 #include <subdev/gpio.h>
7 void *nouveau_newpriv(struct drm_device *);
10 _nv_rd08(struct drm_device *dev, u32 reg)
12 struct nouveau_drm *drm = nouveau_newpriv(dev);
13 return nv_ro08(drm->device, reg);
17 _nv_wr08(struct drm_device *dev, u32 reg, u8 val)
19 struct nouveau_drm *drm = nouveau_newpriv(dev);
20 nv_wo08(drm->device, reg, val);
24 _nv_rd32(struct drm_device *dev, u32 reg)
26 struct nouveau_drm *drm = nouveau_newpriv(dev);
27 return nv_ro32(drm->device, reg);
31 _nv_wr32(struct drm_device *dev, u32 reg, u32 val)
33 struct nouveau_drm *drm = nouveau_newpriv(dev);
34 nv_wo32(drm->device, reg, val);
38 _nv_mask(struct drm_device *dev, u32 reg, u32 mask, u32 val)
40 u32 tmp = _nv_rd32(dev, reg);
41 _nv_wr32(dev, reg, (tmp & ~mask) | val);
46 _nv_bios(struct drm_device *dev, u8 **data, u32 *size)
48 struct nouveau_drm *drm = nouveau_newpriv(dev);
49 struct nouveau_bios *bios = nouveau_bios(drm->device);
56 nouveau_gpio_reset(struct drm_device *dev)
58 struct nouveau_drm *drm = nouveau_newpriv(dev);
59 struct nouveau_gpio *gpio = nouveau_gpio(drm->device);
64 nouveau_gpio_find(struct drm_device *dev, int idx, u8 tag, u8 line,
65 struct dcb_gpio_func *func)
67 struct nouveau_drm *drm = nouveau_newpriv(dev);
68 struct nouveau_gpio *gpio = nouveau_gpio(drm->device);
70 return gpio->find(gpio, idx, tag, line, func);
74 nouveau_gpio_func_valid(struct drm_device *dev, u8 tag)
76 struct nouveau_drm *drm = nouveau_newpriv(dev);
77 struct nouveau_gpio *gpio = nouveau_gpio(drm->device);
78 struct dcb_gpio_func func;
80 return gpio->find(gpio, 0, tag, 0xff, &func) == 0;
84 nouveau_gpio_func_set(struct drm_device *dev, u8 tag, int state)
86 struct nouveau_drm *drm = nouveau_newpriv(dev);
87 struct nouveau_gpio *gpio = nouveau_gpio(drm->device);
88 if (gpio && gpio->get)
89 return gpio->set(gpio, 0, tag, 0xff, state);
94 nouveau_gpio_func_get(struct drm_device *dev, u8 tag)
96 struct nouveau_drm *drm = nouveau_newpriv(dev);
97 struct nouveau_gpio *gpio = nouveau_gpio(drm->device);
98 if (gpio && gpio->get)
99 return gpio->get(gpio, 0, tag, 0xff);
104 nouveau_gpio_irq(struct drm_device *dev, int idx, u8 tag, u8 line, bool on)
106 struct nouveau_drm *drm = nouveau_newpriv(dev);
107 struct nouveau_gpio *gpio = nouveau_gpio(drm->device);
108 if (gpio && gpio->irq)
109 return gpio->irq(gpio, idx, tag, line, on);
114 nouveau_gpio_isr_add(struct drm_device *dev, int idx, u8 tag, u8 line,
115 void (*exec)(void *, int state), void *data)
117 struct nouveau_drm *drm = nouveau_newpriv(dev);
118 struct nouveau_gpio *gpio = nouveau_gpio(drm->device);
119 if (gpio && gpio->isr_add)
120 return gpio->isr_add(gpio, idx, tag, line, exec, data);
125 nouveau_gpio_isr_del(struct drm_device *dev, int idx, u8 tag, u8 line,
126 void (*exec)(void *, int state), void *data)
128 struct nouveau_drm *drm = nouveau_newpriv(dev);
129 struct nouveau_gpio *gpio = nouveau_gpio(drm->device);
130 if (gpio && gpio->isr_del)
131 gpio->isr_del(gpio, idx, tag, line, exec, data);