Commit 78b10b74 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/gsp: select implementation based on available firmware

This will allow for further customisation of the subdev depending on what
firmware is available.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent c63fe2e7
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
nvkm-y += nvkm/subdev/gsp/base.o
nvkm-y += nvkm/subdev/gsp/gv100.o nvkm-y += nvkm/subdev/gsp/gv100.o
/*
* Copyright 2019 Red Hat Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "priv.h"
#include <core/falcon.h>
#include <core/firmware.h>
#include <subdev/acr.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 *
nvkm_gsp_dtor(struct nvkm_subdev *subdev)
{
struct nvkm_gsp *gsp = nvkm_gsp(subdev);
nvkm_falcon_del(&gsp->falcon);
return gsp;
}
static const struct nvkm_subdev_func
nvkm_gsp = {
.dtor = nvkm_gsp_dtor,
.oneinit = nvkm_gsp_oneinit,
};
int
nvkm_gsp_new_(const struct nvkm_gsp_fwif *fwif, struct nvkm_device *device,
int index, struct nvkm_gsp **pgsp)
{
struct nvkm_gsp *gsp;
if (!(gsp = *pgsp = kzalloc(sizeof(*gsp), GFP_KERNEL)))
return -ENOMEM;
nvkm_subdev_ctor(&nvkm_gsp, device, index, &gsp->subdev);
fwif = nvkm_firmware_load(&gsp->subdev, fwif, "Gsp", gsp);
if (IS_ERR(fwif))
return PTR_ERR(fwif);
return 0;
}
...@@ -19,44 +19,22 @@ ...@@ -19,44 +19,22 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <subdev/gsp.h> #include "priv.h"
#include <subdev/top.h>
#include <engine/falcon.h>
static int static int
gv100_gsp_oneinit(struct nvkm_subdev *subdev) gv100_gsp_nofw(struct nvkm_gsp *gsp, int ver, const struct nvkm_gsp_fwif *fwif)
{ {
struct nvkm_gsp *gsp = nvkm_gsp(subdev); return 0;
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 *
gv100_gsp_dtor(struct nvkm_subdev *subdev)
{
struct nvkm_gsp *gsp = nvkm_gsp(subdev);
nvkm_falcon_del(&gsp->falcon);
return gsp;
} }
static const struct nvkm_subdev_func struct nvkm_gsp_fwif
gv100_gsp = { gv100_gsp[] = {
.dtor = gv100_gsp_dtor, { -1, gv100_gsp_nofw },
.oneinit = gv100_gsp_oneinit, {}
}; };
int int
gv100_gsp_new(struct nvkm_device *device, int index, struct nvkm_gsp **pgsp) gv100_gsp_new(struct nvkm_device *device, int index, struct nvkm_gsp **pgsp)
{ {
struct nvkm_gsp *gsp; return nvkm_gsp_new_(gv100_gsp, device, index, pgsp);
if (!(gsp = *pgsp = kzalloc(sizeof(*gsp), GFP_KERNEL)))
return -ENOMEM;
nvkm_subdev_ctor(&gv100_gsp, device, index, &gsp->subdev);
return 0;
} }
/* SPDX-License-Identifier: MIT */
#ifndef __NVKM_GSP_PRIV_H__
#define __NVKM_GSP_PRIV_H__
#include <subdev/gsp.h>
enum nvkm_acr_lsf_id;
struct nvkm_gsp_fwif {
int version;
int (*load)(struct nvkm_gsp *, int ver, const struct nvkm_gsp_fwif *);
};
int nvkm_gsp_new_(const struct nvkm_gsp_fwif *, struct nvkm_device *, int,
struct nvkm_gsp **);
#endif
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