summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/nouveau/nv50_gpio.c
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2011-07-02 20:57:35 +0400
committerBen Skeggs <bskeggs@redhat.com>2011-09-20 10:05:36 +0400
commitd7f8172ca93b61135d6db293c6440b2e97fc87ee (patch)
treea3124b1956a2cacdacb0d04035996415484f6357 /drivers/gpu/drm/nouveau/nv50_gpio.c
parenteeb3ca12b4658c569bd60fe60c4c45c627e842a6 (diff)
downloadlinux-d7f8172ca93b61135d6db293c6440b2e97fc87ee.tar.xz
drm/nvd0/gpio: initial implementation
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nv50_gpio.c')
-rw-r--r--drivers/gpu/drm/nouveau/nv50_gpio.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/nv50_gpio.c b/drivers/gpu/drm/nouveau/nv50_gpio.c
index d4f4206dad7e..793a5ccca121 100644
--- a/drivers/gpu/drm/nouveau/nv50_gpio.c
+++ b/drivers/gpu/drm/nouveau/nv50_gpio.c
@@ -98,6 +98,37 @@ nv50_gpio_set(struct drm_device *dev, enum dcb_gpio_tag tag, int state)
}
int
+nvd0_gpio_get(struct drm_device *dev, enum dcb_gpio_tag tag)
+{
+ struct dcb_gpio_entry *gpio;
+ u32 v;
+
+ gpio = nouveau_bios_gpio_entry(dev, tag);
+ if (!gpio)
+ return -ENOENT;
+
+ v = nv_rd32(dev, 0x00d610 + (gpio->line * 4));
+ v &= 0x00004000;
+ return (!!v == (gpio->state[1] & 1));
+}
+
+int
+nvd0_gpio_set(struct drm_device *dev, enum dcb_gpio_tag tag, int state)
+{
+ struct dcb_gpio_entry *gpio;
+ u32 v;
+
+ gpio = nouveau_bios_gpio_entry(dev, tag);
+ if (!gpio)
+ return -ENOENT;
+
+ v = gpio->state[state] ^ 2;
+
+ nv_mask(dev, 0x00d610 + (gpio->line * 4), 0x00003000, v << 12);
+ return 0;
+}
+
+int
nv50_gpio_irq_register(struct drm_device *dev, enum dcb_gpio_tag tag,
void (*handler)(void *, int), void *data)
{