xref: /freebsd/sys/compat/linuxkpi/common/include/linux/aperture.h (revision f5f40dd63bc7acbb5312b26ac1ea1103c12352a6)
1 /* SPDX-License-Identifier: MIT */
2 
3 #ifndef _LINUX_APERTURE_H_
4 #define _LINUX_APERTURE_H_
5 
6 #include <linux/types.h>
7 
8 #define	CONFIG_APERTURE_HELPERS
9 
10 struct pci_dev;
11 struct platform_device;
12 
13 #if defined(CONFIG_APERTURE_HELPERS)
14 int devm_aperture_acquire_for_platform_device(struct platform_device *pdev,
15 					      resource_size_t base,
16 					      resource_size_t size);
17 
18 int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t size,
19 					bool primary, const char *name);
20 
21 int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *name);
22 #else
23 static inline int devm_aperture_acquire_for_platform_device(struct platform_device *pdev,
24 							    resource_size_t base,
25 							    resource_size_t size)
26 {
27 	return 0;
28 }
29 
30 static inline int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t size,
31 						      bool primary, const char *name)
32 {
33 	return 0;
34 }
35 
36 static inline int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *name)
37 {
38 	return 0;
39 }
40 #endif
41 
42 /**
43  * aperture_remove_all_conflicting_devices - remove all existing framebuffers
44  * @primary: also kick vga16fb if present; only relevant for VGA devices
45  * @name: a descriptive name of the requesting driver
46  *
47  * This function removes all graphics device drivers. Use this function on systems
48  * that can have their framebuffer located anywhere in memory.
49  *
50  * Returns:
51  * 0 on success, or a negative errno code otherwise
52  */
53 static inline int aperture_remove_all_conflicting_devices(bool primary, const char *name)
54 {
55 	return aperture_remove_conflicting_devices(0, (resource_size_t)-1, primary, name);
56 }
57 
58 #endif
59