146fc98bfSBen Skeggs /*
246fc98bfSBen Skeggs * Copyright 2016 Red Hat Inc.
346fc98bfSBen Skeggs *
446fc98bfSBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a
546fc98bfSBen Skeggs * copy of this software and associated documentation files (the "Software"),
646fc98bfSBen Skeggs * to deal in the Software without restriction, including without limitation
746fc98bfSBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense,
846fc98bfSBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the
946fc98bfSBen Skeggs * Software is furnished to do so, subject to the following conditions:
1046fc98bfSBen Skeggs *
1146fc98bfSBen Skeggs * The above copyright notice and this permission notice shall be included in
1246fc98bfSBen Skeggs * all copies or substantial portions of the Software.
1346fc98bfSBen Skeggs *
1446fc98bfSBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1546fc98bfSBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1646fc98bfSBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1746fc98bfSBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1846fc98bfSBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1946fc98bfSBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2046fc98bfSBen Skeggs * OTHER DEALINGS IN THE SOFTWARE.
2146fc98bfSBen Skeggs *
2246fc98bfSBen Skeggs * Authors: Ben Skeggs <bskeggs@redhat.com>
2346fc98bfSBen Skeggs */
2446fc98bfSBen Skeggs #include "priv.h"
2546fc98bfSBen Skeggs
26*2541626cSBen Skeggs static int
gm200_pmu_flcn_bind_stat(struct nvkm_falcon * falcon,bool intr)27*2541626cSBen Skeggs gm200_pmu_flcn_bind_stat(struct nvkm_falcon *falcon, bool intr)
28*2541626cSBen Skeggs {
29*2541626cSBen Skeggs nvkm_falcon_wr32(falcon, 0x200, 0x0000030e);
30*2541626cSBen Skeggs return (nvkm_falcon_rd32(falcon, 0x20c) & 0x00007000) >> 12;
31*2541626cSBen Skeggs }
32*2541626cSBen Skeggs
33*2541626cSBen Skeggs void
gm200_pmu_flcn_bind_inst(struct nvkm_falcon * falcon,int target,u64 addr)34*2541626cSBen Skeggs gm200_pmu_flcn_bind_inst(struct nvkm_falcon *falcon, int target, u64 addr)
35*2541626cSBen Skeggs {
36*2541626cSBen Skeggs nvkm_falcon_wr32(falcon, 0xe00, 4); /* DMAIDX_UCODE */
37*2541626cSBen Skeggs nvkm_falcon_wr32(falcon, 0xe04, 0); /* DMAIDX_VIRT */
38*2541626cSBen Skeggs nvkm_falcon_wr32(falcon, 0xe08, 4); /* DMAIDX_PHYS_VID */
39*2541626cSBen Skeggs nvkm_falcon_wr32(falcon, 0xe0c, 5); /* DMAIDX_PHYS_SYS_COH */
40*2541626cSBen Skeggs nvkm_falcon_wr32(falcon, 0xe10, 6); /* DMAIDX_PHYS_SYS_NCOH */
41*2541626cSBen Skeggs nvkm_falcon_mask(falcon, 0x090, 0x00010000, 0x00010000);
42*2541626cSBen Skeggs nvkm_falcon_wr32(falcon, 0x480, (1 << 30) | (target << 28) | (addr >> 12));
43*2541626cSBen Skeggs }
44*2541626cSBen Skeggs
454cdd2450SBen Skeggs const struct nvkm_falcon_func
464cdd2450SBen Skeggs gm200_pmu_flcn = {
47f15cde64SBen Skeggs .disable = gm200_flcn_disable,
48f15cde64SBen Skeggs .enable = gm200_flcn_enable,
49f15cde64SBen Skeggs .reset_pmc = true,
50f15cde64SBen Skeggs .reset_wait_mem_scrubbing = gm200_flcn_reset_wait_mem_scrubbing,
514cdd2450SBen Skeggs .debug = 0xc08,
52*2541626cSBen Skeggs .bind_inst = gm200_pmu_flcn_bind_inst,
53*2541626cSBen Skeggs .bind_stat = gm200_pmu_flcn_bind_stat,
54*2541626cSBen Skeggs .imem_pio = &gm200_flcn_imem_pio,
55*2541626cSBen Skeggs .dmem_pio = &gm200_flcn_dmem_pio,
564cdd2450SBen Skeggs .start = nvkm_falcon_v1_start,
574cdd2450SBen Skeggs .cmdq = { 0x4a0, 0x4b0, 4 },
584cdd2450SBen Skeggs .msgq = { 0x4c8, 0x4cc, 0 },
594cdd2450SBen Skeggs };
604cdd2450SBen Skeggs
6146fc98bfSBen Skeggs static const struct nvkm_pmu_func
6246fc98bfSBen Skeggs gm200_pmu = {
634cdd2450SBen Skeggs .flcn = &gm200_pmu_flcn,
6446fc98bfSBen Skeggs .reset = gf100_pmu_reset,
6546fc98bfSBen Skeggs };
6646fc98bfSBen Skeggs
6738fd546bSBen Skeggs int
gm200_pmu_nofw(struct nvkm_pmu * pmu,int ver,const struct nvkm_pmu_fwif * fwif)6838fd546bSBen Skeggs gm200_pmu_nofw(struct nvkm_pmu *pmu, int ver, const struct nvkm_pmu_fwif *fwif)
6938fd546bSBen Skeggs {
7038fd546bSBen Skeggs nvkm_warn(&pmu->subdev, "firmware unavailable\n");
7138fd546bSBen Skeggs return 0;
7238fd546bSBen Skeggs }
7338fd546bSBen Skeggs
7446fc98bfSBen Skeggs static const struct nvkm_pmu_fwif
7546fc98bfSBen Skeggs gm200_pmu_fwif[] = {
7638fd546bSBen Skeggs { -1, gm200_pmu_nofw, &gm200_pmu },
7746fc98bfSBen Skeggs {}
7846fc98bfSBen Skeggs };
7946fc98bfSBen Skeggs
8046fc98bfSBen Skeggs int
gm200_pmu_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_pmu ** ppmu)81e4b15b4cSBen Skeggs gm200_pmu_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
82e4b15b4cSBen Skeggs struct nvkm_pmu **ppmu)
8346fc98bfSBen Skeggs {
84e4b15b4cSBen Skeggs return nvkm_pmu_new_(gm200_pmu_fwif, device, type, inst, ppmu);
8546fc98bfSBen Skeggs }
86