Commit 334815ef authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/gsp: initialise SW state for falcon from constructor

This will allow us to register the falcon with ACR, and further customise
its behaviour by providing the nvkm_falcon_func structure directly.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 78b10b74
...@@ -2,12 +2,11 @@ ...@@ -2,12 +2,11 @@
#define __NVKM_GSP_H__ #define __NVKM_GSP_H__
#define nvkm_gsp(p) container_of((p), struct nvkm_gsp, subdev) #define nvkm_gsp(p) container_of((p), struct nvkm_gsp, subdev)
#include <core/subdev.h> #include <core/subdev.h>
#include <core/falcon.h>
struct nvkm_gsp { struct nvkm_gsp {
struct nvkm_subdev subdev; struct nvkm_subdev subdev;
u32 addr; struct nvkm_falcon falcon;
struct nvkm_falcon *falcon;
}; };
int gv100_gsp_new(struct nvkm_device *, int, struct nvkm_gsp **); int gv100_gsp_new(struct nvkm_device *, int, struct nvkm_gsp **);
......
...@@ -25,30 +25,17 @@ ...@@ -25,30 +25,17 @@
#include <subdev/acr.h> #include <subdev/acr.h>
#include <subdev/top.h> #include <subdev/top.h>
static int
nvkm_gsp_oneinit(struct nvkm_subdev *subdev)
{
struct nvkm_gsp *gsp = nvkm_gsp(subdev);
gsp->addr = nvkm_top_addr(subdev->device, subdev->index);
if (!gsp->addr)
return -EINVAL;
return nvkm_falcon_v1_new(subdev, "GSP", gsp->addr, &gsp->falcon);
}
static void * static void *
nvkm_gsp_dtor(struct nvkm_subdev *subdev) nvkm_gsp_dtor(struct nvkm_subdev *subdev)
{ {
struct nvkm_gsp *gsp = nvkm_gsp(subdev); struct nvkm_gsp *gsp = nvkm_gsp(subdev);
nvkm_falcon_del(&gsp->falcon); nvkm_falcon_dtor(&gsp->falcon);
return gsp; return gsp;
} }
static const struct nvkm_subdev_func static const struct nvkm_subdev_func
nvkm_gsp = { nvkm_gsp = {
.dtor = nvkm_gsp_dtor, .dtor = nvkm_gsp_dtor,
.oneinit = nvkm_gsp_oneinit,
}; };
int int
...@@ -66,5 +53,7 @@ nvkm_gsp_new_(const struct nvkm_gsp_fwif *fwif, struct nvkm_device *device, ...@@ -66,5 +53,7 @@ nvkm_gsp_new_(const struct nvkm_gsp_fwif *fwif, struct nvkm_device *device,
if (IS_ERR(fwif)) if (IS_ERR(fwif))
return PTR_ERR(fwif); return PTR_ERR(fwif);
return 0; return nvkm_falcon_ctor(fwif->flcn, &gsp->subdev,
nvkm_subdev_name[gsp->subdev.index], 0,
&gsp->falcon);
} }
...@@ -21,6 +21,20 @@ ...@@ -21,6 +21,20 @@
*/ */
#include "priv.h" #include "priv.h"
static const struct nvkm_falcon_func
gv100_gsp_flcn = {
.load_imem = nvkm_falcon_v1_load_imem,
.load_dmem = nvkm_falcon_v1_load_dmem,
.read_dmem = nvkm_falcon_v1_read_dmem,
.bind_context = nvkm_falcon_v1_bind_context,
.wait_for_halt = nvkm_falcon_v1_wait_for_halt,
.clear_interrupt = nvkm_falcon_v1_clear_interrupt,
.set_start_addr = nvkm_falcon_v1_set_start_addr,
.start = nvkm_falcon_v1_start,
.enable = nvkm_falcon_v1_enable,
.disable = nvkm_falcon_v1_disable,
};
static int static int
gv100_gsp_nofw(struct nvkm_gsp *gsp, int ver, const struct nvkm_gsp_fwif *fwif) gv100_gsp_nofw(struct nvkm_gsp *gsp, int ver, const struct nvkm_gsp_fwif *fwif)
{ {
...@@ -29,7 +43,7 @@ gv100_gsp_nofw(struct nvkm_gsp *gsp, int ver, const struct nvkm_gsp_fwif *fwif) ...@@ -29,7 +43,7 @@ gv100_gsp_nofw(struct nvkm_gsp *gsp, int ver, const struct nvkm_gsp_fwif *fwif)
struct nvkm_gsp_fwif struct nvkm_gsp_fwif
gv100_gsp[] = { gv100_gsp[] = {
{ -1, gv100_gsp_nofw }, { -1, gv100_gsp_nofw, &gv100_gsp_flcn },
{} {}
}; };
......
...@@ -7,6 +7,7 @@ enum nvkm_acr_lsf_id; ...@@ -7,6 +7,7 @@ enum nvkm_acr_lsf_id;
struct nvkm_gsp_fwif { struct nvkm_gsp_fwif {
int version; int version;
int (*load)(struct nvkm_gsp *, int ver, const struct nvkm_gsp_fwif *); int (*load)(struct nvkm_gsp *, int ver, const struct nvkm_gsp_fwif *);
const struct nvkm_falcon_func *flcn;
}; };
int nvkm_gsp_new_(const struct nvkm_gsp_fwif *, struct nvkm_device *, int, int nvkm_gsp_new_(const struct nvkm_gsp_fwif *, struct nvkm_device *, int,
......
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