platform/x86: apple-gmux: support MMIO gmux on T2 Macs
authorOrlando Chamberlain <orlandoch.dev@gmail.com>
Fri, 3 Mar 2023 11:28:42 +0000 (22:28 +1100)
committerHans de Goede <hdegoede@redhat.com>
Thu, 16 Mar 2023 10:02:00 +0000 (11:02 +0100)
commit0c18184de990e63f708b090bcb9fc6c0fbc427cd
tree30730464c461c77af941c3d4c6aef9fad9dd86c6
parent96ec2d9868c4afd3cea17f4ee18b84ccc1cde20f
platform/x86: apple-gmux: support MMIO gmux on T2 Macs

In some newer dual gpu MacBooks, the T2 Coprocessor functions as the
gmux, and the Intel side can interract with this new gmux type through
MMIO. Add support for these gmux controllers to the apple-gmux driver.

We start using the GMSP(0) acpi method on these gmux's when clearing
interrupts, as this prevents a flood of status=0 interrupts that can't
be cleared. It's unknown if this helps or hinders older gmux types, so
it isn't enabled for those.

Interestingly, the ACPI table only allocates 8 bytes for GMUX, but we
actually need 16, and as such we request 16 with request_mem_region.

Reading and writing from ports:
    16 bytes from 0xfe0b0200 are used. 0x0 to 0x4 are where data
    to read appears, and where data to write goes. Writing to 0xe
    sets the gmux port being accessed, and writing to 0xf sends commands.

    These commands are 0x40 & data_length for write, and data_length for
    read, where data_length is 1, 2 or 4. Once byte base+0xf is 0, the
    command is done.

Issues:
    As with other retina models, we can't switch DDC lines so
    switching at runtime doesn't work if the inactive gpu driver
    already disabled eDP due to it not being connected when that
    driver loaded.

    Additionally, turning on the dgpu back on on the MacBookPro16,1 does
    not work.

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Orlando Chamberlain <orlandoch.dev@gmail.com>
Link: https://lore.kernel.org/r/20230303112842.3094-4-orlandoch.dev@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/apple-gmux.c
include/linux/apple-gmux.h