aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2013-02-12 22:34:39 -0500
committerBen Skeggs <bskeggs@redhat.com>2013-02-20 01:00:51 -0500
commitfa531bc8b4278010fd11819c089f6679890addee (patch)
tree96fc7ffa89232074d297318b51a6143e099b7cdf /drivers/gpu
parent4f47643dbb4c345c5beebe53588682a7ff2c872a (diff)
drm/nouveau/gpio/nve0: interrupt regs moved on kepler apparently
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/nouveau/Makefile1
-rw-r--r--drivers/gpu/drm/nouveau/core/include/subdev/gpio.h8
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/device/nve0.c6
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/gpio/nv10.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/gpio/nv50.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/gpio/nvd0.c8
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/gpio/nve0.c131
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/gpio/priv.h17
8 files changed, 159 insertions, 16 deletions
diff --git a/drivers/gpu/drm/nouveau/Makefile b/drivers/gpu/drm/nouveau/Makefile
index ebe37fe5d0fc..e0bd21a99de8 100644
--- a/drivers/gpu/drm/nouveau/Makefile
+++ b/drivers/gpu/drm/nouveau/Makefile
@@ -91,6 +91,7 @@ nouveau-y += core/subdev/gpio/base.o
91nouveau-y += core/subdev/gpio/nv10.o 91nouveau-y += core/subdev/gpio/nv10.o
92nouveau-y += core/subdev/gpio/nv50.o 92nouveau-y += core/subdev/gpio/nv50.o
93nouveau-y += core/subdev/gpio/nvd0.o 93nouveau-y += core/subdev/gpio/nvd0.o
94nouveau-y += core/subdev/gpio/nve0.o
94nouveau-y += core/subdev/i2c/base.o 95nouveau-y += core/subdev/i2c/base.o
95nouveau-y += core/subdev/i2c/aux.o 96nouveau-y += core/subdev/i2c/aux.o
96nouveau-y += core/subdev/i2c/bit.o 97nouveau-y += core/subdev/i2c/bit.o
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/gpio.h b/drivers/gpu/drm/nouveau/core/include/subdev/gpio.h
index b0007b508567..c85b9f1579ad 100644
--- a/drivers/gpu/drm/nouveau/core/include/subdev/gpio.h
+++ b/drivers/gpu/drm/nouveau/core/include/subdev/gpio.h
@@ -48,12 +48,6 @@ int nouveau_gpio_init(struct nouveau_gpio *);
48extern struct nouveau_oclass nv10_gpio_oclass; 48extern struct nouveau_oclass nv10_gpio_oclass;
49extern struct nouveau_oclass nv50_gpio_oclass; 49extern struct nouveau_oclass nv50_gpio_oclass;
50extern struct nouveau_oclass nvd0_gpio_oclass; 50extern struct nouveau_oclass nvd0_gpio_oclass;
51 51extern struct nouveau_oclass nve0_gpio_oclass;
52void nv50_gpio_dtor(struct nouveau_object *);
53int nv50_gpio_init(struct nouveau_object *);
54int nv50_gpio_fini(struct nouveau_object *, bool);
55void nv50_gpio_intr(struct nouveau_subdev *);
56void nv50_gpio_intr_enable(struct nouveau_event *, int line);
57void nv50_gpio_intr_disable(struct nouveau_event *, int line);
58 52
59#endif 53#endif
diff --git a/drivers/gpu/drm/nouveau/core/subdev/device/nve0.c b/drivers/gpu/drm/nouveau/core/subdev/device/nve0.c
index 59d0d0f43a67..1e02bec8ba61 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/device/nve0.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/device/nve0.c
@@ -57,7 +57,7 @@ nve0_identify(struct nouveau_device *device)
57 case 0xe4: 57 case 0xe4:
58 device->cname = "GK104"; 58 device->cname = "GK104";
59 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; 59 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass;
60 device->oclass[NVDEV_SUBDEV_GPIO ] = &nvd0_gpio_oclass; 60 device->oclass[NVDEV_SUBDEV_GPIO ] = &nve0_gpio_oclass;
61 device->oclass[NVDEV_SUBDEV_I2C ] = &nouveau_i2c_oclass; 61 device->oclass[NVDEV_SUBDEV_I2C ] = &nouveau_i2c_oclass;
62 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nvc0_clock_oclass; 62 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nvc0_clock_oclass;
63 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass; 63 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass;
@@ -86,7 +86,7 @@ nve0_identify(struct nouveau_device *device)
86 case 0xe7: 86 case 0xe7:
87 device->cname = "GK107"; 87 device->cname = "GK107";
88 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; 88 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass;
89 device->oclass[NVDEV_SUBDEV_GPIO ] = &nvd0_gpio_oclass; 89 device->oclass[NVDEV_SUBDEV_GPIO ] = &nve0_gpio_oclass;
90 device->oclass[NVDEV_SUBDEV_I2C ] = &nouveau_i2c_oclass; 90 device->oclass[NVDEV_SUBDEV_I2C ] = &nouveau_i2c_oclass;
91 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nvc0_clock_oclass; 91 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nvc0_clock_oclass;
92 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass; 92 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass;
@@ -115,7 +115,7 @@ nve0_identify(struct nouveau_device *device)
115 case 0xe6: 115 case 0xe6:
116 device->cname = "GK106"; 116 device->cname = "GK106";
117 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; 117 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass;
118 device->oclass[NVDEV_SUBDEV_GPIO ] = &nvd0_gpio_oclass; 118 device->oclass[NVDEV_SUBDEV_GPIO ] = &nve0_gpio_oclass;
119 device->oclass[NVDEV_SUBDEV_I2C ] = &nouveau_i2c_oclass; 119 device->oclass[NVDEV_SUBDEV_I2C ] = &nouveau_i2c_oclass;
120 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nvc0_clock_oclass; 120 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nvc0_clock_oclass;
121 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass; 121 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/gpio/nv10.c b/drivers/gpu/drm/nouveau/core/subdev/gpio/nv10.c
index 9665f5f70ee3..76d5d5465ddd 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/gpio/nv10.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/gpio/nv10.c
@@ -24,7 +24,7 @@
24 * 24 *
25 */ 25 */
26 26
27#include <subdev/gpio.h> 27#include "priv.h"
28 28
29struct nv10_gpio_priv { 29struct nv10_gpio_priv {
30 struct nouveau_gpio base; 30 struct nouveau_gpio base;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/gpio/nv50.c b/drivers/gpu/drm/nouveau/core/subdev/gpio/nv50.c
index cbe609aa237c..bf489dcf46e2 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/gpio/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/gpio/nv50.c
@@ -22,7 +22,7 @@
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24 24
25#include <subdev/gpio.h> 25#include "priv.h"
26 26
27struct nv50_gpio_priv { 27struct nv50_gpio_priv {
28 struct nouveau_gpio base; 28 struct nouveau_gpio base;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/gpio/nvd0.c b/drivers/gpu/drm/nouveau/core/subdev/gpio/nvd0.c
index 5ef16a262de7..010431e3acec 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/gpio/nvd0.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/gpio/nvd0.c
@@ -22,13 +22,13 @@
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24 24
25#include <subdev/gpio.h> 25#include "priv.h"
26 26
27struct nvd0_gpio_priv { 27struct nvd0_gpio_priv {
28 struct nouveau_gpio base; 28 struct nouveau_gpio base;
29}; 29};
30 30
31static void 31void
32nvd0_gpio_reset(struct nouveau_gpio *gpio, u8 match) 32nvd0_gpio_reset(struct nouveau_gpio *gpio, u8 match)
33{ 33{
34 struct nouveau_bios *bios = nouveau_bios(gpio); 34 struct nouveau_bios *bios = nouveau_bios(gpio);
@@ -57,7 +57,7 @@ nvd0_gpio_reset(struct nouveau_gpio *gpio, u8 match)
57 } 57 }
58} 58}
59 59
60static int 60int
61nvd0_gpio_drive(struct nouveau_gpio *gpio, int line, int dir, int out) 61nvd0_gpio_drive(struct nouveau_gpio *gpio, int line, int dir, int out)
62{ 62{
63 u32 data = ((dir ^ 1) << 13) | (out << 12); 63 u32 data = ((dir ^ 1) << 13) | (out << 12);
@@ -66,7 +66,7 @@ nvd0_gpio_drive(struct nouveau_gpio *gpio, int line, int dir, int out)
66 return 0; 66 return 0;
67} 67}
68 68
69static int 69int
70nvd0_gpio_sense(struct nouveau_gpio *gpio, int line) 70nvd0_gpio_sense(struct nouveau_gpio *gpio, int line)
71{ 71{
72 return !!(nv_rd32(gpio, 0x00d610 + (line * 4)) & 0x00004000); 72 return !!(nv_rd32(gpio, 0x00d610 + (line * 4)) & 0x00004000);
diff --git a/drivers/gpu/drm/nouveau/core/subdev/gpio/nve0.c b/drivers/gpu/drm/nouveau/core/subdev/gpio/nve0.c
new file mode 100644
index 000000000000..16b8c5bf5efa
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/core/subdev/gpio/nve0.c
@@ -0,0 +1,131 @@
1/*
2 * Copyright 2012 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs
23 */
24
25#include "priv.h"
26
27struct nve0_gpio_priv {
28 struct nouveau_gpio base;
29};
30
31void
32nve0_gpio_intr(struct nouveau_subdev *subdev)
33{
34 struct nve0_gpio_priv *priv = (void *)subdev;
35 u32 intr0 = nv_rd32(priv, 0xdc00) & nv_rd32(priv, 0xdc08);
36 u32 intr1 = nv_rd32(priv, 0xdc80) & nv_rd32(priv, 0xdc88);
37 u32 hi = (intr0 & 0x0000ffff) | (intr1 << 16);
38 u32 lo = (intr0 >> 16) | (intr1 & 0xffff0000);
39 int i;
40
41 for (i = 0; (hi | lo) && i < 32; i++) {
42 if ((hi | lo) & (1 << i))
43 nouveau_event_trigger(priv->base.events, i);
44 }
45
46 nv_wr32(priv, 0xdc00, intr0);
47 nv_wr32(priv, 0xdc88, intr1);
48}
49
50void
51nve0_gpio_intr_enable(struct nouveau_event *event, int line)
52{
53 const u32 addr = line < 16 ? 0xdc00 : 0xdc80;
54 const u32 mask = 0x00010001 << (line & 0xf);
55 nv_wr32(event->priv, addr + 0x08, mask);
56 nv_mask(event->priv, addr + 0x00, mask, mask);
57}
58
59void
60nve0_gpio_intr_disable(struct nouveau_event *event, int line)
61{
62 const u32 addr = line < 16 ? 0xdc00 : 0xdc80;
63 const u32 mask = 0x00010001 << (line & 0xf);
64 nv_wr32(event->priv, addr + 0x08, mask);
65 nv_mask(event->priv, addr + 0x00, mask, 0x00000000);
66}
67
68int
69nve0_gpio_fini(struct nouveau_object *object, bool suspend)
70{
71 struct nve0_gpio_priv *priv = (void *)object;
72 nv_wr32(priv, 0xdc08, 0x00000000);
73 nv_wr32(priv, 0xdc88, 0x00000000);
74 return nouveau_gpio_fini(&priv->base, suspend);
75}
76
77int
78nve0_gpio_init(struct nouveau_object *object)
79{
80 struct nve0_gpio_priv *priv = (void *)object;
81 int ret;
82
83 ret = nouveau_gpio_init(&priv->base);
84 if (ret)
85 return ret;
86
87 nv_wr32(priv, 0xdc00, 0xffffffff);
88 nv_wr32(priv, 0xdc80, 0xffffffff);
89 return 0;
90}
91
92void
93nve0_gpio_dtor(struct nouveau_object *object)
94{
95 struct nve0_gpio_priv *priv = (void *)object;
96 nouveau_gpio_destroy(&priv->base);
97}
98
99static int
100nve0_gpio_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
101 struct nouveau_oclass *oclass, void *data, u32 size,
102 struct nouveau_object **pobject)
103{
104 struct nve0_gpio_priv *priv;
105 int ret;
106
107 ret = nouveau_gpio_create(parent, engine, oclass, 32, &priv);
108 *pobject = nv_object(priv);
109 if (ret)
110 return ret;
111
112 priv->base.reset = nvd0_gpio_reset;
113 priv->base.drive = nvd0_gpio_drive;
114 priv->base.sense = nvd0_gpio_sense;
115 priv->base.events->priv = priv;
116 priv->base.events->enable = nve0_gpio_intr_enable;
117 priv->base.events->disable = nve0_gpio_intr_disable;
118 nv_subdev(priv)->intr = nve0_gpio_intr;
119 return 0;
120}
121
122struct nouveau_oclass
123nve0_gpio_oclass = {
124 .handle = NV_SUBDEV(GPIO, 0xe0),
125 .ofuncs = &(struct nouveau_ofuncs) {
126 .ctor = nve0_gpio_ctor,
127 .dtor = nv50_gpio_dtor,
128 .init = nve0_gpio_init,
129 .fini = nve0_gpio_fini,
130 },
131};
diff --git a/drivers/gpu/drm/nouveau/core/subdev/gpio/priv.h b/drivers/gpu/drm/nouveau/core/subdev/gpio/priv.h
new file mode 100644
index 000000000000..2ee1c895c782
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/core/subdev/gpio/priv.h
@@ -0,0 +1,17 @@
1#ifndef __NVKM_GPIO_H__
2#define __NVKM_GPIO_H__
3
4#include <subdev/gpio.h>
5
6void nv50_gpio_dtor(struct nouveau_object *);
7int nv50_gpio_init(struct nouveau_object *);
8int nv50_gpio_fini(struct nouveau_object *, bool);
9void nv50_gpio_intr(struct nouveau_subdev *);
10void nv50_gpio_intr_enable(struct nouveau_event *, int line);
11void nv50_gpio_intr_disable(struct nouveau_event *, int line);
12
13void nvd0_gpio_reset(struct nouveau_gpio *, u8);
14int nvd0_gpio_drive(struct nouveau_gpio *, int, int, int);
15int nvd0_gpio_sense(struct nouveau_gpio *, int);
16
17#endif