1254885Sdumbbell/**
2254885Sdumbbell * \file radeon_drv.c
3254885Sdumbbell * ATI Radeon driver
4254885Sdumbbell *
5254885Sdumbbell * \author Gareth Hughes <gareth@valinux.com>
6254885Sdumbbell */
7254885Sdumbbell
8254885Sdumbbell/*
9254885Sdumbbell * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
10254885Sdumbbell * All Rights Reserved.
11254885Sdumbbell *
12254885Sdumbbell * Permission is hereby granted, free of charge, to any person obtaining a
13254885Sdumbbell * copy of this software and associated documentation files (the "Software"),
14254885Sdumbbell * to deal in the Software without restriction, including without limitation
15254885Sdumbbell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16254885Sdumbbell * and/or sell copies of the Software, and to permit persons to whom the
17254885Sdumbbell * Software is furnished to do so, subject to the following conditions:
18254885Sdumbbell *
19254885Sdumbbell * The above copyright notice and this permission notice (including the next
20254885Sdumbbell * paragraph) shall be included in all copies or substantial portions of the
21254885Sdumbbell * Software.
22254885Sdumbbell *
23254885Sdumbbell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24254885Sdumbbell * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25254885Sdumbbell * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
26254885Sdumbbell * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
27254885Sdumbbell * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
28254885Sdumbbell * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29254885Sdumbbell * OTHER DEALINGS IN THE SOFTWARE.
30254885Sdumbbell */
31254885Sdumbbell
32254885Sdumbbell#include <sys/cdefs.h>
33254885Sdumbbell__FBSDID("$FreeBSD: stable/10/sys/dev/drm2/radeon/radeon_drv.c 317903 2017-05-07 11:11:51Z nyan $");
34254885Sdumbbell
35254885Sdumbbell#include <dev/drm2/drmP.h>
36254885Sdumbbell#include <dev/drm2/radeon/radeon_drm.h>
37254885Sdumbbell#include "radeon_drv.h"
38254885Sdumbbell#include "radeon_gem.h"
39254885Sdumbbell#include "radeon_kms.h"
40254885Sdumbbell#include "radeon_irq_kms.h"
41254885Sdumbbell
42254885Sdumbbell#include <dev/drm2/drm_pciids.h>
43254885Sdumbbell
44262861Sjhb#include "fb_if.h"
45254885Sdumbbell
46254885Sdumbbell/*
47254885Sdumbbell * KMS wrapper.
48254885Sdumbbell * - 2.0.0 - initial interface
49254885Sdumbbell * - 2.1.0 - add square tiling interface
50254885Sdumbbell * - 2.2.0 - add r6xx/r7xx const buffer support
51254885Sdumbbell * - 2.3.0 - add MSPOS + 3D texture + r500 VAP regs
52254885Sdumbbell * - 2.4.0 - add crtc id query
53254885Sdumbbell * - 2.5.0 - add get accel 2 to work around ddx breakage for evergreen
54254885Sdumbbell * - 2.6.0 - add tiling config query (r6xx+), add initial HiZ support (r300->r500)
55254885Sdumbbell *   2.7.0 - fixups for r600 2D tiling support. (no external ABI change), add eg dyn gpr regs
56254885Sdumbbell *   2.8.0 - pageflip support, r500 US_FORMAT regs. r500 ARGB2101010 colorbuf, r300->r500 CMASK, clock crystal query
57254885Sdumbbell *   2.9.0 - r600 tiling (s3tc,rgtc) working, SET_PREDICATION packet 3 on r600 + eg, backend query
58254885Sdumbbell *   2.10.0 - fusion 2D tiling
59254885Sdumbbell *   2.11.0 - backend map, initial compute support for the CS checker
60254885Sdumbbell *   2.12.0 - RADEON_CS_KEEP_TILING_FLAGS
61254885Sdumbbell *   2.13.0 - virtual memory support, streamout
62254885Sdumbbell *   2.14.0 - add evergreen tiling informations
63254885Sdumbbell *   2.15.0 - add max_pipes query
64254885Sdumbbell *   2.16.0 - fix evergreen 2D tiled surface calculation
65254885Sdumbbell *   2.17.0 - add STRMOUT_BASE_UPDATE for r7xx
66254885Sdumbbell *   2.18.0 - r600-eg: allow "invalid" DB formats
67254885Sdumbbell *   2.19.0 - r600-eg: MSAA textures
68254885Sdumbbell *   2.20.0 - r600-si: RADEON_INFO_TIMESTAMP query
69254885Sdumbbell *   2.21.0 - r600-r700: FMASK and CMASK
70254885Sdumbbell *   2.22.0 - r600 only: RESOLVE_BOX allowed
71254885Sdumbbell *   2.23.0 - allow STRMOUT_BASE_UPDATE on RS780 and RS880
72254885Sdumbbell *   2.24.0 - eg only: allow MIP_ADDRESS=0 for MSAA textures
73254885Sdumbbell *   2.25.0 - eg+: new info request for num SE and num SH
74254885Sdumbbell *   2.26.0 - r600-eg: fix htile size computation
75254885Sdumbbell *   2.27.0 - r600-SI: Add CS ioctl support for async DMA
76254885Sdumbbell *   2.28.0 - r600-eg: Add MEM_WRITE packet support
77254885Sdumbbell *   2.29.0 - R500 FP16 color clear registers
78254885Sdumbbell */
79254885Sdumbbell#define KMS_DRIVER_MAJOR	2
80254885Sdumbbell#define KMS_DRIVER_MINOR	29
81254885Sdumbbell#define KMS_DRIVER_PATCHLEVEL	0
82254885Sdumbbellint radeon_suspend_kms(struct drm_device *dev);
83254885Sdumbbellint radeon_resume_kms(struct drm_device *dev);
84254885Sdumbbellextern int radeon_get_crtc_scanoutpos(struct drm_device *dev, int crtc,
85254885Sdumbbell				      int *vpos, int *hpos);
86254885Sdumbbellextern struct drm_ioctl_desc radeon_ioctls_kms[];
87254885Sdumbbellextern int radeon_max_kms_ioctl;
88282199Sdumbbell#ifdef FREEBSD_WIP
89254885Sdumbbellint radeon_mmap(struct file *filp, struct vm_area_struct *vma);
90282199Sdumbbell#endif /* FREEBSD_WIP */
91254885Sdumbbellint radeon_mode_dumb_mmap(struct drm_file *filp,
92254885Sdumbbell			  struct drm_device *dev,
93254885Sdumbbell			  uint32_t handle, uint64_t *offset_p);
94254885Sdumbbellint radeon_mode_dumb_create(struct drm_file *file_priv,
95254885Sdumbbell			    struct drm_device *dev,
96254885Sdumbbell			    struct drm_mode_create_dumb *args);
97254885Sdumbbellint radeon_mode_dumb_destroy(struct drm_file *file_priv,
98254885Sdumbbell			     struct drm_device *dev,
99254885Sdumbbell			     uint32_t handle);
100254885Sdumbbellstruct dma_buf *radeon_gem_prime_export(struct drm_device *dev,
101254885Sdumbbell					struct drm_gem_object *obj,
102254885Sdumbbell					int flags);
103254885Sdumbbellstruct drm_gem_object *radeon_gem_prime_import(struct drm_device *dev,
104254885Sdumbbell					       struct dma_buf *dma_buf);
105254885Sdumbbell
106254885Sdumbbell#if defined(CONFIG_DEBUG_FS)
107254885Sdumbbellint radeon_debugfs_init(struct drm_minor *minor);
108254885Sdumbbellvoid radeon_debugfs_cleanup(struct drm_minor *minor);
109254885Sdumbbell#endif
110254885Sdumbbell
111254885Sdumbbell
112254885Sdumbbellint radeon_no_wb;
113254885Sdumbbellint radeon_modeset = 1;
114254885Sdumbbellint radeon_dynclks = -1;
115254885Sdumbbellint radeon_r4xx_atom = 0;
116254885Sdumbbellint radeon_agpmode = 0;
117254885Sdumbbellint radeon_vram_limit = 0;
118254885Sdumbbellint radeon_gart_size = 512; /* default gart size */
119254885Sdumbbellint radeon_benchmarking = 0;
120254885Sdumbbellint radeon_testing = 0;
121254885Sdumbbellint radeon_connector_table = 0;
122254885Sdumbbellint radeon_tv = 1;
123254885Sdumbbellint radeon_audio = 0;
124254885Sdumbbellint radeon_disp_priority = 0;
125254885Sdumbbellint radeon_hw_i2c = 0;
126254885Sdumbbellint radeon_pcie_gen2 = -1;
127254885Sdumbbellint radeon_msi = -1;
128254885Sdumbbellint radeon_lockup_timeout = 10000;
129254885Sdumbbell
130317903SnyanTUNABLE_INT("drm.radeon.no_wb", &radeon_no_wb);
131254885SdumbbellMODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers");
132254885Sdumbbellmodule_param_named(no_wb, radeon_no_wb, int, 0444);
133254885Sdumbbell
134317903SnyanTUNABLE_INT("drm.radeon.modeset", &radeon_modeset);
135254885SdumbbellMODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
136254885Sdumbbellmodule_param_named(modeset, radeon_modeset, int, 0400);
137254885Sdumbbell
138317903SnyanTUNABLE_INT("drm.radeon.dynclks", &radeon_dynclks);
139254885SdumbbellMODULE_PARM_DESC(dynclks, "Disable/Enable dynamic clocks");
140254885Sdumbbellmodule_param_named(dynclks, radeon_dynclks, int, 0444);
141254885Sdumbbell
142317903SnyanTUNABLE_INT("drm.radeon.r4xx_atom", &radeon_r4xx_atom);
143254885SdumbbellMODULE_PARM_DESC(r4xx_atom, "Enable ATOMBIOS modesetting for R4xx");
144254885Sdumbbellmodule_param_named(r4xx_atom, radeon_r4xx_atom, int, 0444);
145254885Sdumbbell
146317903SnyanTUNABLE_INT("drm.radeon.vramlimit", &radeon_vram_limit);
147254885SdumbbellMODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing");
148254885Sdumbbellmodule_param_named(vramlimit, radeon_vram_limit, int, 0600);
149254885Sdumbbell
150317903SnyanTUNABLE_INT("drm.radeon.agpmode", &radeon_agpmode);
151254885SdumbbellMODULE_PARM_DESC(agpmode, "AGP Mode (-1 == PCI)");
152254885Sdumbbellmodule_param_named(agpmode, radeon_agpmode, int, 0444);
153254885Sdumbbell
154317903SnyanTUNABLE_INT("drm.radeon.gartsize", &radeon_gart_size);
155254885SdumbbellMODULE_PARM_DESC(gartsize, "Size of PCIE/IGP gart to setup in megabytes (32, 64, etc)");
156254885Sdumbbellmodule_param_named(gartsize, radeon_gart_size, int, 0600);
157254885Sdumbbell
158317903SnyanTUNABLE_INT("drm.radeon.benchmark", &radeon_benchmarking);
159254885SdumbbellMODULE_PARM_DESC(benchmark, "Run benchmark");
160254885Sdumbbellmodule_param_named(benchmark, radeon_benchmarking, int, 0444);
161254885Sdumbbell
162317903SnyanTUNABLE_INT("drm.radeon.test", &radeon_testing);
163254885SdumbbellMODULE_PARM_DESC(test, "Run tests");
164254885Sdumbbellmodule_param_named(test, radeon_testing, int, 0444);
165254885Sdumbbell
166317903SnyanTUNABLE_INT("drm.radeon.connector_table", &radeon_connector_table);
167254885SdumbbellMODULE_PARM_DESC(connector_table, "Force connector table");
168254885Sdumbbellmodule_param_named(connector_table, radeon_connector_table, int, 0444);
169254885Sdumbbell
170317903SnyanTUNABLE_INT("drm.radeon.tv", &radeon_tv);
171254885SdumbbellMODULE_PARM_DESC(tv, "TV enable (0 = disable)");
172254885Sdumbbellmodule_param_named(tv, radeon_tv, int, 0444);
173254885Sdumbbell
174317903SnyanTUNABLE_INT("drm.radeon.audio", &radeon_audio);
175254885SdumbbellMODULE_PARM_DESC(audio, "Audio enable (1 = enable)");
176254885Sdumbbellmodule_param_named(audio, radeon_audio, int, 0444);
177254885Sdumbbell
178317903SnyanTUNABLE_INT("drm.radeon.disp_priority", &radeon_disp_priority);
179254885SdumbbellMODULE_PARM_DESC(disp_priority, "Display Priority (0 = auto, 1 = normal, 2 = high)");
180254885Sdumbbellmodule_param_named(disp_priority, radeon_disp_priority, int, 0444);
181254885Sdumbbell
182317903SnyanTUNABLE_INT("drm.radeon.hw_i2c", &radeon_hw_i2c);
183254885SdumbbellMODULE_PARM_DESC(hw_i2c, "hw i2c engine enable (0 = disable)");
184254885Sdumbbellmodule_param_named(hw_i2c, radeon_hw_i2c, int, 0444);
185254885Sdumbbell
186317903SnyanTUNABLE_INT("drm.radeon.pcie_gen2", &radeon_pcie_gen2);
187254885SdumbbellMODULE_PARM_DESC(pcie_gen2, "PCIE Gen2 mode (-1 = auto, 0 = disable, 1 = enable)");
188254885Sdumbbellmodule_param_named(pcie_gen2, radeon_pcie_gen2, int, 0444);
189254885Sdumbbell
190317903SnyanTUNABLE_INT("drm.radeon.msi", &radeon_msi);
191254885SdumbbellMODULE_PARM_DESC(msi, "MSI support (1 = enable, 0 = disable, -1 = auto)");
192254885Sdumbbellmodule_param_named(msi, radeon_msi, int, 0444);
193254885Sdumbbell
194317903SnyanTUNABLE_INT("drm.radeon.lockup_timeout", &radeon_lockup_timeout);
195254885SdumbbellMODULE_PARM_DESC(lockup_timeout, "GPU lockup timeout in ms (defaul 10000 = 10 seconds, 0 = disable)");
196254885Sdumbbellmodule_param_named(lockup_timeout, radeon_lockup_timeout, int, 0444);
197254885Sdumbbell
198254885Sdumbbellstatic drm_pci_id_list_t pciidlist[] = {
199254885Sdumbbell	radeon_PCI_IDS
200254885Sdumbbell};
201254885Sdumbbell
202282199Sdumbbellstatic struct drm_driver kms_driver;
203254885Sdumbbell
204259303Srmhstatic int radeon_sysctl_init(struct drm_device *dev, struct sysctl_ctx_list *ctx,
205259303Srmh			      struct sysctl_oid *top)
206259303Srmh{
207259303Srmh	return drm_add_busid_modesetting(dev, ctx, top);
208259303Srmh}
209259303Srmh
210282199Sdumbbellstatic struct drm_driver kms_driver = {
211254885Sdumbbell	.driver_features =
212254885Sdumbbell	    DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG |
213254885Sdumbbell	    DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED | DRIVER_GEM |
214282199Sdumbbell	    DRIVER_PRIME,
215282199Sdumbbell#ifdef FREEBSD_WIP
216254885Sdumbbell	.dev_priv_size = 0,
217282199Sdumbbell#endif /* FREEBSD_WIP */
218254885Sdumbbell	.load = radeon_driver_load_kms,
219254885Sdumbbell	.firstopen = radeon_driver_firstopen_kms,
220254885Sdumbbell	.open = radeon_driver_open_kms,
221254885Sdumbbell	.preclose = radeon_driver_preclose_kms,
222254885Sdumbbell	.postclose = radeon_driver_postclose_kms,
223254885Sdumbbell	.lastclose = radeon_driver_lastclose_kms,
224254885Sdumbbell	.unload = radeon_driver_unload_kms,
225282199Sdumbbell#ifdef FREEBSD_WIP
226254885Sdumbbell	.suspend = radeon_suspend_kms,
227254885Sdumbbell	.resume = radeon_resume_kms,
228282199Sdumbbell#endif /* FREEBSD_WIP */
229254885Sdumbbell	.get_vblank_counter = radeon_get_vblank_counter_kms,
230254885Sdumbbell	.enable_vblank = radeon_enable_vblank_kms,
231254885Sdumbbell	.disable_vblank = radeon_disable_vblank_kms,
232254885Sdumbbell	.get_vblank_timestamp = radeon_get_vblank_timestamp_kms,
233254885Sdumbbell	.get_scanout_position = radeon_get_crtc_scanoutpos,
234282199Sdumbbell#if defined(CONFIG_DEBUG_FS)
235282199Sdumbbell	.debugfs_init = radeon_debugfs_init,
236282199Sdumbbell	.debugfs_cleanup = radeon_debugfs_cleanup,
237282199Sdumbbell#endif
238254885Sdumbbell	.irq_preinstall = radeon_driver_irq_preinstall_kms,
239254885Sdumbbell	.irq_postinstall = radeon_driver_irq_postinstall_kms,
240254885Sdumbbell	.irq_uninstall = radeon_driver_irq_uninstall_kms,
241254885Sdumbbell	.irq_handler = radeon_driver_irq_handler_kms,
242259303Srmh	.sysctl_init = radeon_sysctl_init,
243254885Sdumbbell	.ioctls = radeon_ioctls_kms,
244254885Sdumbbell	.gem_init_object = radeon_gem_object_init,
245254885Sdumbbell	.gem_free_object = radeon_gem_object_free,
246254885Sdumbbell	.gem_open_object = radeon_gem_object_open,
247254885Sdumbbell	.gem_close_object = radeon_gem_object_close,
248254885Sdumbbell	.dma_ioctl = radeon_dma_ioctl_kms,
249254885Sdumbbell	.dumb_create = radeon_mode_dumb_create,
250254885Sdumbbell	.dumb_map_offset = radeon_mode_dumb_mmap,
251254885Sdumbbell	.dumb_destroy = radeon_mode_dumb_destroy,
252282199Sdumbbell#ifdef FREEBSD_WIP
253254885Sdumbbell	.fops = &radeon_driver_kms_fops,
254282199Sdumbbell#endif /* FREEBSD_WIP */
255254885Sdumbbell
256282199Sdumbbell#ifdef FREEBSD_WIP
257254885Sdumbbell	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
258254885Sdumbbell	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
259254885Sdumbbell	.gem_prime_export = radeon_gem_prime_export,
260254885Sdumbbell	.gem_prime_import = radeon_gem_prime_import,
261282199Sdumbbell#endif /* FREEBSD_WIP */
262254885Sdumbbell
263254885Sdumbbell	.name = DRIVER_NAME,
264254885Sdumbbell	.desc = DRIVER_DESC,
265254885Sdumbbell	.date = DRIVER_DATE,
266254885Sdumbbell	.major = KMS_DRIVER_MAJOR,
267254885Sdumbbell	.minor = KMS_DRIVER_MINOR,
268254885Sdumbbell	.patchlevel = KMS_DRIVER_PATCHLEVEL,
269254885Sdumbbell};
270254885Sdumbbell
271282199Sdumbbell#ifdef FREEBSD_WIP
272254885Sdumbbellstatic int __init radeon_init(void)
273254885Sdumbbell{
274254885Sdumbbell	driver = &driver_old;
275254885Sdumbbell	pdriver = &radeon_pci_driver;
276254885Sdumbbell	driver->num_ioctls = radeon_max_ioctl;
277254885Sdumbbell#ifdef CONFIG_VGA_CONSOLE
278254885Sdumbbell	if (vgacon_text_force() && radeon_modeset == -1) {
279254885Sdumbbell		DRM_INFO("VGACON disable radeon kernel modesetting.\n");
280254885Sdumbbell		driver = &driver_old;
281254885Sdumbbell		pdriver = &radeon_pci_driver;
282254885Sdumbbell		driver->driver_features &= ~DRIVER_MODESET;
283254885Sdumbbell		radeon_modeset = 0;
284254885Sdumbbell	}
285254885Sdumbbell#endif
286254885Sdumbbell	/* if enabled by default */
287254885Sdumbbell	if (radeon_modeset == -1) {
288254885Sdumbbell#ifdef CONFIG_DRM_RADEON_KMS
289254885Sdumbbell		DRM_INFO("radeon defaulting to kernel modesetting.\n");
290254885Sdumbbell		radeon_modeset = 1;
291254885Sdumbbell#else
292254885Sdumbbell		DRM_INFO("radeon defaulting to userspace modesetting.\n");
293254885Sdumbbell		radeon_modeset = 0;
294254885Sdumbbell#endif
295254885Sdumbbell	}
296254885Sdumbbell	if (radeon_modeset == 1) {
297254885Sdumbbell		DRM_INFO("radeon kernel modesetting enabled.\n");
298254885Sdumbbell		driver = &kms_driver;
299254885Sdumbbell		pdriver = &radeon_kms_pci_driver;
300254885Sdumbbell		driver->driver_features |= DRIVER_MODESET;
301254885Sdumbbell		driver->num_ioctls = radeon_max_kms_ioctl;
302254885Sdumbbell		radeon_register_atpx_handler();
303254885Sdumbbell	}
304254885Sdumbbell	/* if the vga console setting is enabled still
305254885Sdumbbell	 * let modprobe override it */
306254885Sdumbbell	return drm_pci_init(driver, pdriver);
307254885Sdumbbell}
308254885Sdumbbell
309254885Sdumbbellstatic void __exit radeon_exit(void)
310254885Sdumbbell{
311254885Sdumbbell	drm_pci_exit(driver, pdriver);
312254885Sdumbbell	radeon_unregister_atpx_handler();
313254885Sdumbbell}
314282199Sdumbbell#endif /* FREEBSD_WIP */
315254885Sdumbbell
316254885Sdumbbell/* =================================================================== */
317254885Sdumbbell
318254885Sdumbbellstatic int
319254885Sdumbbellradeon_probe(device_t kdev)
320254885Sdumbbell{
321254885Sdumbbell
322282199Sdumbbell	return (-drm_probe_helper(kdev, pciidlist));
323254885Sdumbbell}
324254885Sdumbbell
325254885Sdumbbellstatic int
326254885Sdumbbellradeon_attach(device_t kdev)
327254885Sdumbbell{
328254885Sdumbbell
329254885Sdumbbell	if (radeon_modeset == 1) {
330254885Sdumbbell		kms_driver.driver_features |= DRIVER_MODESET;
331282199Sdumbbell		kms_driver.num_ioctls = radeon_max_kms_ioctl;
332266594Sdumbbell#ifdef COMPAT_FREEBSD32
333266594Sdumbbell		kms_driver.compat_ioctls = radeon_compat_ioctls;
334282199Sdumbbell		kms_driver.num_compat_ioctls = &radeon_num_compat_ioctls;
335266594Sdumbbell#endif
336254885Sdumbbell		radeon_register_atpx_handler();
337254885Sdumbbell	}
338282199Sdumbbell	return (-drm_attach_helper(kdev, pciidlist, &kms_driver));
339254885Sdumbbell}
340254885Sdumbbell
341254885Sdumbbellstatic int
342254885Sdumbbellradeon_suspend(device_t kdev)
343254885Sdumbbell{
344254885Sdumbbell	struct drm_device *dev;
345254885Sdumbbell	int ret;
346254885Sdumbbell
347254885Sdumbbell	dev = device_get_softc(kdev);
348254885Sdumbbell	ret = radeon_suspend_kms(dev);
349282199Sdumbbell	if (ret)
350282199Sdumbbell		return (-ret);
351254885Sdumbbell
352282199Sdumbbell	ret = bus_generic_suspend(kdev);
353282199Sdumbbell
354282199Sdumbbell	return (ret);
355254885Sdumbbell}
356254885Sdumbbell
357254885Sdumbbellstatic int
358254885Sdumbbellradeon_resume(device_t kdev)
359254885Sdumbbell{
360254885Sdumbbell	struct drm_device *dev;
361254885Sdumbbell	int ret;
362254885Sdumbbell
363254885Sdumbbell	dev = device_get_softc(kdev);
364254885Sdumbbell	ret = radeon_resume_kms(dev);
365282199Sdumbbell	if (ret)
366282199Sdumbbell		return (-ret);
367254885Sdumbbell
368282199Sdumbbell	ret = bus_generic_resume(kdev);
369282199Sdumbbell
370282199Sdumbbell	return (ret);
371254885Sdumbbell}
372254885Sdumbbell
373262861Sjhbextern struct fb_info *	radeon_fb_helper_getinfo(device_t kdev);
374262861Sjhb
375254885Sdumbbellstatic device_method_t radeon_methods[] = {
376254885Sdumbbell	/* Device interface */
377254885Sdumbbell	DEVMETHOD(device_probe,		radeon_probe),
378254885Sdumbbell	DEVMETHOD(device_attach,	radeon_attach),
379254885Sdumbbell	DEVMETHOD(device_suspend,	radeon_suspend),
380254885Sdumbbell	DEVMETHOD(device_resume,	radeon_resume),
381282199Sdumbbell	DEVMETHOD(device_detach,	drm_generic_detach),
382262861Sjhb
383262861Sjhb	/* Framebuffer service methods */
384262861Sjhb	DEVMETHOD(fb_getinfo,		radeon_fb_helper_getinfo),
385262861Sjhb
386254885Sdumbbell	DEVMETHOD_END
387254885Sdumbbell};
388254885Sdumbbell
389254885Sdumbbellstatic driver_t radeon_driver = {
390254885Sdumbbell	"drmn",
391254885Sdumbbell	radeon_methods,
392254885Sdumbbell	sizeof(struct drm_device)
393254885Sdumbbell};
394254885Sdumbbell
395254885Sdumbbellextern devclass_t drm_devclass;
396254885SdumbbellDRIVER_MODULE_ORDERED(radeonkms, vgapci, radeon_driver, drm_devclass,
397254885Sdumbbell    NULL, NULL, SI_ORDER_ANY);
398254885SdumbbellMODULE_DEPEND(radeonkms, drmn, 1, 1, 1);
399254885SdumbbellMODULE_DEPEND(radeonkms, agp, 1, 1, 1);
400254885SdumbbellMODULE_DEPEND(radeonkms, iicbus, 1, 1, 1);
401254885SdumbbellMODULE_DEPEND(radeonkms, iic, 1, 1, 1);
402254885SdumbbellMODULE_DEPEND(radeonkms, iicbb, 1, 1, 1);
403257358SdumbbellMODULE_DEPEND(radeonkms, firmware, 1, 1, 1);
404