Lines Matching +full:primary +full:- +full:device
1 // SPDX-License-Identifier: MIT
4 #include <linux/device.h>
19 * A graphics device might be supported by different drivers, but only one
21 * graphics drivers, such as EFI-GOP or VESA, early during the boot process.
23 * hardware-specific driver. To take over the device, the dedicated driver
25 * ownership of framebuffer memory and hand-over between drivers.
30 * An example for a graphics device on the platform bus is shown below.
32 * .. code-block:: c
42 * return -ENODEV;
43 * base = mem->start;
61 * The given example reads the platform device's I/O-memory range from the
62 * device instance. An active framebuffer will be located within this range.
66 * the device.
68 * While the given example uses a platform device, the aperture helpers work
70 * device drivers can also call aperture_remove_conflicting_pci_devices() and
71 * let the function detect the apertures automatically. Device drivers without
82 * .. code-block:: c
91 * return -ENODEV;
92 * base = mem->start;
107 * // Hot-unplug the device
129 * Once hot unplugged from hardware, it may not access the device's
134 struct device *dev;
138 void (*detach)(struct device *dev);
153 bool detached = !ap->dev; in devm_aperture_acquire_release()
159 list_del(&ap->lh); in devm_aperture_acquire_release()
163 static int devm_aperture_acquire(struct device *dev, in devm_aperture_acquire()
165 void (*detach)(struct device *)) in devm_aperture_acquire() argument
175 if (overlap(base, end, ap->base, ap->base + ap->size)) { in devm_aperture_acquire()
177 return -EBUSY; in devm_aperture_acquire()
184 return -ENOMEM; in devm_aperture_acquire()
187 ap->dev = dev; in devm_aperture_acquire()
188 ap->base = base; in devm_aperture_acquire()
189 ap->size = size; in devm_aperture_acquire()
190 ap->detach = detach; in devm_aperture_acquire()
191 INIT_LIST_HEAD(&ap->lh); in devm_aperture_acquire()
193 list_add(&ap->lh, &apertures); in devm_aperture_acquire()
200 static void aperture_detach_platform_device(struct device *dev) in aperture_detach_platform_device()
205 * Remove the device from the device hierarchy. This is the right thing in aperture_detach_platform_device()
206 * to do for firmware-based fb drivers, such as EFI, VESA or VGA. After in aperture_detach_platform_device()
207 * the new driver takes over the hardware, the firmware device's state in aperture_detach_platform_device()
210 * For non-platform devices, a new callback would be required. in aperture_detach_platform_device()
213 * would only have to unplug the DRM device, so that the hardware device in aperture_detach_platform_device()
220 * devm_aperture_acquire_for_platform_device - Acquires ownership of an aperture
221 * on behalf of a platform device.
222 * @pdev: the platform device to own the aperture
226 * Installs the given device as the new owner of the aperture. The function
227 * expects the aperture to be provided by a platform device. If another
229 * unregister the platform device automatically. All acquired apertures are
230 * released automatically when the underlying device goes away.
233 * owned by another device. To evict current owners, callers should use
243 return devm_aperture_acquire(&pdev->dev, base, size, aperture_detach_platform_device); in devm_aperture_acquire_for_platform_device()
256 struct device *dev = ap->dev; in aperture_detach_devices()
261 if (!overlap(base, end, ap->base, ap->base + ap->size)) in aperture_detach_devices()
264 ap->dev = NULL; /* detach from device */ in aperture_detach_devices()
265 list_del(&ap->lh); in aperture_detach_devices()
267 ap->detach(dev); in aperture_detach_devices()
274 * aperture_remove_conflicting_devices - remove devices in the given range
288 * If a driver asked to unregister a platform device registered by in aperture_remove_conflicting_devices()
307 * __aperture_remove_legacy_vga_devices - remove legacy VGA devices of a PCI devices
308 * @pdev: PCI device
311 * framebuffer or a console. This is useful if you have a VGA-compatible
312 * PCI graphics device with framebuffers in non-BAR locations. Drivers
342 * aperture_remove_conflicting_pci_devices - remove existing framebuffers for PCI devices
343 * @pdev: PCI device
347 * memory bars. The function assumes that PCI device with shadowed ROM
348 * drives a primary display and therefore kicks out vga16fb as well.
355 bool primary = false; in aperture_remove_conflicting_pci_devices() local
361 primary = true; in aperture_remove_conflicting_pci_devices()
363 if (primary) in aperture_remove_conflicting_pci_devices()
377 * If this is the primary adapter, there could be a VGA device in aperture_remove_conflicting_pci_devices()
379 * device as well. in aperture_remove_conflicting_pci_devices()
381 if (primary) in aperture_remove_conflicting_pci_devices()