xref: /linux/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/ga102.c (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
121e938d0SBen Skeggs /*
221e938d0SBen Skeggs  * Copyright 2021 Red Hat Inc.
321e938d0SBen Skeggs  *
421e938d0SBen Skeggs  * Permission is hereby granted, free of charge, to any person obtaining a
521e938d0SBen Skeggs  * copy of this software and associated documentation files (the "Software"),
621e938d0SBen Skeggs  * to deal in the Software without restriction, including without limitation
721e938d0SBen Skeggs  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
821e938d0SBen Skeggs  * and/or sell copies of the Software, and to permit persons to whom the
921e938d0SBen Skeggs  * Software is furnished to do so, subject to the following conditions:
1021e938d0SBen Skeggs  *
1121e938d0SBen Skeggs  * The above copyright notice and this permission notice shall be included in
1221e938d0SBen Skeggs  * all copies or substantial portions of the Software.
1321e938d0SBen Skeggs  *
1421e938d0SBen Skeggs  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1521e938d0SBen Skeggs  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1621e938d0SBen Skeggs  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1721e938d0SBen Skeggs  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1821e938d0SBen Skeggs  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1921e938d0SBen Skeggs  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2021e938d0SBen Skeggs  * OTHER DEALINGS IN THE SOFTWARE.
2121e938d0SBen Skeggs  */
2221e938d0SBen Skeggs #include "priv.h"
2321e938d0SBen Skeggs 
24*1dc750daSBen Skeggs #include <subdev/gsp.h>
25*1dc750daSBen Skeggs 
2621e938d0SBen Skeggs static void
ga102_ltc_zbc_clear_color(struct nvkm_ltc * ltc,int i,const u32 color[4])2721e938d0SBen Skeggs ga102_ltc_zbc_clear_color(struct nvkm_ltc *ltc, int i, const u32 color[4])
2821e938d0SBen Skeggs {
2921e938d0SBen Skeggs 	struct nvkm_device *device = ltc->subdev.device;
3021e938d0SBen Skeggs 
3121e938d0SBen Skeggs 	nvkm_mask(device, 0x17e338, 0x0000001f, i);
3221e938d0SBen Skeggs 	nvkm_wr32(device, 0x17e33c, color[0]);
3321e938d0SBen Skeggs 	nvkm_wr32(device, 0x17e340, color[1]);
3421e938d0SBen Skeggs 	nvkm_wr32(device, 0x17e344, color[2]);
3521e938d0SBen Skeggs 	nvkm_wr32(device, 0x17e348, color[3]);
3621e938d0SBen Skeggs }
3721e938d0SBen Skeggs 
3821e938d0SBen Skeggs static const struct nvkm_ltc_func
3921e938d0SBen Skeggs ga102_ltc = {
4021e938d0SBen Skeggs 	.oneinit = gp100_ltc_oneinit,
4121e938d0SBen Skeggs 	.init = gp100_ltc_init,
4221e938d0SBen Skeggs 	.intr = gp100_ltc_intr,
4321e938d0SBen Skeggs 	.cbc_clear = gm107_ltc_cbc_clear,
4421e938d0SBen Skeggs 	.cbc_wait = gm107_ltc_cbc_wait,
4521e938d0SBen Skeggs 	.zbc_color = 31,
4621e938d0SBen Skeggs 	.zbc_depth = 16,
4721e938d0SBen Skeggs 	.zbc_clear_color = ga102_ltc_zbc_clear_color,
4821e938d0SBen Skeggs 	.zbc_clear_depth = gm107_ltc_zbc_clear_depth,
4921e938d0SBen Skeggs 	.zbc_clear_stencil = gp102_ltc_zbc_clear_stencil,
5021e938d0SBen Skeggs 	.invalidate = gf100_ltc_invalidate,
5121e938d0SBen Skeggs 	.flush = gf100_ltc_flush,
5221e938d0SBen Skeggs };
5321e938d0SBen Skeggs 
5421e938d0SBen Skeggs int
ga102_ltc_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_ltc ** pltc)5521e938d0SBen Skeggs ga102_ltc_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
5621e938d0SBen Skeggs 	      struct nvkm_ltc **pltc)
5721e938d0SBen Skeggs {
58*1dc750daSBen Skeggs 	if (nvkm_gsp_rm(device->gsp))
59*1dc750daSBen Skeggs 		return -ENODEV;
60*1dc750daSBen Skeggs 
6121e938d0SBen Skeggs 	return nvkm_ltc_new_(&ga102_ltc, device, type, inst, pltc);
6221e938d0SBen Skeggs }
63