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 */
2492fba5d3SBen Skeggs #include "priv.h"
25acbe9ecfSBen Skeggs #include "chan.h"
26a1c93078SBen Skeggs #include "head.h"
2778f1ad6fSBen Skeggs #include "ior.h"
28168c0299SBen Skeggs
29168c0299SBen Skeggs #include <nvif/class.h>
30c39f472eSBen Skeggs
31acbe9ecfSBen Skeggs void
gm107_sor_dp_pattern(struct nvkm_ior * sor,int pattern)32acbe9ecfSBen Skeggs gm107_sor_dp_pattern(struct nvkm_ior *sor, int pattern)
33acbe9ecfSBen Skeggs {
34acbe9ecfSBen Skeggs struct nvkm_device *device = sor->disp->engine.subdev.device;
35acbe9ecfSBen Skeggs const u32 soff = nv50_ior_base(sor);
36acbe9ecfSBen Skeggs u32 mask = 0x1f1f1f1f, data;
37acbe9ecfSBen Skeggs
38acbe9ecfSBen Skeggs switch (pattern) {
39acbe9ecfSBen Skeggs case 0: data = 0x10101010; break;
40acbe9ecfSBen Skeggs case 1: data = 0x01010101; break;
41acbe9ecfSBen Skeggs case 2: data = 0x02020202; break;
42acbe9ecfSBen Skeggs case 3: data = 0x03030303; break;
43acbe9ecfSBen Skeggs case 4: data = 0x1b1b1b1b; break;
44acbe9ecfSBen Skeggs default:
45acbe9ecfSBen Skeggs WARN_ON(1);
46acbe9ecfSBen Skeggs return;
47acbe9ecfSBen Skeggs }
48acbe9ecfSBen Skeggs
49acbe9ecfSBen Skeggs if (sor->asy.link & 1)
50acbe9ecfSBen Skeggs nvkm_mask(device, 0x61c110 + soff, mask, data);
51acbe9ecfSBen Skeggs else
52acbe9ecfSBen Skeggs nvkm_mask(device, 0x61c12c + soff, mask, data);
53acbe9ecfSBen Skeggs }
54acbe9ecfSBen Skeggs
559a4514fbSBen Skeggs static const struct nvkm_ior_func_dp
569a4514fbSBen Skeggs gm107_sor_dp = {
57acbe9ecfSBen Skeggs .lanes = { 0, 1, 2, 3 },
58acbe9ecfSBen Skeggs .links = gf119_sor_dp_links,
59acbe9ecfSBen Skeggs .power = g94_sor_dp_power,
60acbe9ecfSBen Skeggs .pattern = gm107_sor_dp_pattern,
61acbe9ecfSBen Skeggs .drive = gf119_sor_dp_drive,
62acbe9ecfSBen Skeggs .vcpi = gf119_sor_dp_vcpi,
63acbe9ecfSBen Skeggs .audio = gf119_sor_dp_audio,
64acbe9ecfSBen Skeggs .audio_sym = gf119_sor_dp_audio_sym,
65acbe9ecfSBen Skeggs .watermark = gf119_sor_dp_watermark,
669a4514fbSBen Skeggs };
679a4514fbSBen Skeggs
689a4514fbSBen Skeggs static const struct nvkm_ior_func
699a4514fbSBen Skeggs gm107_sor = {
709a4514fbSBen Skeggs .state = gf119_sor_state,
719a4514fbSBen Skeggs .power = nv50_sor_power,
729a4514fbSBen Skeggs .clock = gf119_sor_clock,
73*2274ce7eSBen Skeggs .bl = >215_sor_bl,
74f530bc60SBen Skeggs .hdmi = &gk104_sor_hdmi,
759a4514fbSBen Skeggs .dp = &gm107_sor_dp,
767bcf89eeSBen Skeggs .hda = &gf119_sor_hda,
77acbe9ecfSBen Skeggs };
78acbe9ecfSBen Skeggs
79acbe9ecfSBen Skeggs static int
gm107_sor_new(struct nvkm_disp * disp,int id)80acbe9ecfSBen Skeggs gm107_sor_new(struct nvkm_disp *disp, int id)
81acbe9ecfSBen Skeggs {
8279c453afSBen Skeggs return nvkm_ior_new_(&gm107_sor, disp, SOR, id, true);
83acbe9ecfSBen Skeggs }
84acbe9ecfSBen Skeggs
850407b33fSBen Skeggs static const struct nvkm_disp_func
860ce41e3cSBen Skeggs gm107_disp = {
87acbe9ecfSBen Skeggs .oneinit = nv50_disp_oneinit,
8892fba5d3SBen Skeggs .init = gf119_disp_init,
8992fba5d3SBen Skeggs .fini = gf119_disp_fini,
9092fba5d3SBen Skeggs .intr = gf119_disp_intr,
91fd47877fSBen Skeggs .intr_error = gf119_disp_intr_error,
92af85389cSBen Skeggs .super = gf119_disp_super,
9392fba5d3SBen Skeggs .uevent = &gf119_disp_chan_uevent,
94f7b2ece3SBen Skeggs .head = { .cnt = gf119_head_cnt, .new = gf119_head_new },
95bf5d1a6bSBen Skeggs .dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new },
969fe4e177SBen Skeggs .sor = { .cnt = gf119_sor_cnt, .new = gm107_sor_new },
97168c0299SBen Skeggs .root = { 0,0,GM107_DISP },
98168c0299SBen Skeggs .user = {
99889fcbe9SBen Skeggs {{0,0,GK104_DISP_CURSOR }, nvkm_disp_chan_new, &gf119_disp_curs },
100889fcbe9SBen Skeggs {{0,0,GK104_DISP_OVERLAY }, nvkm_disp_chan_new, &gf119_disp_oimm },
101889fcbe9SBen Skeggs {{0,0,GK110_DISP_BASE_CHANNEL_DMA }, nvkm_disp_chan_new, &gf119_disp_base },
102889fcbe9SBen Skeggs {{0,0,GM107_DISP_CORE_CHANNEL_DMA }, nvkm_disp_core_new, &gk104_disp_core },
103889fcbe9SBen Skeggs {{0,0,GK104_DISP_OVERLAY_CONTROL_DMA}, nvkm_disp_chan_new, &gk104_disp_ovly },
104168c0299SBen Skeggs {}
105168c0299SBen Skeggs },
1060ce41e3cSBen Skeggs };
1070ce41e3cSBen Skeggs
10870aa8670SBen Skeggs int
gm107_disp_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_disp ** pdisp)109a7f000ecSBen Skeggs gm107_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
110a7f000ecSBen Skeggs struct nvkm_disp **pdisp)
111c39f472eSBen Skeggs {
1121c6aab75SBen Skeggs return nvkm_disp_new_(&gm107_disp, device, type, inst, pdisp);
113c39f472eSBen Skeggs }
114