xref: /openbmc/linux/drivers/gpu/drm/nouveau/nvkm/subdev/acr/ga100.c (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
1*4b569dedSBen Skeggs /*
2*4b569dedSBen Skeggs  * Copyright 2021 Red Hat Inc.
3*4b569dedSBen Skeggs  *
4*4b569dedSBen Skeggs  * Permission is hereby granted, free of charge, to any person obtaining a
5*4b569dedSBen Skeggs  * copy of this software and associated documentation files (the "Software"),
6*4b569dedSBen Skeggs  * to deal in the Software without restriction, including without limitation
7*4b569dedSBen Skeggs  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*4b569dedSBen Skeggs  * and/or sell copies of the Software, and to permit persons to whom the
9*4b569dedSBen Skeggs  * Software is furnished to do so, subject to the following conditions:
10*4b569dedSBen Skeggs  *
11*4b569dedSBen Skeggs  * The above copyright notice and this permission notice shall be included in
12*4b569dedSBen Skeggs  * all copies or substantial portions of the Software.
13*4b569dedSBen Skeggs  *
14*4b569dedSBen Skeggs  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*4b569dedSBen Skeggs  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*4b569dedSBen Skeggs  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17*4b569dedSBen Skeggs  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*4b569dedSBen Skeggs  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*4b569dedSBen Skeggs  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*4b569dedSBen Skeggs  * OTHER DEALINGS IN THE SOFTWARE.
21*4b569dedSBen Skeggs  */
22*4b569dedSBen Skeggs #include "priv.h"
23*4b569dedSBen Skeggs 
24*4b569dedSBen Skeggs void
ga100_acr_wpr_check(struct nvkm_acr * acr,u64 * start,u64 * limit)25*4b569dedSBen Skeggs ga100_acr_wpr_check(struct nvkm_acr *acr, u64 *start, u64 *limit)
26*4b569dedSBen Skeggs {
27*4b569dedSBen Skeggs 	struct nvkm_device *device = acr->subdev.device;
28*4b569dedSBen Skeggs 
29*4b569dedSBen Skeggs 	*start = (u64)(nvkm_rd32(device, 0x1fa81c) & 0xffffff00) << 8;
30*4b569dedSBen Skeggs 	*limit = (u64)(nvkm_rd32(device, 0x1fa820) & 0xffffff00) << 8;
31*4b569dedSBen Skeggs 	*limit = *limit + 0x20000;
32*4b569dedSBen Skeggs }
33*4b569dedSBen Skeggs 
34*4b569dedSBen Skeggs int
ga100_acr_hsfw_ctor(struct nvkm_acr * acr,const char * bl,const char * fw,const char * name,int ver,const struct nvkm_acr_hsf_fwif * fwif)35*4b569dedSBen Skeggs ga100_acr_hsfw_ctor(struct nvkm_acr *acr, const char *bl, const char *fw,
36*4b569dedSBen Skeggs 		    const char *name, int ver, const struct nvkm_acr_hsf_fwif *fwif)
37*4b569dedSBen Skeggs {
38*4b569dedSBen Skeggs 	struct nvkm_acr_hsfw *hsfw;
39*4b569dedSBen Skeggs 
40*4b569dedSBen Skeggs 	if (!(hsfw = kzalloc(sizeof(*hsfw), GFP_KERNEL)))
41*4b569dedSBen Skeggs 		return -ENOMEM;
42*4b569dedSBen Skeggs 
43*4b569dedSBen Skeggs 	hsfw->falcon_id = fwif->falcon_id;
44*4b569dedSBen Skeggs 	hsfw->boot_mbox0 = fwif->boot_mbox0;
45*4b569dedSBen Skeggs 	hsfw->intr_clear = fwif->intr_clear;
46*4b569dedSBen Skeggs 	list_add_tail(&hsfw->head, &acr->hsfw);
47*4b569dedSBen Skeggs 
48*4b569dedSBen Skeggs 	return nvkm_falcon_fw_ctor_hs_v2(fwif->func, name, &acr->subdev, fw, ver, NULL, &hsfw->fw);
49*4b569dedSBen Skeggs }
50