Commit ebb195db authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/mc: move NV_PMC_ENABLE bashing to chipset-specific code

Ampere needs different handling here, most of what we touch has moved.

We probably want to refactor these interfaces in general, but I'm not
yet sure how they should look, this will get the job done for now.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
parent fe76fe49
...@@ -73,9 +73,8 @@ nvkm_mc_reset(struct nvkm_device *device, enum nvkm_subdev_type type, int inst) ...@@ -73,9 +73,8 @@ nvkm_mc_reset(struct nvkm_device *device, enum nvkm_subdev_type type, int inst)
{ {
u64 pmc_enable = nvkm_mc_reset_mask(device, true, type, inst); u64 pmc_enable = nvkm_mc_reset_mask(device, true, type, inst);
if (pmc_enable) { if (pmc_enable) {
nvkm_mask(device, 0x000200, pmc_enable, 0x00000000); device->mc->func->device->disable(device->mc, pmc_enable);
nvkm_mask(device, 0x000200, pmc_enable, pmc_enable); device->mc->func->device->enable(device->mc, pmc_enable);
nvkm_rd32(device, 0x000200);
} }
} }
...@@ -84,17 +83,15 @@ nvkm_mc_disable(struct nvkm_device *device, enum nvkm_subdev_type type, int inst ...@@ -84,17 +83,15 @@ nvkm_mc_disable(struct nvkm_device *device, enum nvkm_subdev_type type, int inst
{ {
u64 pmc_enable = nvkm_mc_reset_mask(device, false, type, inst); u64 pmc_enable = nvkm_mc_reset_mask(device, false, type, inst);
if (pmc_enable) if (pmc_enable)
nvkm_mask(device, 0x000200, pmc_enable, 0x00000000); device->mc->func->device->disable(device->mc, pmc_enable);
} }
void void
nvkm_mc_enable(struct nvkm_device *device, enum nvkm_subdev_type type, int inst) nvkm_mc_enable(struct nvkm_device *device, enum nvkm_subdev_type type, int inst)
{ {
u64 pmc_enable = nvkm_mc_reset_mask(device, false, type, inst); u64 pmc_enable = nvkm_mc_reset_mask(device, false, type, inst);
if (pmc_enable) { if (pmc_enable)
nvkm_mask(device, 0x000200, pmc_enable, pmc_enable); device->mc->func->device->enable(device->mc, pmc_enable);
nvkm_rd32(device, 0x000200);
}
} }
bool bool
...@@ -102,11 +99,9 @@ nvkm_mc_enabled(struct nvkm_device *device, enum nvkm_subdev_type type, int inst ...@@ -102,11 +99,9 @@ nvkm_mc_enabled(struct nvkm_device *device, enum nvkm_subdev_type type, int inst
{ {
u64 pmc_enable = nvkm_mc_reset_mask(device, false, type, inst); u64 pmc_enable = nvkm_mc_reset_mask(device, false, type, inst);
return (pmc_enable != 0) && return (pmc_enable != 0) && device->mc->func->device->enabled(device->mc, pmc_enable);
((nvkm_rd32(device, 0x000200) & pmc_enable) == pmc_enable);
} }
static int static int
nvkm_mc_init(struct nvkm_subdev *subdev) nvkm_mc_init(struct nvkm_subdev *subdev)
{ {
......
...@@ -56,6 +56,7 @@ g84_mc = { ...@@ -56,6 +56,7 @@ g84_mc = {
.init = nv50_mc_init, .init = nv50_mc_init,
.intr = &nv04_mc_intr, .intr = &nv04_mc_intr,
.intrs = g84_mc_intrs, .intrs = g84_mc_intrs,
.device = &nv04_mc_device,
.reset = g84_mc_reset, .reset = g84_mc_reset,
}; };
......
...@@ -56,6 +56,7 @@ g98_mc = { ...@@ -56,6 +56,7 @@ g98_mc = {
.init = nv50_mc_init, .init = nv50_mc_init,
.intr = &nv04_mc_intr, .intr = &nv04_mc_intr,
.intrs = g98_mc_intrs, .intrs = g98_mc_intrs,
.device = &nv04_mc_device,
.reset = g98_mc_reset, .reset = g98_mc_reset,
}; };
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
static const struct nvkm_mc_func static const struct nvkm_mc_func
ga100_mc = { ga100_mc = {
.init = nv50_mc_init, .init = nv50_mc_init,
.device = &nv04_mc_device,
.reset = gk104_mc_reset, .reset = gk104_mc_reset,
}; };
......
...@@ -71,6 +71,7 @@ gf100_mc = { ...@@ -71,6 +71,7 @@ gf100_mc = {
.intrs = gf100_mc_intrs, .intrs = gf100_mc_intrs,
.intr_nonstall = true, .intr_nonstall = true,
.reset = gf100_mc_reset, .reset = gf100_mc_reset,
.device = &nv04_mc_device,
.unk260 = gf100_mc_unk260, .unk260 = gf100_mc_unk260,
}; };
......
...@@ -54,6 +54,7 @@ gk104_mc = { ...@@ -54,6 +54,7 @@ gk104_mc = {
.intrs = gk104_mc_intrs, .intrs = gk104_mc_intrs,
.intr_nonstall = true, .intr_nonstall = true,
.reset = gk104_mc_reset, .reset = gk104_mc_reset,
.device = &nv04_mc_device,
.unk260 = gf100_mc_unk260, .unk260 = gf100_mc_unk260,
}; };
......
...@@ -29,6 +29,7 @@ gk20a_mc = { ...@@ -29,6 +29,7 @@ gk20a_mc = {
.intr = &gt215_mc_intr, .intr = &gt215_mc_intr,
.intrs = gk104_mc_intrs, .intrs = gk104_mc_intrs,
.intr_nonstall = true, .intr_nonstall = true,
.device = &nv04_mc_device,
.reset = gk104_mc_reset, .reset = gk104_mc_reset,
}; };
......
...@@ -90,6 +90,7 @@ gp100_mc = { ...@@ -90,6 +90,7 @@ gp100_mc = {
.intr = &gp100_mc_intr, .intr = &gp100_mc_intr,
.intrs = gp100_mc_intrs, .intrs = gp100_mc_intrs,
.intr_nonstall = true, .intr_nonstall = true,
.device = &nv04_mc_device,
.reset = gk104_mc_reset, .reset = gk104_mc_reset,
}; };
......
...@@ -37,6 +37,7 @@ gp10b_mc = { ...@@ -37,6 +37,7 @@ gp10b_mc = {
.intr = &gp100_mc_intr, .intr = &gp100_mc_intr,
.intrs = gp100_mc_intrs, .intrs = gp100_mc_intrs,
.intr_nonstall = true, .intr_nonstall = true,
.device = &nv04_mc_device,
.reset = gk104_mc_reset, .reset = gk104_mc_reset,
}; };
......
...@@ -83,6 +83,7 @@ gt215_mc = { ...@@ -83,6 +83,7 @@ gt215_mc = {
.init = nv50_mc_init, .init = nv50_mc_init,
.intr = &nv04_mc_intr, .intr = &nv04_mc_intr,
.intrs = gt215_mc_intrs, .intrs = gt215_mc_intrs,
.device = &nv04_mc_device,
.reset = gt215_mc_reset, .reset = gt215_mc_reset,
}; };
......
...@@ -30,6 +30,34 @@ nv04_mc_reset[] = { ...@@ -30,6 +30,34 @@ nv04_mc_reset[] = {
{} {}
}; };
static void
nv04_mc_device_disable(struct nvkm_mc *mc, u32 mask)
{
nvkm_mask(mc->subdev.device, 0x000200, mask, 0x00000000);
}
static void
nv04_mc_device_enable(struct nvkm_mc *mc, u32 mask)
{
struct nvkm_device *device = mc->subdev.device;
nvkm_mask(device, 0x000200, mask, mask);
nvkm_rd32(device, 0x000200);
}
static bool
nv04_mc_device_enabled(struct nvkm_mc *mc, u32 mask)
{
return (nvkm_rd32(mc->subdev.device, 0x000200) & mask) == mask;
}
const struct nvkm_mc_device_func
nv04_mc_device = {
.enabled = nv04_mc_device_enabled,
.enable = nv04_mc_device_enable,
.disable = nv04_mc_device_disable,
};
static const struct nvkm_intr_data static const struct nvkm_intr_data
nv04_mc_intrs[] = { nv04_mc_intrs[] = {
{ NVKM_ENGINE_DISP , 0, 0, 0x01010000, true }, { NVKM_ENGINE_DISP , 0, 0, 0x01010000, true },
...@@ -98,6 +126,7 @@ nv04_mc = { ...@@ -98,6 +126,7 @@ nv04_mc = {
.init = nv04_mc_init, .init = nv04_mc_init,
.intr = &nv04_mc_intr, .intr = &nv04_mc_intr,
.intrs = nv04_mc_intrs, .intrs = nv04_mc_intrs,
.device = &nv04_mc_device,
.reset = nv04_mc_reset, .reset = nv04_mc_reset,
}; };
......
...@@ -38,6 +38,7 @@ nv11_mc = { ...@@ -38,6 +38,7 @@ nv11_mc = {
.init = nv04_mc_init, .init = nv04_mc_init,
.intr = &nv04_mc_intr, .intr = &nv04_mc_intr,
.intrs = nv11_mc_intrs, .intrs = nv11_mc_intrs,
.device = &nv04_mc_device,
.reset = nv04_mc_reset, .reset = nv04_mc_reset,
}; };
......
...@@ -47,6 +47,7 @@ nv17_mc = { ...@@ -47,6 +47,7 @@ nv17_mc = {
.init = nv04_mc_init, .init = nv04_mc_init,
.intr = &nv04_mc_intr, .intr = &nv04_mc_intr,
.intrs = nv17_mc_intrs, .intrs = nv17_mc_intrs,
.device = &nv04_mc_device,
.reset = nv17_mc_reset, .reset = nv17_mc_reset,
}; };
......
...@@ -42,6 +42,7 @@ nv44_mc = { ...@@ -42,6 +42,7 @@ nv44_mc = {
.init = nv44_mc_init, .init = nv44_mc_init,
.intr = &nv04_mc_intr, .intr = &nv04_mc_intr,
.intrs = nv17_mc_intrs, .intrs = nv17_mc_intrs,
.device = &nv04_mc_device,
.reset = nv17_mc_reset, .reset = nv17_mc_reset,
}; };
......
...@@ -49,6 +49,7 @@ nv50_mc = { ...@@ -49,6 +49,7 @@ nv50_mc = {
.init = nv50_mc_init, .init = nv50_mc_init,
.intr = &nv04_mc_intr, .intr = &nv04_mc_intr,
.intrs = nv50_mc_intrs, .intrs = nv50_mc_intrs,
.device = &nv04_mc_device,
.reset = nv17_mc_reset, .reset = nv17_mc_reset,
}; };
......
...@@ -21,7 +21,14 @@ struct nvkm_mc_func { ...@@ -21,7 +21,14 @@ struct nvkm_mc_func {
const struct nvkm_intr_data *intrs; const struct nvkm_intr_data *intrs;
bool intr_nonstall; bool intr_nonstall;
const struct nvkm_mc_device_func {
bool (*enabled)(struct nvkm_mc *, u32 mask);
void (*enable)(struct nvkm_mc *, u32 mask);
void (*disable)(struct nvkm_mc *, u32 mask);
} *device;
const struct nvkm_mc_map *reset; const struct nvkm_mc_map *reset;
void (*unk260)(struct nvkm_mc *, u32); void (*unk260)(struct nvkm_mc *, u32);
}; };
...@@ -30,6 +37,7 @@ extern const struct nvkm_intr_func nv04_mc_intr; ...@@ -30,6 +37,7 @@ extern const struct nvkm_intr_func nv04_mc_intr;
bool nv04_mc_intr_pending(struct nvkm_intr *); bool nv04_mc_intr_pending(struct nvkm_intr *);
void nv04_mc_intr_unarm(struct nvkm_intr *); void nv04_mc_intr_unarm(struct nvkm_intr *);
void nv04_mc_intr_rearm(struct nvkm_intr *); void nv04_mc_intr_rearm(struct nvkm_intr *);
extern const struct nvkm_mc_device_func nv04_mc_device;
extern const struct nvkm_mc_map nv04_mc_reset[]; extern const struct nvkm_mc_map nv04_mc_reset[];
extern const struct nvkm_intr_data nv17_mc_intrs[]; extern const struct nvkm_intr_data nv17_mc_intrs[];
......
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