Skip to content

Commit 1574054

Browse files
Ben Skeggsairlied
authored andcommitted
drm/nouveau/devinit/tu102-: prepare for GSP-RM
- add R535 implementation of DEVINIT, we need some of this for boot - add display disable fuse for ga100- Signed-off-by: Ben Skeggs <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 6a0fd03 commit 1574054

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed

drivers/gpu/drm/nouveau/nvkm/subdev/devinit/Kbuild

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ nvkm-y += nvkm/subdev/devinit/gm200.o
1616
nvkm-y += nvkm/subdev/devinit/gv100.o
1717
nvkm-y += nvkm/subdev/devinit/tu102.o
1818
nvkm-y += nvkm/subdev/devinit/ga100.o
19+
20+
nvkm-y += nvkm/subdev/devinit/r535.o

drivers/gpu/drm/nouveau/nvkm/subdev/devinit/ga100.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <subdev/bios.h>
2525
#include <subdev/bios/pll.h>
2626
#include <subdev/clk/pll.h>
27+
#include <subdev/gsp.h>
2728

2829
static int
2930
ga100_devinit_pll_set(struct nvkm_devinit *init, u32 type, u32 freq)
@@ -62,8 +63,19 @@ ga100_devinit_pll_set(struct nvkm_devinit *init, u32 type, u32 freq)
6263
return ret;
6364
}
6465

66+
static void
67+
ga100_devinit_disable(struct nvkm_devinit *init)
68+
{
69+
struct nvkm_device *device = init->subdev.device;
70+
u32 r820c04 = nvkm_rd32(device, 0x820c04);
71+
72+
if (r820c04 & 0x00000001)
73+
nvkm_subdev_disable(device, NVKM_ENGINE_DISP, 0);
74+
}
75+
6576
static const struct nvkm_devinit_func
6677
ga100_devinit = {
78+
.disable = ga100_devinit_disable,
6779
.init = nv50_devinit_init,
6880
.post = tu102_devinit_post,
6981
.pll_set = ga100_devinit_pll_set,
@@ -73,5 +85,8 @@ int
7385
ga100_devinit_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
7486
struct nvkm_devinit **pinit)
7587
{
88+
if (nvkm_gsp_rm(device->gsp))
89+
return r535_devinit_new(&ga100_devinit, device, type, inst, pinit);
90+
7691
return nv50_devinit_new_(&ga100_devinit, device, type, inst, pinit);
7792
}

drivers/gpu/drm/nouveau/nvkm/subdev/devinit/priv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#define nvkm_devinit(p) container_of((p), struct nvkm_devinit, subdev)
55
#include <subdev/devinit.h>
66

7+
int r535_devinit_new(const struct nvkm_devinit_func *,
8+
struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_devinit **);
9+
710
struct nvkm_devinit_func {
811
void *(*dtor)(struct nvkm_devinit *);
912
void (*preinit)(struct nvkm_devinit *);
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2023 Red Hat Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
#include "nv50.h"
23+
24+
static void *
25+
r535_devinit_dtor(struct nvkm_devinit *devinit)
26+
{
27+
kfree(devinit->func);
28+
return devinit;
29+
}
30+
31+
int
32+
r535_devinit_new(const struct nvkm_devinit_func *hw,
33+
struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
34+
struct nvkm_devinit **pdevinit)
35+
{
36+
struct nvkm_devinit_func *rm;
37+
int ret;
38+
39+
if (!(rm = kzalloc(sizeof(*rm), GFP_KERNEL)))
40+
return -ENOMEM;
41+
42+
rm->dtor = r535_devinit_dtor;
43+
rm->post = hw->post;
44+
rm->disable = hw->disable;
45+
46+
ret = nv50_devinit_new_(rm, device, type, inst, pdevinit);
47+
if (ret)
48+
kfree(rm);
49+
50+
return ret;
51+
}

drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <subdev/bios.h>
2525
#include <subdev/bios/pll.h>
2626
#include <subdev/clk/pll.h>
27+
#include <subdev/gsp.h>
2728

2829
static int
2930
tu102_devinit_pll_set(struct nvkm_devinit *init, u32 type, u32 freq)
@@ -100,5 +101,8 @@ int
100101
tu102_devinit_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
101102
struct nvkm_devinit **pinit)
102103
{
104+
if (nvkm_gsp_rm(device->gsp))
105+
return r535_devinit_new(&tu102_devinit, device, type, inst, pinit);
106+
103107
return nv50_devinit_new_(&tu102_devinit, device, type, inst, pinit);
104108
}

0 commit comments

Comments
 (0)