1be61c54cSBen Skeggs /*
2be61c54cSBen Skeggs * Copyright 2012 Red Hat Inc.
3be61c54cSBen Skeggs *
4be61c54cSBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a
5be61c54cSBen Skeggs * copy of this software and associated documentation files (the "Software"),
6be61c54cSBen Skeggs * to deal in the Software without restriction, including without limitation
7be61c54cSBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8be61c54cSBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the
9be61c54cSBen Skeggs * Software is furnished to do so, subject to the following conditions:
10be61c54cSBen Skeggs *
11be61c54cSBen Skeggs * The above copyright notice and this permission notice shall be included in
12be61c54cSBen Skeggs * all copies or substantial portions of the Software.
13be61c54cSBen Skeggs *
14be61c54cSBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15be61c54cSBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16be61c54cSBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17be61c54cSBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18be61c54cSBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19be61c54cSBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20be61c54cSBen Skeggs * OTHER DEALINGS IN THE SOFTWARE.
21be61c54cSBen Skeggs *
22be61c54cSBen Skeggs * Authors: Ben Skeggs
23be61c54cSBen Skeggs */
24be61c54cSBen Skeggs #include "priv.h"
25be61c54cSBen Skeggs
26fe76fe49SBen Skeggs const struct nvkm_intr_data
27fe76fe49SBen Skeggs gp100_mc_intrs[] = {
28fe76fe49SBen Skeggs { NVKM_ENGINE_DISP , 0, 0, 0x04000000, true },
292fc71a05SBen Skeggs { NVKM_ENGINE_FIFO , 0, 0, 0x00000100 },
30fe76fe49SBen Skeggs { NVKM_SUBDEV_FAULT , 0, 0, 0x00000200, true },
31fe76fe49SBen Skeggs { NVKM_SUBDEV_PRIVRING, 0, 0, 0x40000000, true },
32fe76fe49SBen Skeggs { NVKM_SUBDEV_BUS , 0, 0, 0x10000000, true },
33fe76fe49SBen Skeggs { NVKM_SUBDEV_FB , 0, 0, 0x08002000, true },
34fe76fe49SBen Skeggs { NVKM_SUBDEV_LTC , 0, 0, 0x02000000, true },
35fe76fe49SBen Skeggs { NVKM_SUBDEV_PMU , 0, 0, 0x01000000, true },
36fe76fe49SBen Skeggs { NVKM_SUBDEV_GPIO , 0, 0, 0x00200000, true },
37fe76fe49SBen Skeggs { NVKM_SUBDEV_I2C , 0, 0, 0x00200000, true },
38fe76fe49SBen Skeggs { NVKM_SUBDEV_TIMER , 0, 0, 0x00100000, true },
39fe76fe49SBen Skeggs { NVKM_SUBDEV_THERM , 0, 0, 0x00040000, true },
40*9aa3faceSBen Skeggs { NVKM_SUBDEV_TOP , 0, 0, 0x00009000 },
41*9aa3faceSBen Skeggs { NVKM_SUBDEV_TOP , 0, 0, 0xffff6fff, true },
42fe76fe49SBen Skeggs {},
43be61c54cSBen Skeggs };
44be61c54cSBen Skeggs
45be61c54cSBen Skeggs static void
gp100_mc_intr_allow(struct nvkm_intr * intr,int leaf,u32 mask)46fe76fe49SBen Skeggs gp100_mc_intr_allow(struct nvkm_intr *intr, int leaf, u32 mask)
47be61c54cSBen Skeggs {
48fe76fe49SBen Skeggs struct nvkm_mc *mc = container_of(intr, typeof(*mc), intr);
49fe76fe49SBen Skeggs
50fe76fe49SBen Skeggs nvkm_wr32(mc->subdev.device, 0x000160 + (leaf * 4), mask);
51be61c54cSBen Skeggs }
52be61c54cSBen Skeggs
53fe76fe49SBen Skeggs static void
gp100_mc_intr_block(struct nvkm_intr * intr,int leaf,u32 mask)54fe76fe49SBen Skeggs gp100_mc_intr_block(struct nvkm_intr *intr, int leaf, u32 mask)
55be61c54cSBen Skeggs {
56fe76fe49SBen Skeggs struct nvkm_mc *mc = container_of(intr, typeof(*mc), intr);
57fe76fe49SBen Skeggs
58fe76fe49SBen Skeggs nvkm_wr32(mc->subdev.device, 0x000180 + (leaf * 4), mask);
59be61c54cSBen Skeggs }
60be61c54cSBen Skeggs
61fe76fe49SBen Skeggs static void
gp100_mc_intr_rearm(struct nvkm_intr * intr)62fe76fe49SBen Skeggs gp100_mc_intr_rearm(struct nvkm_intr *intr)
63be61c54cSBen Skeggs {
64fe76fe49SBen Skeggs int i;
65fe76fe49SBen Skeggs
66fe76fe49SBen Skeggs for (i = 0; i < intr->leaves; i++)
67fe76fe49SBen Skeggs intr->func->allow(intr, i, intr->mask[i]);
68be61c54cSBen Skeggs }
69be61c54cSBen Skeggs
70fe76fe49SBen Skeggs static void
gp100_mc_intr_unarm(struct nvkm_intr * intr)71fe76fe49SBen Skeggs gp100_mc_intr_unarm(struct nvkm_intr *intr)
72be61c54cSBen Skeggs {
73fe76fe49SBen Skeggs int i;
74fe76fe49SBen Skeggs
75fe76fe49SBen Skeggs for (i = 0; i < intr->leaves; i++)
76fe76fe49SBen Skeggs intr->func->block(intr, i, 0xffffffff);
77be61c54cSBen Skeggs }
78be61c54cSBen Skeggs
79fe76fe49SBen Skeggs const struct nvkm_intr_func
80fe76fe49SBen Skeggs gp100_mc_intr = {
81fe76fe49SBen Skeggs .pending = nv04_mc_intr_pending,
82fe76fe49SBen Skeggs .unarm = gp100_mc_intr_unarm,
83fe76fe49SBen Skeggs .rearm = gp100_mc_intr_rearm,
84fe76fe49SBen Skeggs .block = gp100_mc_intr_block,
85fe76fe49SBen Skeggs .allow = gp100_mc_intr_allow,
862f68234fSBen Skeggs };
872f68234fSBen Skeggs
88be61c54cSBen Skeggs static const struct nvkm_mc_func
89be61c54cSBen Skeggs gp100_mc = {
90be61c54cSBen Skeggs .init = nv50_mc_init,
91fe76fe49SBen Skeggs .intr = &gp100_mc_intr,
92fe76fe49SBen Skeggs .intrs = gp100_mc_intrs,
93fe76fe49SBen Skeggs .intr_nonstall = true,
94ebb195dbSBen Skeggs .device = &nv04_mc_device,
95be61c54cSBen Skeggs .reset = gk104_mc_reset,
96be61c54cSBen Skeggs };
97be61c54cSBen Skeggs
98be61c54cSBen Skeggs int
gp100_mc_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_mc ** pmc)991fc2fddfSBen Skeggs gp100_mc_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_mc **pmc)
100b9a995deSAlexandre Courbot {
101fe76fe49SBen Skeggs return nvkm_mc_new_(&gp100_mc, device, type, inst, pmc);
102b9a995deSAlexandre Courbot }
103