xref: /dflybsd-src/sys/dev/drm/drm_memory.c (revision 1dedbd3b06c68f627b7825694444529d5eb2b1bf)
16431cd91SFrançois Tigeot /**
26431cd91SFrançois Tigeot  * \file drm_memory.c
36431cd91SFrançois Tigeot  * Memory management wrappers for DRM
46431cd91SFrançois Tigeot  *
56431cd91SFrançois Tigeot  * \author Rickard E. (Rik) Faith <faith@valinux.com>
66431cd91SFrançois Tigeot  * \author Gareth Hughes <gareth@valinux.com>
76431cd91SFrançois Tigeot  */
86431cd91SFrançois Tigeot 
96431cd91SFrançois Tigeot /*
106431cd91SFrançois Tigeot  * Created: Thu Feb  4 14:00:34 1999 by faith@valinux.com
116431cd91SFrançois Tigeot  *
127f3c3d6fSHasso Tepper  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
137f3c3d6fSHasso Tepper  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
146431cd91SFrançois Tigeot  * All Rights Reserved.
157f3c3d6fSHasso Tepper  *
167f3c3d6fSHasso Tepper  * Permission is hereby granted, free of charge, to any person obtaining a
177f3c3d6fSHasso Tepper  * copy of this software and associated documentation files (the "Software"),
187f3c3d6fSHasso Tepper  * to deal in the Software without restriction, including without limitation
197f3c3d6fSHasso Tepper  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
207f3c3d6fSHasso Tepper  * and/or sell copies of the Software, and to permit persons to whom the
217f3c3d6fSHasso Tepper  * Software is furnished to do so, subject to the following conditions:
227f3c3d6fSHasso Tepper  *
237f3c3d6fSHasso Tepper  * The above copyright notice and this permission notice (including the next
247f3c3d6fSHasso Tepper  * paragraph) shall be included in all copies or substantial portions of the
257f3c3d6fSHasso Tepper  * Software.
267f3c3d6fSHasso Tepper  *
277f3c3d6fSHasso Tepper  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
287f3c3d6fSHasso Tepper  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
297f3c3d6fSHasso Tepper  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
307f3c3d6fSHasso Tepper  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
317f3c3d6fSHasso Tepper  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
327f3c3d6fSHasso Tepper  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
337f3c3d6fSHasso Tepper  * OTHER DEALINGS IN THE SOFTWARE.
347f3c3d6fSHasso Tepper  */
357f3c3d6fSHasso Tepper 
366431cd91SFrançois Tigeot #include <linux/highmem.h>
376431cd91SFrançois Tigeot #include <linux/export.h>
38352ff8bdSFrançois Tigeot #include <linux/kconfig.h>
3918e26a6dSFrançois Tigeot #include <drm/drmP.h>
401b13d190SFrançois Tigeot #include "drm_legacy.h"
411b13d190SFrançois Tigeot 
42352ff8bdSFrançois Tigeot #if IS_ENABLED(CONFIG_AGP)
43e5411345Szrj 
441b13d190SFrançois Tigeot #ifdef HAVE_PAGE_AGP
451b13d190SFrançois Tigeot # include <asm/agp.h>
461b13d190SFrançois Tigeot #else
471b13d190SFrançois Tigeot # ifdef __powerpc__
48*1dedbd3bSFrançois Tigeot #  define PAGE_AGP	pgprot_noncached_wc(PAGE_KERNEL)
491b13d190SFrançois Tigeot # else
501b13d190SFrançois Tigeot #  define PAGE_AGP	PAGE_KERNEL
511b13d190SFrançois Tigeot # endif
521b13d190SFrançois Tigeot #endif
537f3c3d6fSHasso Tepper 
54e5411345Szrj 
55352ff8bdSFrançois Tigeot #else /*  CONFIG_AGP  */
56352ff8bdSFrançois Tigeot #endif /* CONFIG_AGP */
57e5411345Szrj 
drm_legacy_ioremap(struct drm_local_map * map,struct drm_device * dev)586431cd91SFrançois Tigeot void drm_legacy_ioremap(struct drm_local_map *map, struct drm_device *dev)
597f3c3d6fSHasso Tepper {
606431cd91SFrançois Tigeot 	map->handle = ioremap(map->offset, map->size);
617f3c3d6fSHasso Tepper }
626431cd91SFrançois Tigeot EXPORT_SYMBOL(drm_legacy_ioremap);
637f3c3d6fSHasso Tepper 
drm_legacy_ioremap_wc(struct drm_local_map * map,struct drm_device * dev)646431cd91SFrançois Tigeot void drm_legacy_ioremap_wc(struct drm_local_map *map, struct drm_device *dev)
657f3c3d6fSHasso Tepper {
666431cd91SFrançois Tigeot 	map->handle = ioremap_wc(map->offset, map->size);
677f3c3d6fSHasso Tepper }
686431cd91SFrançois Tigeot EXPORT_SYMBOL(drm_legacy_ioremap_wc);
697f3c3d6fSHasso Tepper 
drm_legacy_ioremapfree(struct drm_local_map * map,struct drm_device * dev)706431cd91SFrançois Tigeot void drm_legacy_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
717f3c3d6fSHasso Tepper {
726431cd91SFrançois Tigeot 	if (!map->handle || !map->size)
736431cd91SFrançois Tigeot 		return;
74b3705d71SHasso Tepper 
755c002123SFrançois Tigeot 	pmap_unmapdev((vm_offset_t) map->handle, map->size);
767f3c3d6fSHasso Tepper }
776431cd91SFrançois Tigeot EXPORT_SYMBOL(drm_legacy_ioremapfree);
78