xref: /linux/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
14f2a8f58SJoel Stanley // SPDX-License-Identifier: GPL-2.0+
24f2a8f58SJoel Stanley // Copyright 2018 IBM Corporation
34f2a8f58SJoel Stanley 
44f2a8f58SJoel Stanley #include <linux/clk.h>
54f2a8f58SJoel Stanley #include <linux/dma-mapping.h>
64f2a8f58SJoel Stanley #include <linux/irq.h>
74f2a8f58SJoel Stanley #include <linux/mfd/syscon.h>
84f2a8f58SJoel Stanley #include <linux/module.h>
9*e1704914SRob Herring #include <linux/mod_devicetable.h>
104f2a8f58SJoel Stanley #include <linux/of_reserved_mem.h>
114f2a8f58SJoel Stanley #include <linux/platform_device.h>
12*e1704914SRob Herring #include <linux/property.h>
134f2a8f58SJoel Stanley #include <linux/regmap.h>
144f2a8f58SJoel Stanley #include <linux/reset.h>
154f2a8f58SJoel Stanley 
164f2a8f58SJoel Stanley #include <drm/drm_atomic_helper.h>
174f2a8f58SJoel Stanley #include <drm/drm_device.h>
1874e6a79fSThomas Zimmermann #include <drm/drm_fbdev_dma.h>
194a83c26aSDanilo Krummrich #include <drm/drm_gem_dma_helper.h>
204f2a8f58SJoel Stanley #include <drm/drm_gem_framebuffer_helper.h>
2194afe983SJavier Martinez Canillas #include <drm/drm_module.h>
224f2a8f58SJoel Stanley #include <drm/drm_probe_helper.h>
234f2a8f58SJoel Stanley #include <drm/drm_simple_kms_helper.h>
244f2a8f58SJoel Stanley #include <drm/drm_vblank.h>
254f2a8f58SJoel Stanley #include <drm/drm_drv.h>
264f2a8f58SJoel Stanley 
274f2a8f58SJoel Stanley #include "aspeed_gfx.h"
284f2a8f58SJoel Stanley 
294f2a8f58SJoel Stanley /**
304f2a8f58SJoel Stanley  * DOC: ASPEED GFX Driver
314f2a8f58SJoel Stanley  *
324f2a8f58SJoel Stanley  * This driver is for the ASPEED BMC SoC's 'GFX' display hardware, also called
334f2a8f58SJoel Stanley  * the 'SOC Display Controller' in the datasheet. This driver runs on the ARM
344f2a8f58SJoel Stanley  * based BMC systems, unlike the ast driver which runs on a host CPU and is for
354f2a8f58SJoel Stanley  * a PCIe graphics device.
364f2a8f58SJoel Stanley  *
374f2a8f58SJoel Stanley  * The AST2500 supports a total of 3 output paths:
384f2a8f58SJoel Stanley  *
394f2a8f58SJoel Stanley  *   1. VGA output, the output target can choose either or both to the DAC
404f2a8f58SJoel Stanley  *   or DVO interface.
414f2a8f58SJoel Stanley  *
424f2a8f58SJoel Stanley  *   2. Graphics CRT output, the output target can choose either or both to
434f2a8f58SJoel Stanley  *   the DAC or DVO interface.
444f2a8f58SJoel Stanley  *
454f2a8f58SJoel Stanley  *   3. Video input from DVO, the video input can be used for video engine
464f2a8f58SJoel Stanley  *   capture or DAC display output.
474f2a8f58SJoel Stanley  *
484f2a8f58SJoel Stanley  * Output options are selected in SCU2C.
494f2a8f58SJoel Stanley  *
504f2a8f58SJoel Stanley  * The "VGA mode" device is the PCI attached controller. The "Graphics CRT"
514f2a8f58SJoel Stanley  * is the ARM's internal display controller.
524f2a8f58SJoel Stanley  *
534f2a8f58SJoel Stanley  * The driver only supports a simple configuration consisting of a 40MHz
544f2a8f58SJoel Stanley  * pixel clock, fixed by hardware limitations, and the VGA output path.
554f2a8f58SJoel Stanley  *
564f2a8f58SJoel Stanley  * The driver was written with the 'AST2500 Software Programming Guide' v17,
574f2a8f58SJoel Stanley  * which is available under NDA from ASPEED.
584f2a8f58SJoel Stanley  */
594f2a8f58SJoel Stanley 
60bce724faSJoel Stanley struct aspeed_gfx_config {
61bce724faSJoel Stanley 	u32 dac_reg;		/* DAC register in SCU */
625e2421ceSTommy Haung 	u32 int_clear_reg;	/* Interrupt clear register */
63bce724faSJoel Stanley 	u32 vga_scratch_reg;	/* VGA scratch register in SCU */
64bce724faSJoel Stanley 	u32 throd_val;		/* Default Threshold Seting */
65bce724faSJoel Stanley 	u32 scan_line_max;	/* Max memory size of one scan line */
66bce724faSJoel Stanley };
67bce724faSJoel Stanley 
68bce724faSJoel Stanley static const struct aspeed_gfx_config ast2400_config = {
69bce724faSJoel Stanley 	.dac_reg = 0x2c,
705e2421ceSTommy Haung 	.int_clear_reg = 0x60,
71bce724faSJoel Stanley 	.vga_scratch_reg = 0x50,
72bce724faSJoel Stanley 	.throd_val = CRT_THROD_LOW(0x1e) | CRT_THROD_HIGH(0x12),
73bce724faSJoel Stanley 	.scan_line_max = 64,
74bce724faSJoel Stanley };
75bce724faSJoel Stanley 
76bce724faSJoel Stanley static const struct aspeed_gfx_config ast2500_config = {
77bce724faSJoel Stanley 	.dac_reg = 0x2c,
785e2421ceSTommy Haung 	.int_clear_reg = 0x60,
79bce724faSJoel Stanley 	.vga_scratch_reg = 0x50,
80bce724faSJoel Stanley 	.throd_val = CRT_THROD_LOW(0x24) | CRT_THROD_HIGH(0x3c),
81bce724faSJoel Stanley 	.scan_line_max = 128,
82bce724faSJoel Stanley };
83bce724faSJoel Stanley 
84e41d27eaSTommy Haung static const struct aspeed_gfx_config ast2600_config = {
85e41d27eaSTommy Haung 	.dac_reg = 0xc0,
86e41d27eaSTommy Haung 	.int_clear_reg = 0x68,
87e41d27eaSTommy Haung 	.vga_scratch_reg = 0x50,
88e41d27eaSTommy Haung 	.throd_val = CRT_THROD_LOW(0x50) | CRT_THROD_HIGH(0x70),
89e41d27eaSTommy Haung 	.scan_line_max = 128,
90e41d27eaSTommy Haung };
91e41d27eaSTommy Haung 
92bce724faSJoel Stanley static const struct of_device_id aspeed_gfx_match[] = {
93bce724faSJoel Stanley 	{ .compatible = "aspeed,ast2400-gfx", .data = &ast2400_config },
94bce724faSJoel Stanley 	{ .compatible = "aspeed,ast2500-gfx", .data = &ast2500_config },
95e41d27eaSTommy Haung 	{ .compatible = "aspeed,ast2600-gfx", .data = &ast2600_config },
96bce724faSJoel Stanley 	{ },
97bce724faSJoel Stanley };
98bce724faSJoel Stanley MODULE_DEVICE_TABLE(of, aspeed_gfx_match);
99bce724faSJoel Stanley 
1004f2a8f58SJoel Stanley static const struct drm_mode_config_funcs aspeed_gfx_mode_config_funcs = {
1014f2a8f58SJoel Stanley 	.fb_create		= drm_gem_fb_create,
1024f2a8f58SJoel Stanley 	.atomic_check		= drm_atomic_helper_check,
1034f2a8f58SJoel Stanley 	.atomic_commit		= drm_atomic_helper_commit,
1044f2a8f58SJoel Stanley };
1054f2a8f58SJoel Stanley 
aspeed_gfx_setup_mode_config(struct drm_device * drm)106c2c25c1cSDaniel Vetter static int aspeed_gfx_setup_mode_config(struct drm_device *drm)
1074f2a8f58SJoel Stanley {
108c2c25c1cSDaniel Vetter 	int ret;
109c2c25c1cSDaniel Vetter 
110c2c25c1cSDaniel Vetter 	ret = drmm_mode_config_init(drm);
111c2c25c1cSDaniel Vetter 	if (ret)
112c2c25c1cSDaniel Vetter 		return ret;
1134f2a8f58SJoel Stanley 
1144f2a8f58SJoel Stanley 	drm->mode_config.min_width = 0;
1154f2a8f58SJoel Stanley 	drm->mode_config.min_height = 0;
1164f2a8f58SJoel Stanley 	drm->mode_config.max_width = 800;
1174f2a8f58SJoel Stanley 	drm->mode_config.max_height = 600;
1184f2a8f58SJoel Stanley 	drm->mode_config.funcs = &aspeed_gfx_mode_config_funcs;
119c2c25c1cSDaniel Vetter 
120c2c25c1cSDaniel Vetter 	return ret;
1214f2a8f58SJoel Stanley }
1224f2a8f58SJoel Stanley 
aspeed_gfx_irq_handler(int irq,void * data)1234f2a8f58SJoel Stanley static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
1244f2a8f58SJoel Stanley {
1254f2a8f58SJoel Stanley 	struct drm_device *drm = data;
126cd829454SDaniel Vetter 	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
1274f2a8f58SJoel Stanley 	u32 reg;
1284f2a8f58SJoel Stanley 
1294f2a8f58SJoel Stanley 	reg = readl(priv->base + CRT_CTRL1);
1304f2a8f58SJoel Stanley 
1314f2a8f58SJoel Stanley 	if (reg & CRT_CTRL_VERTICAL_INTR_STS) {
1324f2a8f58SJoel Stanley 		drm_crtc_handle_vblank(&priv->pipe.crtc);
1335e2421ceSTommy Haung 		writel(reg, priv->base + priv->int_clr_reg);
1344f2a8f58SJoel Stanley 		return IRQ_HANDLED;
1354f2a8f58SJoel Stanley 	}
1364f2a8f58SJoel Stanley 
1374f2a8f58SJoel Stanley 	return IRQ_NONE;
1384f2a8f58SJoel Stanley }
1394f2a8f58SJoel Stanley 
aspeed_gfx_load(struct drm_device * drm)1404f2a8f58SJoel Stanley static int aspeed_gfx_load(struct drm_device *drm)
1414f2a8f58SJoel Stanley {
1424f2a8f58SJoel Stanley 	struct platform_device *pdev = to_platform_device(drm->dev);
143cd829454SDaniel Vetter 	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
14492614ad5SJoel Stanley 	struct device_node *np = pdev->dev.of_node;
145bce724faSJoel Stanley 	const struct aspeed_gfx_config *config;
1464f2a8f58SJoel Stanley 	struct resource *res;
1474f2a8f58SJoel Stanley 	int ret;
1484f2a8f58SJoel Stanley 
1494f2a8f58SJoel Stanley 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1504f2a8f58SJoel Stanley 	priv->base = devm_ioremap_resource(drm->dev, res);
1514f2a8f58SJoel Stanley 	if (IS_ERR(priv->base))
1524f2a8f58SJoel Stanley 		return PTR_ERR(priv->base);
1534f2a8f58SJoel Stanley 
154*e1704914SRob Herring 	config = device_get_match_data(&pdev->dev);
155*e1704914SRob Herring 	if (!config)
156bce724faSJoel Stanley 		return -EINVAL;
157bce724faSJoel Stanley 
158bce724faSJoel Stanley 	priv->dac_reg = config->dac_reg;
1595e2421ceSTommy Haung 	priv->int_clr_reg = config->int_clear_reg;
160bce724faSJoel Stanley 	priv->vga_scratch_reg = config->vga_scratch_reg;
161bce724faSJoel Stanley 	priv->throd_val = config->throd_val;
162bce724faSJoel Stanley 	priv->scan_line_max = config->scan_line_max;
163bce724faSJoel Stanley 
16492614ad5SJoel Stanley 	priv->scu = syscon_regmap_lookup_by_phandle(np, "syscon");
16592614ad5SJoel Stanley 	if (IS_ERR(priv->scu)) {
1664f2a8f58SJoel Stanley 		priv->scu = syscon_regmap_lookup_by_compatible("aspeed,ast2500-scu");
1674f2a8f58SJoel Stanley 		if (IS_ERR(priv->scu)) {
1684f2a8f58SJoel Stanley 			dev_err(&pdev->dev, "failed to find SCU regmap\n");
1694f2a8f58SJoel Stanley 			return PTR_ERR(priv->scu);
1704f2a8f58SJoel Stanley 		}
17192614ad5SJoel Stanley 	}
1724f2a8f58SJoel Stanley 
1734f2a8f58SJoel Stanley 	ret = of_reserved_mem_device_init(drm->dev);
1744f2a8f58SJoel Stanley 	if (ret) {
1754f2a8f58SJoel Stanley 		dev_err(&pdev->dev,
1764f2a8f58SJoel Stanley 			"failed to initialize reserved mem: %d\n", ret);
1774f2a8f58SJoel Stanley 		return ret;
1784f2a8f58SJoel Stanley 	}
1794f2a8f58SJoel Stanley 
1804f2a8f58SJoel Stanley 	ret = dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32));
1814f2a8f58SJoel Stanley 	if (ret) {
1824f2a8f58SJoel Stanley 		dev_err(&pdev->dev, "failed to set DMA mask: %d\n", ret);
1834f2a8f58SJoel Stanley 		return ret;
1844f2a8f58SJoel Stanley 	}
1854f2a8f58SJoel Stanley 
1864f2a8f58SJoel Stanley 	priv->rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
1874f2a8f58SJoel Stanley 	if (IS_ERR(priv->rst)) {
1884f2a8f58SJoel Stanley 		dev_err(&pdev->dev,
1894f2a8f58SJoel Stanley 			"missing or invalid reset controller device tree entry");
1904f2a8f58SJoel Stanley 		return PTR_ERR(priv->rst);
1914f2a8f58SJoel Stanley 	}
1924f2a8f58SJoel Stanley 	reset_control_deassert(priv->rst);
1934f2a8f58SJoel Stanley 
1944f2a8f58SJoel Stanley 	priv->clk = devm_clk_get(drm->dev, NULL);
1954f2a8f58SJoel Stanley 	if (IS_ERR(priv->clk)) {
1964f2a8f58SJoel Stanley 		dev_err(&pdev->dev,
1974f2a8f58SJoel Stanley 			"missing or invalid clk device tree entry");
1984f2a8f58SJoel Stanley 		return PTR_ERR(priv->clk);
1994f2a8f58SJoel Stanley 	}
2004f2a8f58SJoel Stanley 	clk_prepare_enable(priv->clk);
2014f2a8f58SJoel Stanley 
2024f2a8f58SJoel Stanley 	/* Sanitize control registers */
2034f2a8f58SJoel Stanley 	writel(0, priv->base + CRT_CTRL1);
2044f2a8f58SJoel Stanley 	writel(0, priv->base + CRT_CTRL2);
2054f2a8f58SJoel Stanley 
206c2c25c1cSDaniel Vetter 	ret = aspeed_gfx_setup_mode_config(drm);
207c2c25c1cSDaniel Vetter 	if (ret < 0)
208c2c25c1cSDaniel Vetter 		return ret;
2094f2a8f58SJoel Stanley 
2104f2a8f58SJoel Stanley 	ret = drm_vblank_init(drm, 1);
2114f2a8f58SJoel Stanley 	if (ret < 0) {
2124f2a8f58SJoel Stanley 		dev_err(drm->dev, "Failed to initialise vblank\n");
2134f2a8f58SJoel Stanley 		return ret;
2144f2a8f58SJoel Stanley 	}
2154f2a8f58SJoel Stanley 
2164f2a8f58SJoel Stanley 	ret = aspeed_gfx_create_output(drm);
2174f2a8f58SJoel Stanley 	if (ret < 0) {
2184f2a8f58SJoel Stanley 		dev_err(drm->dev, "Failed to create outputs\n");
2194f2a8f58SJoel Stanley 		return ret;
2204f2a8f58SJoel Stanley 	}
2214f2a8f58SJoel Stanley 
2224f2a8f58SJoel Stanley 	ret = aspeed_gfx_create_pipe(drm);
2234f2a8f58SJoel Stanley 	if (ret < 0) {
2244f2a8f58SJoel Stanley 		dev_err(drm->dev, "Cannot setup simple display pipe\n");
2254f2a8f58SJoel Stanley 		return ret;
2264f2a8f58SJoel Stanley 	}
2274f2a8f58SJoel Stanley 
2284f2a8f58SJoel Stanley 	ret = devm_request_irq(drm->dev, platform_get_irq(pdev, 0),
2294f2a8f58SJoel Stanley 			       aspeed_gfx_irq_handler, 0, "aspeed gfx", drm);
2304f2a8f58SJoel Stanley 	if (ret < 0) {
2314f2a8f58SJoel Stanley 		dev_err(drm->dev, "Failed to install IRQ handler\n");
2324f2a8f58SJoel Stanley 		return ret;
2334f2a8f58SJoel Stanley 	}
2344f2a8f58SJoel Stanley 
2354f2a8f58SJoel Stanley 	drm_mode_config_reset(drm);
2364f2a8f58SJoel Stanley 
2374f2a8f58SJoel Stanley 	return 0;
2384f2a8f58SJoel Stanley }
2394f2a8f58SJoel Stanley 
aspeed_gfx_unload(struct drm_device * drm)2404f2a8f58SJoel Stanley static void aspeed_gfx_unload(struct drm_device *drm)
2414f2a8f58SJoel Stanley {
2424f2a8f58SJoel Stanley 	drm_kms_helper_poll_fini(drm);
2434f2a8f58SJoel Stanley }
2444f2a8f58SJoel Stanley 
2454a83c26aSDanilo Krummrich DEFINE_DRM_GEM_DMA_FOPS(fops);
2464f2a8f58SJoel Stanley 
24770a59dd8SDaniel Vetter static const struct drm_driver aspeed_gfx_driver = {
2480424fdafSDaniel Vetter 	.driver_features        = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
2494a83c26aSDanilo Krummrich 	DRM_GEM_DMA_DRIVER_OPS,
2504f2a8f58SJoel Stanley 	.fops = &fops,
2514f2a8f58SJoel Stanley 	.name = "aspeed-gfx-drm",
2524f2a8f58SJoel Stanley 	.desc = "ASPEED GFX DRM",
2534f2a8f58SJoel Stanley 	.date = "20180319",
2544f2a8f58SJoel Stanley 	.major = 1,
2554f2a8f58SJoel Stanley 	.minor = 0,
2564f2a8f58SJoel Stanley };
2574f2a8f58SJoel Stanley 
dac_mux_store(struct device * dev,struct device_attribute * attr,const char * buf,size_t count)258696029ebSJoel Stanley static ssize_t dac_mux_store(struct device *dev, struct device_attribute *attr,
259696029ebSJoel Stanley 			     const char *buf, size_t count)
260696029ebSJoel Stanley {
261696029ebSJoel Stanley 	struct aspeed_gfx *priv = dev_get_drvdata(dev);
262696029ebSJoel Stanley 	u32 val;
263696029ebSJoel Stanley 	int rc;
264696029ebSJoel Stanley 
265696029ebSJoel Stanley 	rc = kstrtou32(buf, 0, &val);
266696029ebSJoel Stanley 	if (rc)
267696029ebSJoel Stanley 		return rc;
268696029ebSJoel Stanley 
269696029ebSJoel Stanley 	if (val > 3)
270696029ebSJoel Stanley 		return -EINVAL;
271696029ebSJoel Stanley 
272bce724faSJoel Stanley 	rc = regmap_update_bits(priv->scu, priv->dac_reg, 0x30000, val << 16);
273696029ebSJoel Stanley 	if (rc < 0)
274696029ebSJoel Stanley 		return 0;
275696029ebSJoel Stanley 
276696029ebSJoel Stanley 	return count;
277696029ebSJoel Stanley }
278696029ebSJoel Stanley 
dac_mux_show(struct device * dev,struct device_attribute * attr,char * buf)279696029ebSJoel Stanley static ssize_t dac_mux_show(struct device *dev, struct device_attribute *attr, char *buf)
280696029ebSJoel Stanley {
281696029ebSJoel Stanley 	struct aspeed_gfx *priv = dev_get_drvdata(dev);
282696029ebSJoel Stanley 	u32 reg;
283696029ebSJoel Stanley 	int rc;
284696029ebSJoel Stanley 
285bce724faSJoel Stanley 	rc = regmap_read(priv->scu, priv->dac_reg, &reg);
286696029ebSJoel Stanley 	if (rc)
287696029ebSJoel Stanley 		return rc;
288696029ebSJoel Stanley 
289696029ebSJoel Stanley 	return sprintf(buf, "%u\n", (reg >> 16) & 0x3);
290696029ebSJoel Stanley }
291696029ebSJoel Stanley static DEVICE_ATTR_RW(dac_mux);
292696029ebSJoel Stanley 
293696029ebSJoel Stanley static ssize_t
vga_pw_show(struct device * dev,struct device_attribute * attr,char * buf)294696029ebSJoel Stanley vga_pw_show(struct device *dev, struct device_attribute *attr, char *buf)
295696029ebSJoel Stanley {
296696029ebSJoel Stanley 	struct aspeed_gfx *priv = dev_get_drvdata(dev);
297696029ebSJoel Stanley 	u32 reg;
298696029ebSJoel Stanley 	int rc;
299696029ebSJoel Stanley 
300bce724faSJoel Stanley 	rc = regmap_read(priv->scu, priv->vga_scratch_reg, &reg);
301696029ebSJoel Stanley 	if (rc)
302696029ebSJoel Stanley 		return rc;
303696029ebSJoel Stanley 
304b4a6aaeaSJoel Stanley 	return sprintf(buf, "%u\n", reg);
305696029ebSJoel Stanley }
306696029ebSJoel Stanley static DEVICE_ATTR_RO(vga_pw);
307696029ebSJoel Stanley 
308696029ebSJoel Stanley static struct attribute *aspeed_sysfs_entries[] = {
309696029ebSJoel Stanley 	&dev_attr_vga_pw.attr,
310696029ebSJoel Stanley 	&dev_attr_dac_mux.attr,
311696029ebSJoel Stanley 	NULL,
312696029ebSJoel Stanley };
313696029ebSJoel Stanley 
314696029ebSJoel Stanley static struct attribute_group aspeed_sysfs_attr_group = {
315696029ebSJoel Stanley 	.attrs = aspeed_sysfs_entries,
316696029ebSJoel Stanley };
317696029ebSJoel Stanley 
aspeed_gfx_probe(struct platform_device * pdev)3184f2a8f58SJoel Stanley static int aspeed_gfx_probe(struct platform_device *pdev)
3194f2a8f58SJoel Stanley {
320cd829454SDaniel Vetter 	struct aspeed_gfx *priv;
3214f2a8f58SJoel Stanley 	int ret;
3224f2a8f58SJoel Stanley 
323cd829454SDaniel Vetter 	priv = devm_drm_dev_alloc(&pdev->dev, &aspeed_gfx_driver,
324cd829454SDaniel Vetter 				  struct aspeed_gfx, drm);
325cd829454SDaniel Vetter 	if (IS_ERR(priv))
326cd829454SDaniel Vetter 		return PTR_ERR(priv);
3274f2a8f58SJoel Stanley 
328cd829454SDaniel Vetter 	ret = aspeed_gfx_load(&priv->drm);
3294f2a8f58SJoel Stanley 	if (ret)
330cd829454SDaniel Vetter 		return ret;
3314f2a8f58SJoel Stanley 
3325dd331d4SJulia Lawall 	platform_set_drvdata(pdev, priv);
333696029ebSJoel Stanley 
334696029ebSJoel Stanley 	ret = sysfs_create_group(&pdev->dev.kobj, &aspeed_sysfs_attr_group);
335696029ebSJoel Stanley 	if (ret)
336696029ebSJoel Stanley 		return ret;
337696029ebSJoel Stanley 
338cd829454SDaniel Vetter 	ret = drm_dev_register(&priv->drm, 0);
3394f2a8f58SJoel Stanley 	if (ret)
3404f2a8f58SJoel Stanley 		goto err_unload;
3414f2a8f58SJoel Stanley 
34274e6a79fSThomas Zimmermann 	drm_fbdev_dma_setup(&priv->drm, 32);
3434f2a8f58SJoel Stanley 	return 0;
3444f2a8f58SJoel Stanley 
3454f2a8f58SJoel Stanley err_unload:
346696029ebSJoel Stanley 	sysfs_remove_group(&pdev->dev.kobj, &aspeed_sysfs_attr_group);
347cd829454SDaniel Vetter 	aspeed_gfx_unload(&priv->drm);
3484f2a8f58SJoel Stanley 
3494f2a8f58SJoel Stanley 	return ret;
3504f2a8f58SJoel Stanley }
3514f2a8f58SJoel Stanley 
aspeed_gfx_remove(struct platform_device * pdev)3529a32dd32SUwe Kleine-König static void aspeed_gfx_remove(struct platform_device *pdev)
3534f2a8f58SJoel Stanley {
3544f2a8f58SJoel Stanley 	struct drm_device *drm = platform_get_drvdata(pdev);
3554f2a8f58SJoel Stanley 
356696029ebSJoel Stanley 	sysfs_remove_group(&pdev->dev.kobj, &aspeed_sysfs_attr_group);
3574f2a8f58SJoel Stanley 	drm_dev_unregister(drm);
3584f2a8f58SJoel Stanley 	aspeed_gfx_unload(drm);
3593c4babaeSDouglas Anderson 	drm_atomic_helper_shutdown(drm);
3603c4babaeSDouglas Anderson }
3613c4babaeSDouglas Anderson 
aspeed_gfx_shutdown(struct platform_device * pdev)3623c4babaeSDouglas Anderson static void aspeed_gfx_shutdown(struct platform_device *pdev)
3633c4babaeSDouglas Anderson {
3643c4babaeSDouglas Anderson 	drm_atomic_helper_shutdown(platform_get_drvdata(pdev));
3654f2a8f58SJoel Stanley }
3664f2a8f58SJoel Stanley 
3674f2a8f58SJoel Stanley static struct platform_driver aspeed_gfx_platform_driver = {
3684f2a8f58SJoel Stanley 	.probe		= aspeed_gfx_probe,
3699a32dd32SUwe Kleine-König 	.remove_new	= aspeed_gfx_remove,
3703c4babaeSDouglas Anderson 	.shutdown	= aspeed_gfx_shutdown,
3714f2a8f58SJoel Stanley 	.driver = {
3724f2a8f58SJoel Stanley 		.name = "aspeed_gfx",
3734f2a8f58SJoel Stanley 		.of_match_table = aspeed_gfx_match,
3744f2a8f58SJoel Stanley 	},
3754f2a8f58SJoel Stanley };
3764f2a8f58SJoel Stanley 
37794afe983SJavier Martinez Canillas drm_module_platform_driver(aspeed_gfx_platform_driver);
3784f2a8f58SJoel Stanley 
3794f2a8f58SJoel Stanley MODULE_AUTHOR("Joel Stanley <joel@jms.id.au>");
3804f2a8f58SJoel Stanley MODULE_DESCRIPTION("ASPEED BMC DRM/KMS driver");
3814f2a8f58SJoel Stanley MODULE_LICENSE("GPL");
382