xref: /linux/drivers/gpu/drm/nouveau/nvkm/engine/fifo/nv10.c (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
1c39f472eSBen Skeggs /*
2c39f472eSBen Skeggs  * Copyright 2012 Red Hat Inc.
3c39f472eSBen Skeggs  *
4c39f472eSBen Skeggs  * Permission is hereby granted, free of charge, to any person obtaining a
5c39f472eSBen Skeggs  * copy of this software and associated documentation files (the "Software"),
6c39f472eSBen Skeggs  * to deal in the Software without restriction, including without limitation
7c39f472eSBen Skeggs  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8c39f472eSBen Skeggs  * and/or sell copies of the Software, and to permit persons to whom the
9c39f472eSBen Skeggs  * Software is furnished to do so, subject to the following conditions:
10c39f472eSBen Skeggs  *
11c39f472eSBen Skeggs  * The above copyright notice and this permission notice shall be included in
12c39f472eSBen Skeggs  * all copies or substantial portions of the Software.
13c39f472eSBen Skeggs  *
14c39f472eSBen Skeggs  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15c39f472eSBen Skeggs  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16c39f472eSBen Skeggs  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17c39f472eSBen Skeggs  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18c39f472eSBen Skeggs  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19c39f472eSBen Skeggs  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20c39f472eSBen Skeggs  * OTHER DEALINGS IN THE SOFTWARE.
21c39f472eSBen Skeggs  *
22c39f472eSBen Skeggs  * Authors: Ben Skeggs
23c39f472eSBen Skeggs  */
24*06db7fdeSBen Skeggs #include "priv.h"
253647c53bSBen Skeggs #include "cgrp.h"
26f5e45689SBen Skeggs #include "chan.h"
273647c53bSBen Skeggs #include "runl.h"
283647c53bSBen Skeggs 
293647c53bSBen Skeggs #include <core/gpuobj.h>
303647c53bSBen Skeggs #include <subdev/instmem.h>
31f5e45689SBen Skeggs 
329a65a38cSBen Skeggs #include "regsnv04.h"
33c39f472eSBen Skeggs 
34f5e45689SBen Skeggs #include <nvif/class.h>
35f5e45689SBen Skeggs 
363647c53bSBen Skeggs static int
nv10_chan_ramfc_write(struct nvkm_chan * chan,u64 offset,u64 length,u32 devm,bool priv)373647c53bSBen Skeggs nv10_chan_ramfc_write(struct nvkm_chan *chan, u64 offset, u64 length, u32 devm, bool priv)
383647c53bSBen Skeggs {
393647c53bSBen Skeggs 	struct nvkm_memory *ramfc = chan->cgrp->runl->fifo->engine.subdev.device->imem->ramfc;
403647c53bSBen Skeggs 	const u32 base = chan->id * 32;
413647c53bSBen Skeggs 
423647c53bSBen Skeggs 	chan->ramfc_offset = base;
433647c53bSBen Skeggs 
443647c53bSBen Skeggs 	nvkm_kmap(ramfc);
453647c53bSBen Skeggs 	nvkm_wo32(ramfc, base + 0x00, offset);
463647c53bSBen Skeggs 	nvkm_wo32(ramfc, base + 0x04, offset);
473647c53bSBen Skeggs 	nvkm_wo32(ramfc, base + 0x0c, chan->push->addr >> 4);
483647c53bSBen Skeggs 	nvkm_wo32(ramfc, base + 0x14, NV_PFIFO_CACHE1_DMA_FETCH_TRIG_128_BYTES |
493647c53bSBen Skeggs 				      NV_PFIFO_CACHE1_DMA_FETCH_SIZE_128_BYTES |
503647c53bSBen Skeggs #ifdef __BIG_ENDIAN
513647c53bSBen Skeggs 				      NV_PFIFO_CACHE1_BIG_ENDIAN |
523647c53bSBen Skeggs #endif
533647c53bSBen Skeggs 				      NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_8);
543647c53bSBen Skeggs 	nvkm_done(ramfc);
553647c53bSBen Skeggs 	return 0;
563647c53bSBen Skeggs }
573647c53bSBen Skeggs 
583647c53bSBen Skeggs static const struct nvkm_chan_func_ramfc
593647c53bSBen Skeggs nv10_chan_ramfc = {
603647c53bSBen Skeggs 	.layout = (const struct nvkm_ramfc_layout[]) {
61c39f472eSBen Skeggs 		{ 32,  0, 0x00,  0, NV04_PFIFO_CACHE1_DMA_PUT },
62c39f472eSBen Skeggs 		{ 32,  0, 0x04,  0, NV04_PFIFO_CACHE1_DMA_GET },
63c39f472eSBen Skeggs 		{ 32,  0, 0x08,  0, NV10_PFIFO_CACHE1_REF_CNT },
64c39f472eSBen Skeggs 		{ 16,  0, 0x0c,  0, NV04_PFIFO_CACHE1_DMA_INSTANCE },
65c39f472eSBen Skeggs 		{ 16, 16, 0x0c,  0, NV04_PFIFO_CACHE1_DMA_DCOUNT },
66c39f472eSBen Skeggs 		{ 32,  0, 0x10,  0, NV04_PFIFO_CACHE1_DMA_STATE },
67c39f472eSBen Skeggs 		{ 32,  0, 0x14,  0, NV04_PFIFO_CACHE1_DMA_FETCH },
68c39f472eSBen Skeggs 		{ 32,  0, 0x18,  0, NV04_PFIFO_CACHE1_ENGINE },
69c39f472eSBen Skeggs 		{ 32,  0, 0x1c,  0, NV04_PFIFO_CACHE1_PULL1 },
70c39f472eSBen Skeggs 		{}
713647c53bSBen Skeggs 	},
723647c53bSBen Skeggs 	.write = nv10_chan_ramfc_write,
733647c53bSBen Skeggs 	.clear = nv04_chan_ramfc_clear,
743647c53bSBen Skeggs 	.ctxdma = true,
75c39f472eSBen Skeggs };
76c39f472eSBen Skeggs 
77f5e45689SBen Skeggs static const struct nvkm_chan_func
78f5e45689SBen Skeggs nv10_chan = {
79d3e7a439SBen Skeggs 	.inst = &nv04_chan_inst,
80fbe9f433SBen Skeggs 	.userd = &nv04_chan_userd,
813647c53bSBen Skeggs 	.ramfc = &nv10_chan_ramfc,
8267059b9fSBen Skeggs 	.start = nv04_chan_start,
8367059b9fSBen Skeggs 	.stop = nv04_chan_stop,
84f5e45689SBen Skeggs };
85f5e45689SBen Skeggs 
868c18138cSBen Skeggs int
nv10_fifo_chid_nr(struct nvkm_fifo * fifo)878c18138cSBen Skeggs nv10_fifo_chid_nr(struct nvkm_fifo *fifo)
888c18138cSBen Skeggs {
898c18138cSBen Skeggs 	return 32;
908c18138cSBen Skeggs }
918c18138cSBen Skeggs 
928f0649b5SBen Skeggs static const struct nvkm_fifo_func
9313de7f46SBen Skeggs nv10_fifo = {
948c18138cSBen Skeggs 	.chid_nr = nv10_fifo_chid_nr,
95800ac1f8SBen Skeggs 	.chid_ctor = nv04_fifo_chid_ctor,
96d94470e9SBen Skeggs 	.runl_ctor = nv04_fifo_runl_ctor,
9713de7f46SBen Skeggs 	.init = nv04_fifo_init,
9813de7f46SBen Skeggs 	.intr = nv04_fifo_intr,
9913de7f46SBen Skeggs 	.pause = nv04_fifo_pause,
10013de7f46SBen Skeggs 	.start = nv04_fifo_start,
101d94470e9SBen Skeggs 	.runl = &nv04_runl,
102d94470e9SBen Skeggs 	.engn = &nv04_engn,
103d94470e9SBen Skeggs 	.engn_sw = &nv04_engn,
104f5e45689SBen Skeggs 	.cgrp = {{                        }, &nv04_cgrp },
105*06db7fdeSBen Skeggs 	.chan = {{ 0, 0, NV10_CHANNEL_DMA }, &nv10_chan },
106c39f472eSBen Skeggs };
107c39f472eSBen Skeggs 
10813de7f46SBen Skeggs int
nv10_fifo_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_fifo ** pfifo)109ab0db2bdSBen Skeggs nv10_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
110ab0db2bdSBen Skeggs 	      struct nvkm_fifo **pfifo)
111c39f472eSBen Skeggs {
112*06db7fdeSBen Skeggs 	return nvkm_fifo_new_(&nv10_fifo, device, type, inst, pfifo);
113c39f472eSBen Skeggs }
114