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