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/ltcg.h>
26 
30 };
31 
32 static void
33 nvc0_ltcg_subp_isr(struct nvc0_ltcg_priv *priv, int unit, int subp)
34 {
35  u32 subp_base = 0x141000 + (unit * 0x2000) + (subp * 0x400);
36  u32 stat = nv_rd32(priv, subp_base + 0x020);
37 
38  if (stat) {
39  nv_info(priv, "LTC%d_LTS%d: 0x%08x\n", unit, subp, stat);
40  nv_wr32(priv, subp_base + 0x020, stat);
41  }
42 }
43 
44 static void
45 nvc0_ltcg_intr(struct nouveau_subdev *subdev)
46 {
47  struct nvc0_ltcg_priv *priv = (void *)subdev;
48  u32 units;
49 
50  units = nv_rd32(priv, 0x00017c);
51  while (units) {
52  u32 subp, unit = ffs(units) - 1;
53  for (subp = 0; subp < priv->subp_nr; subp++)
54  nvc0_ltcg_subp_isr(priv, unit, subp);
55  units &= ~(1 << unit);
56  }
57 
58  /* we do something horribly wrong and upset PMFB a lot, so mask off
59  * interrupts from it after the first one until it's fixed
60  */
61  nv_mask(priv, 0x000640, 0x02000000, 0x00000000);
62 }
63 
64 static int
65 nvc0_ltcg_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
66  struct nouveau_oclass *oclass, void *data, u32 size,
67  struct nouveau_object **pobject)
68 {
69  struct nvc0_ltcg_priv *priv;
70  int ret;
71 
72  ret = nouveau_ltcg_create(parent, engine, oclass, &priv);
73  *pobject = nv_object(priv);
74  if (ret)
75  return ret;
76 
77  priv->subp_nr = nv_rd32(priv, 0x17e8dc) >> 24;
78  nv_mask(priv, 0x17e820, 0x00100000, 0x00000000); /* INTR_EN &= ~0x10 */
79 
80  nv_subdev(priv)->intr = nvc0_ltcg_intr;
81  return 0;
82 }
83 
84 struct nouveau_oclass
86  .handle = NV_SUBDEV(LTCG, 0xc0),
87  .ofuncs = &(struct nouveau_ofuncs) {
88  .ctor = nvc0_ltcg_ctor,
89  .dtor = _nouveau_ltcg_dtor,
90  .init = _nouveau_ltcg_init,
91  .fini = _nouveau_ltcg_fini,
92  },
93 };