1*1bab09acSLyude Paul /*
2*1bab09acSLyude Paul * Copyright 2018 Red Hat Inc.
3*1bab09acSLyude Paul *
4*1bab09acSLyude Paul * Permission is hereby granted, free of charge, to any person obtaining a
5*1bab09acSLyude Paul * copy of this software and associated documentation files (the "Software"),
6*1bab09acSLyude Paul * to deal in the Software without restriction, including without limitation
7*1bab09acSLyude Paul * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*1bab09acSLyude Paul * and/or sell copies of the Software, and to permit persons to whom the
9*1bab09acSLyude Paul * Software is furnished to do so, subject to the following conditions:
10*1bab09acSLyude Paul *
11*1bab09acSLyude Paul * The above copyright notice and this permission notice shall be included in
12*1bab09acSLyude Paul * all copies or substantial portions of the Software.
13*1bab09acSLyude Paul *
14*1bab09acSLyude Paul * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*1bab09acSLyude Paul * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*1bab09acSLyude Paul * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17*1bab09acSLyude Paul * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*1bab09acSLyude Paul * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*1bab09acSLyude Paul * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*1bab09acSLyude Paul * OTHER DEALINGS IN THE SOFTWARE.
21*1bab09acSLyude Paul *
22*1bab09acSLyude Paul * Authors: Lyude Paul
23*1bab09acSLyude Paul */
24*1bab09acSLyude Paul #include <core/device.h>
25*1bab09acSLyude Paul
26*1bab09acSLyude Paul #include "priv.h"
27*1bab09acSLyude Paul
28*1bab09acSLyude Paul #define pack_for_each_init(init, pack, head) \
29*1bab09acSLyude Paul for (pack = head; pack && pack->init; pack++) \
30*1bab09acSLyude Paul for (init = pack->init; init && init->count; init++)
31*1bab09acSLyude Paul void
gf100_clkgate_init(struct nvkm_therm * therm,const struct nvkm_therm_clkgate_pack * p)32*1bab09acSLyude Paul gf100_clkgate_init(struct nvkm_therm *therm,
33*1bab09acSLyude Paul const struct nvkm_therm_clkgate_pack *p)
34*1bab09acSLyude Paul {
35*1bab09acSLyude Paul struct nvkm_device *device = therm->subdev.device;
36*1bab09acSLyude Paul const struct nvkm_therm_clkgate_pack *pack;
37*1bab09acSLyude Paul const struct nvkm_therm_clkgate_init *init;
38*1bab09acSLyude Paul u32 next, addr;
39*1bab09acSLyude Paul
40*1bab09acSLyude Paul pack_for_each_init(init, pack, p) {
41*1bab09acSLyude Paul next = init->addr + init->count * 8;
42*1bab09acSLyude Paul addr = init->addr;
43*1bab09acSLyude Paul
44*1bab09acSLyude Paul nvkm_trace(&therm->subdev, "{ 0x%06x, %d, 0x%08x }\n",
45*1bab09acSLyude Paul init->addr, init->count, init->data);
46*1bab09acSLyude Paul while (addr < next) {
47*1bab09acSLyude Paul nvkm_trace(&therm->subdev, "\t0x%06x = 0x%08x\n",
48*1bab09acSLyude Paul addr, init->data);
49*1bab09acSLyude Paul nvkm_wr32(device, addr, init->data);
50*1bab09acSLyude Paul addr += 8;
51*1bab09acSLyude Paul }
52*1bab09acSLyude Paul }
53*1bab09acSLyude Paul }
54*1bab09acSLyude Paul
55*1bab09acSLyude Paul /*
56*1bab09acSLyude Paul * TODO: Fermi clockgating isn't understood fully yet, so we don't specify any
57*1bab09acSLyude Paul * clockgate functions to use
58*1bab09acSLyude Paul */
59