1c85ee6caSBen Skeggs /*
2c85ee6caSBen Skeggs * Copyright 2012 Red Hat Inc.
3c85ee6caSBen Skeggs *
4c85ee6caSBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a
5c85ee6caSBen Skeggs * copy of this software and associated documentation files (the "Software"),
6c85ee6caSBen Skeggs * to deal in the Software without restriction, including without limitation
7c85ee6caSBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8c85ee6caSBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the
9c85ee6caSBen Skeggs * Software is furnished to do so, subject to the following conditions:
10c85ee6caSBen Skeggs *
11c85ee6caSBen Skeggs * The above copyright notice and this permission notice shall be included in
12c85ee6caSBen Skeggs * all copies or substantial portions of the Software.
13c85ee6caSBen Skeggs *
14c85ee6caSBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15c85ee6caSBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16c85ee6caSBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17c85ee6caSBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18c85ee6caSBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19c85ee6caSBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20c85ee6caSBen Skeggs * OTHER DEALINGS IN THE SOFTWARE.
21c85ee6caSBen Skeggs *
22c85ee6caSBen Skeggs * Authors: Ben Skeggs
23c85ee6caSBen Skeggs */
24c85ee6caSBen Skeggs #include "nv40.h"
25c85ee6caSBen Skeggs #include "regs.h"
26c85ee6caSBen Skeggs
27c85ee6caSBen Skeggs #include <subdev/fb.h>
28c85ee6caSBen Skeggs #include <engine/fifo.h>
29c85ee6caSBen Skeggs
30c85ee6caSBen Skeggs static void
nv44_gr_tile(struct nvkm_gr * base,int i,struct nvkm_fb_tile * tile)31c85ee6caSBen Skeggs nv44_gr_tile(struct nvkm_gr *base, int i, struct nvkm_fb_tile *tile)
32c85ee6caSBen Skeggs {
33c85ee6caSBen Skeggs struct nv40_gr *gr = nv40_gr(base);
34c85ee6caSBen Skeggs struct nvkm_device *device = gr->base.engine.subdev.device;
35c85ee6caSBen Skeggs struct nvkm_fifo *fifo = device->fifo;
36c85ee6caSBen Skeggs unsigned long flags;
37c85ee6caSBen Skeggs
38c85ee6caSBen Skeggs nvkm_fifo_pause(fifo, &flags);
39c85ee6caSBen Skeggs nv04_gr_idle(&gr->base);
40c85ee6caSBen Skeggs
41c85ee6caSBen Skeggs switch (device->chipset) {
42c85ee6caSBen Skeggs case 0x44:
43c85ee6caSBen Skeggs case 0x4a:
44c85ee6caSBen Skeggs nvkm_wr32(device, NV20_PGRAPH_TSIZE(i), tile->pitch);
45c85ee6caSBen Skeggs nvkm_wr32(device, NV20_PGRAPH_TLIMIT(i), tile->limit);
46c85ee6caSBen Skeggs nvkm_wr32(device, NV20_PGRAPH_TILE(i), tile->addr);
47c85ee6caSBen Skeggs break;
48c85ee6caSBen Skeggs case 0x46:
49c85ee6caSBen Skeggs case 0x4c:
50c85ee6caSBen Skeggs case 0x63:
51c85ee6caSBen Skeggs case 0x67:
52c85ee6caSBen Skeggs case 0x68:
53c85ee6caSBen Skeggs nvkm_wr32(device, NV47_PGRAPH_TSIZE(i), tile->pitch);
54c85ee6caSBen Skeggs nvkm_wr32(device, NV47_PGRAPH_TLIMIT(i), tile->limit);
55c85ee6caSBen Skeggs nvkm_wr32(device, NV47_PGRAPH_TILE(i), tile->addr);
56c85ee6caSBen Skeggs nvkm_wr32(device, NV40_PGRAPH_TSIZE1(i), tile->pitch);
57c85ee6caSBen Skeggs nvkm_wr32(device, NV40_PGRAPH_TLIMIT1(i), tile->limit);
58c85ee6caSBen Skeggs nvkm_wr32(device, NV40_PGRAPH_TILE1(i), tile->addr);
59c85ee6caSBen Skeggs break;
60c85ee6caSBen Skeggs case 0x4e:
61c85ee6caSBen Skeggs nvkm_wr32(device, NV20_PGRAPH_TSIZE(i), tile->pitch);
62c85ee6caSBen Skeggs nvkm_wr32(device, NV20_PGRAPH_TLIMIT(i), tile->limit);
63c85ee6caSBen Skeggs nvkm_wr32(device, NV20_PGRAPH_TILE(i), tile->addr);
64c85ee6caSBen Skeggs nvkm_wr32(device, NV40_PGRAPH_TSIZE1(i), tile->pitch);
65c85ee6caSBen Skeggs nvkm_wr32(device, NV40_PGRAPH_TLIMIT1(i), tile->limit);
66c85ee6caSBen Skeggs nvkm_wr32(device, NV40_PGRAPH_TILE1(i), tile->addr);
67c85ee6caSBen Skeggs break;
68c85ee6caSBen Skeggs default:
69c85ee6caSBen Skeggs WARN_ON(1);
70c85ee6caSBen Skeggs break;
71c85ee6caSBen Skeggs }
72c85ee6caSBen Skeggs
73c85ee6caSBen Skeggs nvkm_fifo_start(fifo, &flags);
74c85ee6caSBen Skeggs }
75c85ee6caSBen Skeggs
76c85ee6caSBen Skeggs static const struct nvkm_gr_func
77c85ee6caSBen Skeggs nv44_gr = {
78c85ee6caSBen Skeggs .init = nv40_gr_init,
79c85ee6caSBen Skeggs .intr = nv40_gr_intr,
80c85ee6caSBen Skeggs .tile = nv44_gr_tile,
81c85ee6caSBen Skeggs .units = nv40_gr_units,
82c85ee6caSBen Skeggs .chan_new = nv40_gr_chan_new,
83c85ee6caSBen Skeggs .sclass = {
84c85ee6caSBen Skeggs { -1, -1, 0x0012, &nv40_gr_object }, /* beta1 */
85c85ee6caSBen Skeggs { -1, -1, 0x0019, &nv40_gr_object }, /* clip */
86c85ee6caSBen Skeggs { -1, -1, 0x0030, &nv40_gr_object }, /* null */
87c85ee6caSBen Skeggs { -1, -1, 0x0039, &nv40_gr_object }, /* m2mf */
88c85ee6caSBen Skeggs { -1, -1, 0x0043, &nv40_gr_object }, /* rop */
89c85ee6caSBen Skeggs { -1, -1, 0x0044, &nv40_gr_object }, /* patt */
90c85ee6caSBen Skeggs { -1, -1, 0x004a, &nv40_gr_object }, /* gdi */
91c85ee6caSBen Skeggs { -1, -1, 0x0062, &nv40_gr_object }, /* surf2d */
92c85ee6caSBen Skeggs { -1, -1, 0x0072, &nv40_gr_object }, /* beta4 */
93c85ee6caSBen Skeggs { -1, -1, 0x0089, &nv40_gr_object }, /* sifm */
94c85ee6caSBen Skeggs { -1, -1, 0x008a, &nv40_gr_object }, /* ifc */
95c85ee6caSBen Skeggs { -1, -1, 0x009f, &nv40_gr_object }, /* imageblit */
96c85ee6caSBen Skeggs { -1, -1, 0x3062, &nv40_gr_object }, /* surf2d (nv40) */
97c85ee6caSBen Skeggs { -1, -1, 0x3089, &nv40_gr_object }, /* sifm (nv40) */
98c85ee6caSBen Skeggs { -1, -1, 0x309e, &nv40_gr_object }, /* swzsurf (nv40) */
99c85ee6caSBen Skeggs { -1, -1, 0x4497, &nv40_gr_object }, /* curie */
100c85ee6caSBen Skeggs {}
101c85ee6caSBen Skeggs }
102c85ee6caSBen Skeggs };
103c85ee6caSBen Skeggs
104c85ee6caSBen Skeggs int
nv44_gr_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_gr ** pgr)105*864d37c3SBen Skeggs nv44_gr_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_gr **pgr)
106c85ee6caSBen Skeggs {
107*864d37c3SBen Skeggs return nv40_gr_new_(&nv44_gr, device, type, inst, pgr);
108c85ee6caSBen Skeggs }
109