Home | History | Annotate | Line # | Download | only in pmu
      1 /*	$NetBSD: nouveau_nvkm_subdev_pmu_gk110.c,v 1.3 2021/12/18 23:45:41 riastradh Exp $	*/
      2 
      3 /*
      4  * Copyright 2015 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: Ben Skeggs
     25  */
     26 #include <sys/cdefs.h>
     27 __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_pmu_gk110.c,v 1.3 2021/12/18 23:45:41 riastradh Exp $");
     28 
     29 #define gf119_pmu_code gk110_pmu_code
     30 #define gf119_pmu_data gk110_pmu_data
     31 #include "priv.h"
     32 #include "fuc/gf119.fuc4.h"
     33 
     34 #include <subdev/timer.h>
     35 
     36 void
     37 gk110_pmu_pgob(struct nvkm_pmu *pmu, bool enable)
     38 {
     39 	struct nvkm_device *device = pmu->subdev.device;
     40 	static const struct {
     41 		u32 addr;
     42 		u32 data;
     43 	} magic[] = {
     44 		{ 0x020520, 0xfffffffc },
     45 		{ 0x020524, 0xfffffffe },
     46 		{ 0x020524, 0xfffffffc },
     47 		{ 0x020524, 0xfffffff8 },
     48 		{ 0x020524, 0xffffffe0 },
     49 		{ 0x020530, 0xfffffffe },
     50 		{ 0x02052c, 0xfffffffa },
     51 		{ 0x02052c, 0xfffffff0 },
     52 		{ 0x02052c, 0xffffffc0 },
     53 		{ 0x02052c, 0xffffff00 },
     54 		{ 0x02052c, 0xfffffc00 },
     55 		{ 0x02052c, 0xfffcfc00 },
     56 		{ 0x02052c, 0xfff0fc00 },
     57 		{ 0x02052c, 0xff80fc00 },
     58 		{ 0x020528, 0xfffffffe },
     59 		{ 0x020528, 0xfffffffc },
     60 	};
     61 	int i;
     62 
     63 	nvkm_mask(device, 0x000200, 0x00001000, 0x00000000);
     64 	nvkm_rd32(device, 0x000200);
     65 	nvkm_mask(device, 0x000200, 0x08000000, 0x08000000);
     66 	msleep(50);
     67 
     68 	nvkm_mask(device, 0x10a78c, 0x00000002, 0x00000002);
     69 	nvkm_mask(device, 0x10a78c, 0x00000001, 0x00000001);
     70 	nvkm_mask(device, 0x10a78c, 0x00000001, 0x00000000);
     71 
     72 	nvkm_mask(device, 0x0206b4, 0x00000000, 0x00000000);
     73 	for (i = 0; i < ARRAY_SIZE(magic); i++) {
     74 		nvkm_wr32(device, magic[i].addr, magic[i].data);
     75 		nvkm_msec(device, 2000,
     76 			if (!(nvkm_rd32(device, magic[i].addr) & 0x80000000))
     77 				break;
     78 		);
     79 	}
     80 
     81 	nvkm_mask(device, 0x10a78c, 0x00000002, 0x00000000);
     82 	nvkm_mask(device, 0x10a78c, 0x00000001, 0x00000001);
     83 	nvkm_mask(device, 0x10a78c, 0x00000001, 0x00000000);
     84 
     85 	nvkm_mask(device, 0x000200, 0x08000000, 0x00000000);
     86 	nvkm_mask(device, 0x000200, 0x00001000, 0x00001000);
     87 	nvkm_rd32(device, 0x000200);
     88 }
     89 
     90 static const struct nvkm_pmu_func
     91 gk110_pmu = {
     92 	.flcn = &gt215_pmu_flcn,
     93 	.code.data = gk110_pmu_code,
     94 	.code.size = sizeof(gk110_pmu_code),
     95 	.data.data = gk110_pmu_data,
     96 	.data.size = sizeof(gk110_pmu_data),
     97 	.enabled = gf100_pmu_enabled,
     98 	.reset = gf100_pmu_reset,
     99 	.init = gt215_pmu_init,
    100 	.fini = gt215_pmu_fini,
    101 	.intr = gt215_pmu_intr,
    102 	.send = gt215_pmu_send,
    103 	.recv = gt215_pmu_recv,
    104 	.pgob = gk110_pmu_pgob,
    105 };
    106 
    107 static const struct nvkm_pmu_fwif
    108 gk110_pmu_fwif[] = {
    109 	{ -1, gf100_pmu_nofw, &gk110_pmu },
    110 	{}
    111 };
    112 
    113 int
    114 gk110_pmu_new(struct nvkm_device *device, int index, struct nvkm_pmu **ppmu)
    115 {
    116 	return nvkm_pmu_new_(gk110_pmu_fwif, device, index, ppmu);
    117 }
    118