
//External(BSCA, MethodObj)
//External(BAC1, IntObj)

OperationRegion (CMOS, SystemIO, 0x72, 2)
Field (CMOS, ByteAcc, NoLock, Preserve)
{
    CMI1, 7,
    , 1,
    CMD1, 8
}
IndexField (CMI1, CMD1, ByteAcc, NoLock, Preserve)
{
  Offset(0x5C),
  BACS, 32
}


Scope(\_SB.PCI0.I2C5)
{
//[-start-20200413-NB2329LBWGL0096-modify-]//
#if 0
Device (BMA2)
{
    Name (_ADR, Zero)  // _ADR: Address
    Name (_HID, "10EC5280")  // _HID: Hardware ID
    Name (_CID, "10EC5280")  // _CID: Compatible ID
    Name (_DDN, "Accelerometer")  // _DDN: DOS Device Name
    Name (_UID, One)  // _UID: Unique ID
    Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
    {
         Name (RBUF, ResourceTemplate ()
         {
            I2cSerialBus (0x0068, ControllerInitiated, 0x00061A80,
                 AddressingMode7Bit, "\\_SB.PCI0.I2C5",
                 0x00, ResourceConsumer, ,
                 )
         })
        Return (RBUF)
    }
    Method(ROTM, 0x0, NotSerialized)
    {
        Name(RBUF, Package(){
            "0 1 0",
            "-1 0 0",
            "0 0 1"
        })
        Return (RBUF)
    }
    Method (_STA, 0, NotSerialized)  // _STA: Status
    {
        Return (0x0F)
    }
}
#endif

  //ACCEL1_INT  GPIO_138 North Community GPO0
  Device (SPBA)
  {
    Name (_ADR, Zero)  // _ADR: Address
    Name (_HID, "10EC5280")  // _HID: Hardware ID
    Name (_CID, "10EC5280")  // _CID: Compatible ID
    Name (_UID, One)  // _UID: Unique ID
    Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
    {
      Name (RBUF, ResourceTemplate ()
      {
        I2cSerialBus (0x0068, ControllerInitiated, 0x00061A80,
            AddressingMode7Bit, "\\_SB.PCI0.I2C5",
            0x00, ResourceConsumer, ,
            )//I2C resource for ACC

       // GpioInt (Level, ActiveHigh, Exclusive, PullNone, 0x0000,
       //     "\\_SB.GPO0", 0x00, ResourceConsumer, ,
       //     )
       //     {   // Pin list          GPIO_138
       //         62
       //     }//Interrupt resource for ACC (fake)
        //I2cSerialBus (0x0068, ControllerInitiated, 0x00061A80,
        //    AddressingMode7Bit, "\\_SB.PCI0.I2C5",
        //    0x00, ResourceConsumer, ,
        //    )//I2C resource for GYRO
      })
      Return (RBUF)
  }

    Method (ROMS, 0, NotSerialized)
    {
        Name (SBUF, Package (0x03)
        {
            "1 0 0", 
            "0 1 0", 
            "0 0 1"
        })
        Return (SBUF)
    }

    Method (CALS, 1, NotSerialized)
    {
        Store (Arg0, Local0)
        If (LOr (LEqual (Local0, Zero), LEqual (Local0, Ones)))
        {
            Store (BAC1, Local0)
            Return (Local0)
        }
        Else
        {
            Store (Local0, BAC1)
            Store (Local0, BACS)
            BSCA (0xB0)
        }
    }

   Method (_STA, 0, NotSerialized)  // _STA: Status
   {
      If(LEqual(GAVT, 0x68)){
        Return (0x0F)
      }else{
        Return (0x00)
      }
   }


#if 0
  Method (_DSM, 4, NotSerialized)  // _DSM: Device-Specific Method  also contain your remapping array
  {
      If (LEqual (Arg0, Buffer (0x10)
        {
            /* 0000 */   0x1E, 0x54, 0x81, 0x76, 0x27, 0x88, 0x39, 0x42,
            /* 0008 */   0x8D, 0x9D, 0x36, 0xBE, 0x7F, 0xE1, 0x25, 0x42
        }))
      {
        If (LEqual (Arg2, Zero))
        {
          Return (Buffer (One)
          {
               0x03
          })
        }
        //add your ACC calibration array here
        If (LEqual (Arg2, One))
        {
          Return (Buffer (0x04)
          {
               0x00, 0x01, 0x02, 0x03
          })
        }
        //add your ACC remapping array here  修改
        If (LEqual (Arg2, 0x02))
        {
            Return (Buffer (0x04)
            {
              0x00,0x01,0x01,0x00
            })
        }
   
      //add your GYRO remapping array here    修改
        If (LEqual (Arg2, 0x04))
        {
          Return (Buffer (0x04)
          {
             0x00,0x01,0x01,0x00
          })
        }

      }
      Else
      {
          Return (Buffer (One)
          {
               0x00
          })
      }
    }
#endif
  }
//[-end-20200413-NB2329LBWGL0096-modify-]//
} //Scope(\_SB.PCI0.I2C5)
