drm/mgag200: Add per-device callbacks

While currently empty, the device callbacks will allow mgag200's
modesetting code to interact with the BMC and PIXPLLC.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Tested-by: Jocelyn Falempe <jfalempe@redhat.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20220728124103.30159-10-tzimmermann@suse.de
This commit is contained in:
Thomas Zimmermann 2022-07-28 14:40:58 +02:00
parent 5cd062e31d
commit f639f74a78
10 changed files with 48 additions and 10 deletions

View File

@ -162,13 +162,15 @@ int mgag200_device_preinit(struct mga_device *mdev)
} }
int mgag200_device_init(struct mga_device *mdev, enum mga_type type, int mgag200_device_init(struct mga_device *mdev, enum mga_type type,
const struct mgag200_device_info *info) const struct mgag200_device_info *info,
const struct mgag200_device_funcs *funcs)
{ {
struct drm_device *dev = &mdev->base; struct drm_device *dev = &mdev->base;
u8 crtcext3, misc; u8 crtcext3, misc;
int ret; int ret;
mdev->info = info; mdev->info = info;
mdev->funcs = funcs;
mdev->type = type; mdev->type = type;
ret = drmm_mutex_init(dev, &mdev->rmmio_lock); ret = drmm_mutex_init(dev, &mdev->rmmio_lock);

View File

@ -262,10 +262,14 @@ struct mgag200_device_info {
.bug_no_startadd = (_bug_no_startadd), \ .bug_no_startadd = (_bug_no_startadd), \
} }
struct mgag200_device_funcs {
};
struct mga_device { struct mga_device {
struct drm_device base; struct drm_device base;
const struct mgag200_device_info *info; const struct mgag200_device_info *info;
const struct mgag200_device_funcs *funcs;
struct resource *rmmio_res; struct resource *rmmio_res;
void __iomem *rmmio; void __iomem *rmmio;
@ -322,7 +326,8 @@ resource_size_t mgag200_probe_vram(void __iomem *mem, resource_size_t size);
resource_size_t mgag200_device_probe_vram(struct mga_device *mdev); resource_size_t mgag200_device_probe_vram(struct mga_device *mdev);
int mgag200_device_preinit(struct mga_device *mdev); int mgag200_device_preinit(struct mga_device *mdev);
int mgag200_device_init(struct mga_device *mdev, enum mga_type type, int mgag200_device_init(struct mga_device *mdev, enum mga_type type,
const struct mgag200_device_info *info); const struct mgag200_device_info *info,
const struct mgag200_device_funcs *funcs);
/* mgag200_<device type>.c */ /* mgag200_<device type>.c */
struct mga_device *mgag200_g200_device_create(struct pci_dev *pdev, const struct drm_driver *drv, struct mga_device *mgag200_g200_device_create(struct pci_dev *pdev, const struct drm_driver *drv,

View File

@ -183,6 +183,9 @@ out:
pci_unmap_rom(pdev, rom); pci_unmap_rom(pdev, rom);
} }
static const struct mgag200_device_funcs mgag200_g200_device_funcs = {
};
struct mga_device *mgag200_g200_device_create(struct pci_dev *pdev, const struct drm_driver *drv, struct mga_device *mgag200_g200_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
enum mga_type type) enum mga_type type)
{ {
@ -210,7 +213,8 @@ struct mga_device *mgag200_g200_device_create(struct pci_dev *pdev, const struct
mgag200_g200_init_refclk(g200); mgag200_g200_init_refclk(g200);
ret = mgag200_device_init(mdev, type, &mgag200_g200_device_info); ret = mgag200_device_init(mdev, type, &mgag200_g200_device_info,
&mgag200_g200_device_funcs);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);

View File

@ -37,6 +37,9 @@ void mgag200_g200eh_init_registers(struct mga_device *mdev)
static const struct mgag200_device_info mgag200_g200eh_device_info = static const struct mgag200_device_info mgag200_g200eh_device_info =
MGAG200_DEVICE_INFO_INIT(2048, 2048, 37500, false, 1, 0, false); MGAG200_DEVICE_INFO_INIT(2048, 2048, 37500, false, 1, 0, false);
static const struct mgag200_device_funcs mgag200_g200eh_device_funcs = {
};
struct mga_device *mgag200_g200eh_device_create(struct pci_dev *pdev, const struct drm_driver *drv, struct mga_device *mgag200_g200eh_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
enum mga_type type) enum mga_type type)
{ {
@ -60,7 +63,8 @@ struct mga_device *mgag200_g200eh_device_create(struct pci_dev *pdev, const stru
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
ret = mgag200_device_init(mdev, type, &mgag200_g200eh_device_info); ret = mgag200_device_init(mdev, type, &mgag200_g200eh_device_info,
&mgag200_g200eh_device_funcs);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);

View File

@ -13,6 +13,9 @@
static const struct mgag200_device_info mgag200_g200eh3_device_info = static const struct mgag200_device_info mgag200_g200eh3_device_info =
MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, false, 1, 0, false); MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, false, 1, 0, false);
static const struct mgag200_device_funcs mgag200_g200eh3_device_funcs = {
};
struct mga_device *mgag200_g200eh3_device_create(struct pci_dev *pdev, struct mga_device *mgag200_g200eh3_device_create(struct pci_dev *pdev,
const struct drm_driver *drv, const struct drm_driver *drv,
enum mga_type type) enum mga_type type)
@ -37,7 +40,8 @@ struct mga_device *mgag200_g200eh3_device_create(struct pci_dev *pdev,
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
ret = mgag200_device_init(mdev, type, &mgag200_g200eh3_device_info); ret = mgag200_device_init(mdev, type, &mgag200_g200eh3_device_info,
&mgag200_g200eh3_device_funcs);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);

View File

@ -38,6 +38,9 @@ static void mgag200_g200er_init_registers(struct mga_device *mdev)
static const struct mgag200_device_info mgag200_g200er_device_info = static const struct mgag200_device_info mgag200_g200er_device_info =
MGAG200_DEVICE_INFO_INIT(2048, 2048, 55000, false, 1, 0, false); MGAG200_DEVICE_INFO_INIT(2048, 2048, 55000, false, 1, 0, false);
static const struct mgag200_device_funcs mgag200_g200er_device_funcs = {
};
struct mga_device *mgag200_g200er_device_create(struct pci_dev *pdev, const struct drm_driver *drv, struct mga_device *mgag200_g200er_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
enum mga_type type) enum mga_type type)
{ {
@ -57,7 +60,8 @@ struct mga_device *mgag200_g200er_device_create(struct pci_dev *pdev, const stru
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
ret = mgag200_device_init(mdev, type, &mgag200_g200er_device_info); ret = mgag200_device_init(mdev, type, &mgag200_g200er_device_info,
&mgag200_g200er_device_funcs);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);

View File

@ -38,6 +38,9 @@ static void mgag200_g200ev_init_registers(struct mga_device *mdev)
static const struct mgag200_device_info mgag200_g200ev_device_info = static const struct mgag200_device_info mgag200_g200ev_device_info =
MGAG200_DEVICE_INFO_INIT(2048, 2048, 32700, false, 0, 1, false); MGAG200_DEVICE_INFO_INIT(2048, 2048, 32700, false, 0, 1, false);
static const struct mgag200_device_funcs mgag200_g200ev_device_funcs = {
};
struct mga_device *mgag200_g200ev_device_create(struct pci_dev *pdev, const struct drm_driver *drv, struct mga_device *mgag200_g200ev_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
enum mga_type type) enum mga_type type)
{ {
@ -61,7 +64,8 @@ struct mga_device *mgag200_g200ev_device_create(struct pci_dev *pdev, const stru
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
ret = mgag200_device_init(mdev, type, &mgag200_g200ev_device_info); ret = mgag200_device_init(mdev, type, &mgag200_g200ev_device_info,
&mgag200_g200ev_device_funcs);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);

View File

@ -20,6 +20,9 @@ static void mgag200_g200ew3_init_registers(struct mga_device *mdev)
static const struct mgag200_device_info mgag200_g200ew3_device_info = static const struct mgag200_device_info mgag200_g200ew3_device_info =
MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, true, 0, 1, false); MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, true, 0, 1, false);
static const struct mgag200_device_funcs mgag200_g200ew3_device_funcs = {
};
static resource_size_t mgag200_g200ew3_device_probe_vram(struct mga_device *mdev) static resource_size_t mgag200_g200ew3_device_probe_vram(struct mga_device *mdev)
{ {
resource_size_t vram_size = resource_size(mdev->vram_res); resource_size_t vram_size = resource_size(mdev->vram_res);
@ -53,7 +56,8 @@ struct mga_device *mgag200_g200ew3_device_create(struct pci_dev *pdev,
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
ret = mgag200_device_init(mdev, type, &mgag200_g200ew3_device_info); ret = mgag200_device_init(mdev, type, &mgag200_g200ew3_device_info,
&mgag200_g200ew3_device_funcs);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);

View File

@ -93,6 +93,9 @@ static int mgag200_g200se_init_unique_rev_id(struct mgag200_g200se_device *g200s
return 0; return 0;
} }
static const struct mgag200_device_funcs mgag200_g200se_device_funcs = {
};
struct mga_device *mgag200_g200se_device_create(struct pci_dev *pdev, const struct drm_driver *drv, struct mga_device *mgag200_g200se_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
enum mga_type type) enum mga_type type)
{ {
@ -144,7 +147,7 @@ struct mga_device *mgag200_g200se_device_create(struct pci_dev *pdev, const stru
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
ret = mgag200_device_init(mdev, type, info); ret = mgag200_device_init(mdev, type, info, &mgag200_g200se_device_funcs);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);

View File

@ -35,6 +35,9 @@ void mgag200_g200wb_init_registers(struct mga_device *mdev)
static const struct mgag200_device_info mgag200_g200wb_device_info = static const struct mgag200_device_info mgag200_g200wb_device_info =
MGAG200_DEVICE_INFO_INIT(1280, 1024, 31877, true, 0, 1, false); MGAG200_DEVICE_INFO_INIT(1280, 1024, 31877, true, 0, 1, false);
static const struct mgag200_device_funcs mgag200_g200wb_device_funcs = {
};
struct mga_device *mgag200_g200wb_device_create(struct pci_dev *pdev, const struct drm_driver *drv, struct mga_device *mgag200_g200wb_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
enum mga_type type) enum mga_type type)
{ {
@ -58,7 +61,8 @@ struct mga_device *mgag200_g200wb_device_create(struct pci_dev *pdev, const stru
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
ret = mgag200_device_init(mdev, type, &mgag200_g200wb_device_info); ret = mgag200_device_init(mdev, type, &mgag200_g200wb_device_info,
&mgag200_g200wb_device_funcs);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);