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.
26 #include <core/option.h>
29 nvkm_mc_unk260(struct nvkm_mc *mc, u32 data)
32 mc->func->unk260(mc, data);
36 nvkm_mc_intr_unarm(struct nvkm_mc *mc)
38 return mc->func->intr_unarm(mc);
42 nvkm_mc_intr_rearm(struct nvkm_mc *mc)
44 return mc->func->intr_rearm(mc);
48 nvkm_mc_intr_mask(struct nvkm_mc *mc)
50 u32 intr = mc->func->intr_mask(mc);
51 if (WARN_ON_ONCE(intr == 0xffffffff))
52 intr = 0; /* likely fallen off the bus */
57 nvkm_mc_intr(struct nvkm_mc *mc, bool *handled)
59 struct nvkm_device *device = mc->subdev.device;
60 struct nvkm_subdev *subdev;
61 const struct nvkm_mc_intr *map = mc->func->intr;
64 stat = intr = nvkm_mc_intr_mask(mc);
66 if (intr & map->stat) {
67 subdev = nvkm_device_subdev(device, map->unit);
69 nvkm_subdev_intr(subdev);
76 nvkm_error(&mc->subdev, "intr %08x\n", stat);
81 nvkm_mc_fini(struct nvkm_subdev *subdev, bool suspend)
83 struct nvkm_mc *mc = nvkm_mc(subdev);
84 nvkm_mc_intr_unarm(mc);
89 nvkm_mc_init(struct nvkm_subdev *subdev)
91 struct nvkm_mc *mc = nvkm_mc(subdev);
94 nvkm_mc_intr_rearm(mc);
99 nvkm_mc_dtor(struct nvkm_subdev *subdev)
101 return nvkm_mc(subdev);
104 static const struct nvkm_subdev_func
106 .dtor = nvkm_mc_dtor,
107 .init = nvkm_mc_init,
108 .fini = nvkm_mc_fini,
112 nvkm_mc_new_(const struct nvkm_mc_func *func, struct nvkm_device *device,
113 int index, struct nvkm_mc **pmc)
117 if (!(mc = *pmc = kzalloc(sizeof(*mc), GFP_KERNEL)))
120 nvkm_subdev_ctor(&nvkm_mc, device, index, 0, &mc->subdev);