From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: How to switch SMBus/I2c bus number in EDK2? To: devel@edk2.groups.io From: gordontcp@gmail.com X-Originating-Location: Hsinchu, TW (61.222.87.235) X-Originating-Platform: Windows Chrome 104 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Tue, 06 Sep 2022 04:09:55 -0700 Message-ID: Content-Type: multipart/alternative; boundary="3OekeqFdaXeNP88TjfUK" --3OekeqFdaXeNP88TjfUK Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi all, My platform information is as follows: Minnowboard Max. I use i2cdetect under Linux to detect multiple I2c buses, such as: I2c-0 Synopsys DesignWare I2C adapter I2c-10 SMBus I801 adapter at 2000 I can scan the I2c-10 SMbus slave address 0x50 from the SpdRead code in the= UEFI shell to have a slave device. Methods as below: UINT32 FindSmBusDev() { ... Addr =3D 0x80000000; for(Bus =3D 0x00; Bus < 0xFF; Bus++) { for(Dev =3D 0x00; Dev <=3D 0x1F; Dev++) { for(Fun =3D 0x00; Fun <=3D 0x07; Fun++) { Addr &=3D 0xFF000000;//clean the address Addr |=3D ((Bus << 16) | (Dev << 11) | (Fun << 8));//set the pci bus dev = and fun IoWrite32(PCI_INDEX_IO_PORT, Addr); if(IoRead32(PCI_DATA_IO_PORT) !=3D 0xFFFFFFFF) { Addr =3D Addr + 0x08;//read class code IoWrite32(PCI_INDEX_IO_PORT, Addr); if (IoRead32(PCI_DATA_IO_PORT) >> 16 =3D=3D 0x0C05)//it's Smbus class co= de { return Addr - 0x08; } } } } } return Addr; } My question is: How to switch to I2c-0 bus under UEFI to perform I2C IO operation on the sl= ave device of Synopsys I2C controller? Any suggestion is greatly appreciated! --3OekeqFdaXeNP88TjfUK Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable

Hi all,
My platform informat= ion is as follows:
Minnowboard Max.
I use i2cdetect under Linux to detect multiple I2c buses, such as= :

I2c-0 Synopsys Des=
ignWare I2C adapter
I2c-10 SMBus I801 adapter at 2000

I can scan the I2c-10 SMbus slave= address 0x50 from the SpdRead code in the UEFI shell to have a slave devic= e. Methods as below:

UINT32 FindSmBusDe=
v()
{
...
Addr =3D 0x80000000;
for(Bus =3D 0x00; Bus < 0xFF; Bus++) {
 for(Dev =3D 0x00; Dev <=3D 0x1F; Dev++) {
  for(Fun =3D 0x00; Fun <=3D 0x07; Fun++) {
   Addr &=3D 0xFF000000;//clean the address
   Addr |=3D ((Bus << 16) | (Dev << 11) | (Fun << 8));//s=
et the pci bus dev and fun IoWrite32(PCI_INDEX_IO_PORT, Addr);
  if(IoRead32(PCI_DATA_IO_PORT) !=3D 0xFFFFFFFF) {
     Addr =3D Addr + 0x08;//read class code
    IoWrite32(PCI_INDEX_IO_PORT, Addr);
    if (IoRead32(PCI_DATA_IO_PORT) >> 16 =3D=3D 0x0C05)//it's Smbus c=
lass code
    {
       return Addr - 0x08;
    }
   }
  }
 }
}
return Addr;
}
 

My question is:
Ho= w to switch to I2c-0 bus under UEFI to perform I2C IO operation on the slav= e device of Synopsys I2C controller?
Any suggestion is greatly appreci= ated!

--3OekeqFdaXeNP88TjfUK--