1 // SPDX-License-Identifier: GPL-2.0-only
2 
3 #include <linux/pci.h>
4 
5 #include <drm/drm_drv.h>
6 
7 #include "mgag200_drv.h"
8 
9 /*
10  * DRM device
11  */
12 
13 static const struct mgag200_device_info mgag200_g200er_device_info =
14 	MGAG200_DEVICE_INFO_INIT(2048, 2048, 55000, false, 1, 0, false);
15 
16 struct mga_device *mgag200_g200er_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
17 						enum mga_type type)
18 {
19 	struct mga_device *mdev;
20 	struct drm_device *dev;
21 	resource_size_t vram_available;
22 	int ret;
23 
24 	mdev = devm_drm_dev_alloc(&pdev->dev, drv, struct mga_device, base);
25 	if (IS_ERR(mdev))
26 		return mdev;
27 	dev = &mdev->base;
28 
29 	pci_set_drvdata(pdev, dev);
30 
31 	ret = mgag200_device_preinit(mdev);
32 	if (ret)
33 		return ERR_PTR(ret);
34 
35 	ret = mgag200_device_init(mdev, type, &mgag200_g200er_device_info);
36 	if (ret)
37 		return ERR_PTR(ret);
38 
39 	vram_available = mgag200_device_probe_vram(mdev);
40 
41 	ret = mgag200_modeset_init(mdev, vram_available);
42 	if (ret)
43 		return ERR_PTR(ret);
44 
45 	return mdev;
46 }
47