/*
 * DF-5582 rig SSDT — a Device under \_SB carrying a GenericSerialBus
 * (SMBU) operation region with I2cSerialBus-connected fields, so the
 * REAL smbacpi.ko GSBUS address-space handler (installed on \_SB.DFS by
 * the rig's fake ig4iic parent) is dispatched through the production
 * ACPICA field machinery (AcpiExReadSerialBus/AcpiExWriteSerialBus ->
 * AcpiEvAddressSpaceDispatch, interpreter EXITED).
 *
 *   \_SB.DFS
 *     _REG(0x0B, 1)   : flags NLFG when the GSBUS handler arrives
 *     SMB0            : GenericSerialBus opregion, offset 0, len 0x100
 *     FLD0 (AttribBytes(16)) : BYTES read  -> SMBUS_TRANS on the fake
 *                               ig4iic (rlen = AccessLength = 16; fits
 *                               buf[32], no stack issue: this field is
 *                               the clean dispatch path for the race)
 *     FLD1 (AttribBlock)     : BLOCK write -> exercises the KNOWN
 *                               DF-1112/DF-2332 buf[32] class (bonus
 *                               confirmation only)
 *     TST0             : read FLD0 (the DF-5582 race vehicle)
 *     TST1             : write 255-byte payload to FLD1 (known class)
 */
DefinitionBlock ("df5582.aml", "SSDT", 2, "DF5582", "RIG", 0x00000001)
{
    Scope (\_SB)
    {
        Device (DFS)
        {
            Name (_ADR, 0)	/* bus 0, dev 0 function 0 */
            Name (NLFG, 0)

            Method (_REG, 2, NotSerialized)
            {
                If (LEqual (Arg0, 0x0B))
                {
                    Store (Arg1, NLFG)
                }
            }

            OperationRegion (SMB0, GenericSerialBus, 0x00, 0x0100)

            Field (SMB0, BufferAcc, NoLock, Preserve)
            {
                Connection (
                    I2cSerialBus (0x0010, ControllerInitiated, 0x000186A0,
                        AddressingMode7Bit, "\\_SB.DFS", 0x00,
                        ResourceConsumer, , )
                ),
                AccessAs (BufferAcc, AttribBytes (16)),
                FLD0,   8
            }

            Field (SMB0, BufferAcc, NoLock, Preserve)
            {
                Connection (
                    I2cSerialBus (0x0010, ControllerInitiated, 0x000186A0,
                        AddressingMode7Bit, "\\_SB.DFS", 0x00,
                        ResourceConsumer, , )
                ),
                AccessAs (BufferAcc, AttribBlock),
                FLD1,   8
            }

            Method (TST0, 0, NotSerialized)
            {
                Store (Zero, Local0)
                Store (FLD0, Local0)
                Return (Local0)
            }

            Name (BLKD, Buffer (0x0101) {})

            Method (TST1, 0, NotSerialized)
            {
                Store (Zero, Local1)
                While (LLess (Local1, 0x0101))
                {
                    Store (0x41, Index (BLKD, Local1))
                    Increment (Local1)
                }
                /* GSBUS BLOCK write: buffer byte 1 = transfer length */
                Store (0xFF, Index (BLKD, 1))
                Store (BLKD, FLD1)
            }
        }
    }
}
