Commit 6b1277c8 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/pmu/gt215-: abstract detection of whether reset is needed

GT215, GF100-GP100, and GP10x are all different.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 715e7d26
...@@ -75,7 +75,7 @@ nvkm_pmu_reset(struct nvkm_pmu *pmu) ...@@ -75,7 +75,7 @@ nvkm_pmu_reset(struct nvkm_pmu *pmu)
{ {
struct nvkm_device *device = pmu->subdev.device; struct nvkm_device *device = pmu->subdev.device;
if (!(nvkm_rd32(device, 0x000200) & 0x00002000)) if (!pmu->func->enabled(pmu))
return 0; return 0;
/* Inhibit interrupts, and wait for idle. */ /* Inhibit interrupts, and wait for idle. */
......
...@@ -34,12 +34,19 @@ gf100_pmu_reset(struct nvkm_pmu *pmu) ...@@ -34,12 +34,19 @@ gf100_pmu_reset(struct nvkm_pmu *pmu)
nvkm_mc_enable(device, NVKM_SUBDEV_PMU); nvkm_mc_enable(device, NVKM_SUBDEV_PMU);
} }
bool
gf100_pmu_enabled(struct nvkm_pmu *pmu)
{
return nvkm_mc_enabled(pmu->subdev.device, NVKM_SUBDEV_PMU);
}
static const struct nvkm_pmu_func static const struct nvkm_pmu_func
gf100_pmu = { gf100_pmu = {
.code.data = gf100_pmu_code, .code.data = gf100_pmu_code,
.code.size = sizeof(gf100_pmu_code), .code.size = sizeof(gf100_pmu_code),
.data.data = gf100_pmu_data, .data.data = gf100_pmu_data,
.data.size = sizeof(gf100_pmu_data), .data.size = sizeof(gf100_pmu_data),
.enabled = gf100_pmu_enabled,
.reset = gf100_pmu_reset, .reset = gf100_pmu_reset,
.init = gt215_pmu_init, .init = gt215_pmu_init,
.fini = gt215_pmu_fini, .fini = gt215_pmu_fini,
......
...@@ -30,6 +30,7 @@ gf119_pmu = { ...@@ -30,6 +30,7 @@ gf119_pmu = {
.code.size = sizeof(gf119_pmu_code), .code.size = sizeof(gf119_pmu_code),
.data.data = gf119_pmu_data, .data.data = gf119_pmu_data,
.data.size = sizeof(gf119_pmu_data), .data.size = sizeof(gf119_pmu_data),
.enabled = gf100_pmu_enabled,
.reset = gf100_pmu_reset, .reset = gf100_pmu_reset,
.init = gt215_pmu_init, .init = gt215_pmu_init,
.fini = gt215_pmu_fini, .fini = gt215_pmu_fini,
......
...@@ -109,6 +109,7 @@ gk104_pmu = { ...@@ -109,6 +109,7 @@ gk104_pmu = {
.code.size = sizeof(gk104_pmu_code), .code.size = sizeof(gk104_pmu_code),
.data.data = gk104_pmu_data, .data.data = gk104_pmu_data,
.data.size = sizeof(gk104_pmu_data), .data.size = sizeof(gk104_pmu_data),
.enabled = gf100_pmu_enabled,
.reset = gf100_pmu_reset, .reset = gf100_pmu_reset,
.init = gt215_pmu_init, .init = gt215_pmu_init,
.fini = gt215_pmu_fini, .fini = gt215_pmu_fini,
......
...@@ -88,6 +88,7 @@ gk110_pmu = { ...@@ -88,6 +88,7 @@ gk110_pmu = {
.code.size = sizeof(gk110_pmu_code), .code.size = sizeof(gk110_pmu_code),
.data.data = gk110_pmu_data, .data.data = gk110_pmu_data,
.data.size = sizeof(gk110_pmu_data), .data.size = sizeof(gk110_pmu_data),
.enabled = gf100_pmu_enabled,
.reset = gf100_pmu_reset, .reset = gf100_pmu_reset,
.init = gt215_pmu_init, .init = gt215_pmu_init,
.fini = gt215_pmu_fini, .fini = gt215_pmu_fini,
......
...@@ -30,6 +30,7 @@ gk208_pmu = { ...@@ -30,6 +30,7 @@ gk208_pmu = {
.code.size = sizeof(gk208_pmu_code), .code.size = sizeof(gk208_pmu_code),
.data.data = gk208_pmu_data, .data.data = gk208_pmu_data,
.data.size = sizeof(gk208_pmu_data), .data.size = sizeof(gk208_pmu_data),
.enabled = gf100_pmu_enabled,
.reset = gf100_pmu_reset, .reset = gf100_pmu_reset,
.init = gt215_pmu_init, .init = gt215_pmu_init,
.fini = gt215_pmu_fini, .fini = gt215_pmu_fini,
......
...@@ -196,6 +196,7 @@ gk20a_dvfs_data= { ...@@ -196,6 +196,7 @@ gk20a_dvfs_data= {
static const struct nvkm_pmu_func static const struct nvkm_pmu_func
gk20a_pmu = { gk20a_pmu = {
.enabled = gf100_pmu_enabled,
.init = gk20a_pmu_init, .init = gk20a_pmu_init,
.fini = gk20a_pmu_fini, .fini = gk20a_pmu_fini,
.reset = gf100_pmu_reset, .reset = gf100_pmu_reset,
......
...@@ -32,6 +32,7 @@ gm107_pmu = { ...@@ -32,6 +32,7 @@ gm107_pmu = {
.code.size = sizeof(gm107_pmu_code), .code.size = sizeof(gm107_pmu_code),
.data.data = gm107_pmu_data, .data.data = gm107_pmu_data,
.data.size = sizeof(gm107_pmu_data), .data.size = sizeof(gm107_pmu_data),
.enabled = gf100_pmu_enabled,
.reset = gf100_pmu_reset, .reset = gf100_pmu_reset,
.init = gt215_pmu_init, .init = gt215_pmu_init,
.fini = gt215_pmu_fini, .fini = gt215_pmu_fini,
......
...@@ -38,6 +38,7 @@ gm20b_pmu_recv(struct nvkm_pmu *pmu) ...@@ -38,6 +38,7 @@ gm20b_pmu_recv(struct nvkm_pmu *pmu)
static const struct nvkm_pmu_func static const struct nvkm_pmu_func
gm20b_pmu = { gm20b_pmu = {
.enabled = gf100_pmu_enabled,
.intr = gt215_pmu_intr, .intr = gt215_pmu_intr,
.recv = gm20b_pmu_recv, .recv = gm20b_pmu_recv,
}; };
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
static const struct nvkm_pmu_func static const struct nvkm_pmu_func
gp100_pmu = { gp100_pmu = {
.enabled = gf100_pmu_enabled,
.reset = gf100_pmu_reset, .reset = gf100_pmu_reset,
}; };
......
...@@ -31,8 +31,15 @@ gp102_pmu_reset(struct nvkm_pmu *pmu) ...@@ -31,8 +31,15 @@ gp102_pmu_reset(struct nvkm_pmu *pmu)
nvkm_mask(device, 0x10a3c0, 0x00000001, 0x00000000); nvkm_mask(device, 0x10a3c0, 0x00000001, 0x00000000);
} }
static bool
gp102_pmu_enabled(struct nvkm_pmu *pmu)
{
return !(nvkm_rd32(pmu->subdev.device, 0x10a3c0) & 0x00000001);
}
static const struct nvkm_pmu_func static const struct nvkm_pmu_func
gp102_pmu = { gp102_pmu = {
.enabled = gp102_pmu_enabled,
.reset = gp102_pmu_reset, .reset = gp102_pmu_reset,
}; };
......
...@@ -189,6 +189,12 @@ gt215_pmu_reset(struct nvkm_pmu *pmu) ...@@ -189,6 +189,12 @@ gt215_pmu_reset(struct nvkm_pmu *pmu)
nvkm_rd32(device, 0x022210); nvkm_rd32(device, 0x022210);
} }
static bool
gt215_pmu_enabled(struct nvkm_pmu *pmu)
{
return nvkm_rd32(pmu->subdev.device, 0x022210) & 0x00000001;
}
int int
gt215_pmu_init(struct nvkm_pmu *pmu) gt215_pmu_init(struct nvkm_pmu *pmu)
{ {
...@@ -241,6 +247,7 @@ gt215_pmu = { ...@@ -241,6 +247,7 @@ gt215_pmu = {
.code.size = sizeof(gt215_pmu_code), .code.size = sizeof(gt215_pmu_code),
.data.data = gt215_pmu_data, .data.data = gt215_pmu_data,
.data.size = sizeof(gt215_pmu_data), .data.size = sizeof(gt215_pmu_data),
.enabled = gt215_pmu_enabled,
.reset = gt215_pmu_reset, .reset = gt215_pmu_reset,
.init = gt215_pmu_init, .init = gt215_pmu_init,
.fini = gt215_pmu_fini, .fini = gt215_pmu_fini,
......
...@@ -20,6 +20,7 @@ struct nvkm_pmu_func { ...@@ -20,6 +20,7 @@ struct nvkm_pmu_func {
u32 size; u32 size;
} data; } data;
bool (*enabled)(struct nvkm_pmu *);
void (*reset)(struct nvkm_pmu *); void (*reset)(struct nvkm_pmu *);
int (*init)(struct nvkm_pmu *); int (*init)(struct nvkm_pmu *);
void (*fini)(struct nvkm_pmu *); void (*fini)(struct nvkm_pmu *);
...@@ -36,6 +37,7 @@ void gt215_pmu_intr(struct nvkm_pmu *); ...@@ -36,6 +37,7 @@ void gt215_pmu_intr(struct nvkm_pmu *);
void gt215_pmu_recv(struct nvkm_pmu *); void gt215_pmu_recv(struct nvkm_pmu *);
int gt215_pmu_send(struct nvkm_pmu *, u32[2], u32, u32, u32, u32); int gt215_pmu_send(struct nvkm_pmu *, u32[2], u32, u32, u32, u32);
bool gf100_pmu_enabled(struct nvkm_pmu *);
void gf100_pmu_reset(struct nvkm_pmu *); void gf100_pmu_reset(struct nvkm_pmu *);
void gk110_pmu_pgob(struct nvkm_pmu *, bool); void gk110_pmu_pgob(struct nvkm_pmu *, bool);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment