Lines Matching +full:pre +full:- +full:its

1 // SPDX-License-Identifier: GPL-2.0-only
6 * Copyright (C) 2010-2012 Andreas Heider <andreas@meetr.de>
19 #include <linux/apple-gmux.h>
30 * A `Lattice XP2`_ on pre-retinas, a `Renesas R4F2113`_ on retinas.
33 * dual GPUs but no built-in display.)
35 * gmux is connected to the LPC bus of the southbridge. Its I/O ports are
37 * to access a pre-retina gmux are infixed ``_pio_``, those for a retina gmux
103 return inb(gmux_data->iostart + port); in gmux_pio_read8()
109 outb(val, gmux_data->iostart + port); in gmux_pio_write8()
114 return inl(gmux_data->iostart + port); in gmux_pio_read32()
125 outb(tmpval, gmux_data->iostart + port + i); in gmux_pio_write32()
132 u8 gwr = inb(gmux_data->iostart + GMUX_PORT_WRITE); in gmux_index_wait_ready()
135 inb(gmux_data->iostart + GMUX_PORT_READ); in gmux_index_wait_ready()
136 gwr = inb(gmux_data->iostart + GMUX_PORT_WRITE); in gmux_index_wait_ready()
138 i--; in gmux_index_wait_ready()
147 u8 gwr = inb(gmux_data->iostart + GMUX_PORT_WRITE); in gmux_index_wait_complete()
150 gwr = inb(gmux_data->iostart + GMUX_PORT_WRITE); in gmux_index_wait_complete()
152 i--; in gmux_index_wait_complete()
156 inb(gmux_data->iostart + GMUX_PORT_READ); in gmux_index_wait_complete()
165 mutex_lock(&gmux_data->index_lock); in gmux_index_read8()
167 outb((port & 0xff), gmux_data->iostart + GMUX_PORT_READ); in gmux_index_read8()
169 val = inb(gmux_data->iostart + GMUX_PORT_VALUE); in gmux_index_read8()
170 mutex_unlock(&gmux_data->index_lock); in gmux_index_read8()
178 mutex_lock(&gmux_data->index_lock); in gmux_index_write8()
179 outb(val, gmux_data->iostart + GMUX_PORT_VALUE); in gmux_index_write8()
181 outb(port & 0xff, gmux_data->iostart + GMUX_PORT_WRITE); in gmux_index_write8()
183 mutex_unlock(&gmux_data->index_lock); in gmux_index_write8()
190 mutex_lock(&gmux_data->index_lock); in gmux_index_read32()
192 outb((port & 0xff), gmux_data->iostart + GMUX_PORT_READ); in gmux_index_read32()
194 val = inl(gmux_data->iostart + GMUX_PORT_VALUE); in gmux_index_read32()
195 mutex_unlock(&gmux_data->index_lock); in gmux_index_read32()
206 mutex_lock(&gmux_data->index_lock); in gmux_index_write32()
210 outb(tmpval, gmux_data->iostart + GMUX_PORT_VALUE + i); in gmux_index_write32()
214 outb(port & 0xff, gmux_data->iostart + GMUX_PORT_WRITE); in gmux_index_write32()
216 mutex_unlock(&gmux_data->index_lock); in gmux_index_write32()
221 if (gmux_data->indexed) in gmux_read8()
229 if (gmux_data->indexed) in gmux_write8()
237 if (gmux_data->indexed) in gmux_read32()
246 if (gmux_data->indexed) in gmux_write32()
256 outb(0xaa, gmux_data->iostart + 0xcc); in gmux_is_indexed()
257 outb(0x55, gmux_data->iostart + 0xcd); in gmux_is_indexed()
258 outb(0x00, gmux_data->iostart + 0xce); in gmux_is_indexed()
260 val = inb(gmux_data->iostart + 0xcc) | in gmux_is_indexed()
261 (inb(gmux_data->iostart + 0xcd) << 8); in gmux_is_indexed()
309 * On pre-retinas, the LVDS outputs of both GPUs feed into gmux which muxes
310 * either of them to the panel. One of the tricks gmux has up its sleeve is
311 * to lengthen the blanking interval of its output during a switch to
312 * synchronize it with the GPU switched to. This allows for a flicker-free
321 * Pre-retinas are able to switch the panel's DDC pins separately.
328 * in its DPCD, allowing the inactive GPU to skip the AUX handshake and
329 * set up the output with link parameters pre-calibrated by the active GPU.
340 * are still switchable by way of an `NXP CBTL03062`_ (on pre-retinas
343 * external displays appear to it as phantoms which fail to link-train.
367 * variable ``gpu-power-prefs-fa4ce28d-b62f-4c99-9cc3-6815686e30f9`` (5th byte,
372 * .. _US 8,687,007 B2: https://pimg-fpiw.uspto.gov/fdd/07/870/086/0.pdf
378 …* .. _NXP CBTL03062: http://pdf.datasheetarchive.com/indexerfiles/Datasheets-SW16/DSASW00308511.…
385 gmux_data->switch_state_ddc = VGA_SWITCHEROO_IGD; in gmux_read_switch_state()
387 gmux_data->switch_state_ddc = VGA_SWITCHEROO_DIS; in gmux_read_switch_state()
390 gmux_data->switch_state_display = VGA_SWITCHEROO_IGD; in gmux_read_switch_state()
392 gmux_data->switch_state_display = VGA_SWITCHEROO_DIS; in gmux_read_switch_state()
395 gmux_data->switch_state_external = VGA_SWITCHEROO_IGD; in gmux_read_switch_state()
397 gmux_data->switch_state_external = VGA_SWITCHEROO_DIS; in gmux_read_switch_state()
402 if (gmux_data->switch_state_ddc == VGA_SWITCHEROO_IGD) in gmux_write_switch_state()
407 if (gmux_data->switch_state_display == VGA_SWITCHEROO_IGD) in gmux_write_switch_state()
412 if (gmux_data->switch_state_external == VGA_SWITCHEROO_IGD) in gmux_write_switch_state()
420 apple_gmux_data->switch_state_ddc = id; in gmux_switchto()
421 apple_gmux_data->switch_state_display = id; in gmux_switchto()
422 if (apple_gmux_data->external_switchable) in gmux_switchto()
423 apple_gmux_data->switch_state_external = id; in gmux_switchto()
433 apple_gmux_data->switch_state_ddc; in gmux_switch_ddc()
439 apple_gmux_data->switch_state_ddc = id; in gmux_switch_ddc()
460 reinit_completion(&gmux_data->powerchange_done); in gmux_set_discrete_state()
472 gmux_data->power_state = state; in gmux_set_discrete_state()
474 if (gmux_data->gpe >= 0 && in gmux_set_discrete_state()
475 !wait_for_completion_interruptible_timeout(&gmux_data->powerchange_done, in gmux_set_discrete_state()
497 if (pdev->vendor == PCI_VENDOR_ID_INTEL) in gmux_get_client_id()
499 else if (pdev->vendor == PCI_VENDOR_ID_NVIDIA && in gmux_get_client_id()
500 pdev->device == 0x0863) in gmux_get_client_id()
569 complete(&gmux_data->powerchange_done); in gmux_notify_handler()
588 if (gmux_data->power_state == VGA_SWITCHEROO_OFF) in gmux_resume()
589 gmux_set_discrete_state(gmux_data, gmux_data->power_state); in gmux_resume()
595 return to_pci_dev(dev)->is_thunderbolt; in is_thunderbolt()
605 int ret = -ENXIO; in gmux_probe()
610 return -EBUSY; in gmux_probe()
614 return -ENOMEM; in gmux_probe()
623 gmux_data->iostart = res->start; in gmux_probe()
624 gmux_data->iolen = resource_size(res); in gmux_probe()
626 if (gmux_data->iolen < GMUX_MIN_IO_LEN) { in gmux_probe()
628 gmux_data->iolen, GMUX_MIN_IO_LEN); in gmux_probe()
632 if (!request_region(gmux_data->iostart, gmux_data->iolen, in gmux_probe()
650 mutex_init(&gmux_data->index_lock); in gmux_probe()
651 gmux_data->indexed = true; in gmux_probe()
659 ret = -ENODEV; in gmux_probe()
664 ver_release, (gmux_data->indexed ? "indexed" : "classic")); in gmux_probe()
679 bdev = backlight_device_register("gmux_backlight", &pnp->dev, in gmux_probe()
686 gmux_data->bdev = bdev; in gmux_probe()
687 bdev->props.brightness = gmux_get_brightness(bdev); in gmux_probe()
698 gmux_data->power_state = VGA_SWITCHEROO_ON; in gmux_probe()
700 gmux_data->dhandle = ACPI_HANDLE(&pnp->dev); in gmux_probe()
701 if (!gmux_data->dhandle) { in gmux_probe()
703 dev_name(&pnp->dev)); in gmux_probe()
704 ret = -ENODEV; in gmux_probe()
708 status = acpi_evaluate_integer(gmux_data->dhandle, "GMGP", NULL, &gpe); in gmux_probe()
710 gmux_data->gpe = (int)gpe; in gmux_probe()
712 status = acpi_install_notify_handler(gmux_data->dhandle, in gmux_probe()
718 ret = -ENODEV; in gmux_probe()
722 status = acpi_enable_gpe(NULL, gmux_data->gpe); in gmux_probe()
730 gmux_data->gpe = -1; in gmux_probe()
735 * switchable. Force its AUX channel to the discrete GPU. in gmux_probe()
737 gmux_data->external_switchable = in gmux_probe()
739 if (!gmux_data->external_switchable) in gmux_probe()
743 init_completion(&gmux_data->powerchange_done); in gmux_probe()
749 * and need eDP pre-calibration. They are distinguishable from in gmux_probe()
750 * pre-retinas by having an "indexed" gmux. in gmux_probe()
752 * Pre-retina MacBook Pros can switch the panel's DDC separately. in gmux_probe()
754 if (gmux_data->indexed) in gmux_probe()
770 if (gmux_data->gpe >= 0) in gmux_probe()
771 acpi_disable_gpe(NULL, gmux_data->gpe); in gmux_probe()
773 if (gmux_data->gpe >= 0) in gmux_probe()
774 acpi_remove_notify_handler(gmux_data->dhandle, in gmux_probe()
780 release_region(gmux_data->iostart, gmux_data->iolen); in gmux_probe()
792 if (gmux_data->gpe >= 0) { in gmux_remove()
793 acpi_disable_gpe(NULL, gmux_data->gpe); in gmux_remove()
794 acpi_remove_notify_handler(gmux_data->dhandle, in gmux_remove()
799 backlight_device_unregister(gmux_data->bdev); in gmux_remove()
801 release_region(gmux_data->iostart, gmux_data->iolen); in gmux_remove()
819 .name = "apple-gmux",