2 * Copyright 2012 Red Hat Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
24 #define gp100_mc(p) container_of((p), struct gp100_mc, base)
35 gp100_mc_intr_update(struct gp100_mc *mc)
37 struct nvkm_device *device = mc->base.subdev.device;
38 u32 mask = mc->intr ? mc->mask : 0, i;
39 for (i = 0; i < 2; i++) {
40 nvkm_wr32(device, 0x000180 + (i * 0x04), ~mask);
41 nvkm_wr32(device, 0x000160 + (i * 0x04), mask);
46 gp100_mc_intr_unarm(struct nvkm_mc *base)
48 struct gp100_mc *mc = gp100_mc(base);
50 spin_lock_irqsave(&mc->lock, flags);
52 gp100_mc_intr_update(mc);
53 spin_unlock_irqrestore(&mc->lock, flags);
57 gp100_mc_intr_rearm(struct nvkm_mc *base)
59 struct gp100_mc *mc = gp100_mc(base);
61 spin_lock_irqsave(&mc->lock, flags);
63 gp100_mc_intr_update(mc);
64 spin_unlock_irqrestore(&mc->lock, flags);
68 gp100_mc_intr_mask(struct nvkm_mc *base, u32 mask, u32 intr)
70 struct gp100_mc *mc = gp100_mc(base);
72 spin_lock_irqsave(&mc->lock, flags);
73 mc->mask = (mc->mask & ~mask) | intr;
74 gp100_mc_intr_update(mc);
75 spin_unlock_irqrestore(&mc->lock, flags);
78 static const struct nvkm_mc_func
81 .intr = gk104_mc_intr,
82 .intr_unarm = gp100_mc_intr_unarm,
83 .intr_rearm = gp100_mc_intr_rearm,
84 .intr_mask = gp100_mc_intr_mask,
85 .intr_stat = gf100_mc_intr_stat,
86 .reset = gk104_mc_reset,
90 gp100_mc_new(struct nvkm_device *device, int index, struct nvkm_mc **pmc)
94 if (!(mc = kzalloc(sizeof(*mc), GFP_KERNEL)))
96 nvkm_mc_ctor(&gp100_mc, device, index, &mc->base);
99 spin_lock_init(&mc->lock);
101 mc->mask = 0x7fffffff;