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_g200eh3_device_info =
14 	MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, false, 1, 0, false);
15 
16 struct mga_device *mgag200_g200eh3_device_create(struct pci_dev *pdev,
17 						 const struct drm_driver *drv,
18 						 enum mga_type type)
19 {
20 	struct mga_device *mdev;
21 	struct drm_device *dev;
22 	resource_size_t vram_available;
23 	int ret;
24 
25 	mdev = devm_drm_dev_alloc(&pdev->dev, drv, struct mga_device, base);
26 	if (IS_ERR(mdev))
27 		return mdev;
28 	dev = &mdev->base;
29 
30 	pci_set_drvdata(pdev, dev);
31 
32 	ret = mgag200_init_pci_options(pdev, 0x00000120, 0x0000b000);
33 	if (ret)
34 		return ERR_PTR(ret);
35 
36 	ret = mgag200_device_preinit(mdev);
37 	if (ret)
38 		return ERR_PTR(ret);
39 
40 	ret = mgag200_device_init(mdev, type, &mgag200_g200eh3_device_info);
41 	if (ret)
42 		return ERR_PTR(ret);
43 
44 	vram_available = mgag200_device_probe_vram(mdev);
45 
46 	ret = mgag200_modeset_init(mdev, vram_available);
47 	if (ret)
48 		return ERR_PTR(ret);
49 
50 	return mdev;
51 }
52