Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvc0.c
Go to the documentation of this file.
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 <subdev/ibus.h>
26 
29 };
30 
31 static void
32 nvc0_ibus_intr_hub(struct nvc0_ibus_priv *priv, int i)
33 {
34  u32 addr = nv_rd32(priv, 0x122120 + (i * 0x0400));
35  u32 data = nv_rd32(priv, 0x122124 + (i * 0x0400));
36  u32 stat = nv_rd32(priv, 0x122128 + (i * 0x0400));
37  nv_error(priv, "HUB%d: 0x%06x 0x%08x (0x%08x)\n", i, addr, data, stat);
38  nv_mask(priv, 0x122128 + (i * 0x0400), 0x00000200, 0x00000000);
39 }
40 
41 static void
42 nvc0_ibus_intr_rop(struct nvc0_ibus_priv *priv, int i)
43 {
44  u32 addr = nv_rd32(priv, 0x124120 + (i * 0x0400));
45  u32 data = nv_rd32(priv, 0x124124 + (i * 0x0400));
46  u32 stat = nv_rd32(priv, 0x124128 + (i * 0x0400));
47  nv_error(priv, "ROP%d: 0x%06x 0x%08x (0x%08x)\n", i, addr, data, stat);
48  nv_mask(priv, 0x124128 + (i * 0x0400), 0x00000200, 0x00000000);
49 }
50 
51 static void
52 nvc0_ibus_intr_gpc(struct nvc0_ibus_priv *priv, int i)
53 {
54  u32 addr = nv_rd32(priv, 0x128120 + (i * 0x0400));
55  u32 data = nv_rd32(priv, 0x128124 + (i * 0x0400));
56  u32 stat = nv_rd32(priv, 0x128128 + (i * 0x0400));
57  nv_error(priv, "GPC%d: 0x%06x 0x%08x (0x%08x)\n", i, addr, data, stat);
58  nv_mask(priv, 0x128128 + (i * 0x0400), 0x00000200, 0x00000000);
59 }
60 
61 static void
62 nvc0_ibus_intr(struct nouveau_subdev *subdev)
63 {
64  struct nvc0_ibus_priv *priv = (void *)subdev;
65  u32 intr0 = nv_rd32(priv, 0x121c58);
66  u32 intr1 = nv_rd32(priv, 0x121c5c);
67  u32 hubnr = nv_rd32(priv, 0x121c70);
68  u32 ropnr = nv_rd32(priv, 0x121c74);
69  u32 gpcnr = nv_rd32(priv, 0x121c78);
70  u32 i;
71 
72  for (i = 0; (intr0 & 0x0000ff00) && i < hubnr; i++) {
73  u32 stat = 0x00000100 << i;
74  if (intr0 & stat) {
75  nvc0_ibus_intr_hub(priv, i);
76  intr0 &= ~stat;
77  }
78  }
79 
80  for (i = 0; (intr0 & 0xffff0000) && i < ropnr; i++) {
81  u32 stat = 0x00010000 << i;
82  if (intr0 & stat) {
83  nvc0_ibus_intr_rop(priv, i);
84  intr0 &= ~stat;
85  }
86  }
87 
88  for (i = 0; intr1 && i < gpcnr; i++) {
89  u32 stat = 0x00000001 << i;
90  if (intr1 & stat) {
91  nvc0_ibus_intr_gpc(priv, i);
92  intr1 &= ~stat;
93  }
94  }
95 }
96 
97 static int
98 nvc0_ibus_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
99  struct nouveau_oclass *oclass, void *data, u32 size,
100  struct nouveau_object **pobject)
101 {
102  struct nvc0_ibus_priv *priv;
103  int ret;
104 
105  ret = nouveau_ibus_create(parent, engine, oclass, &priv);
106  *pobject = nv_object(priv);
107  if (ret)
108  return ret;
109 
110  nv_subdev(priv)->intr = nvc0_ibus_intr;
111  return 0;
112 }
113 
114 struct nouveau_oclass
116  .handle = NV_SUBDEV(IBUS, 0xc0),
117  .ofuncs = &(struct nouveau_ofuncs) {
118  .ctor = nvc0_ibus_ctor,
119  .dtor = _nouveau_ibus_dtor,
120  .init = _nouveau_ibus_init,
121  .fini = _nouveau_ibus_fini,
122  },
123 };