From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by mx.groups.io with SMTP id smtpd.web11.3501.1662468074352751304 for ; Tue, 06 Sep 2022 05:41:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PwpDWPd3; spf=pass (domain: gmail.com, ip: 209.85.210.177, mailfrom: pedro.falcato@gmail.com) Received: by mail-pf1-f177.google.com with SMTP id 145so11261301pfw.4 for ; Tue, 06 Sep 2022 05:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date; bh=bjCjIfUEi9ZRm7ztwH4TVbYppt95AzBUlUzZjONgExg=; b=PwpDWPd3NLT6VPn3Iy4FTFzmLh7+wHblRlW3ehAqvbEvqit+ZzOkSuLabHld2lRadZ zNpT3KIYJhAE+ol+LE66QvNID2TYhynudLmb4dNNAOEnkkhkKier76GiCH5AUIG33Ax1 /MGMDQ+ZmM7WL10NJY+Cr7UT+PlmO1qwWq9Xjmq5MVjIHGZDnarXDa9RTwi4xtK5BUKE 947rOigy/FgIWMef+tqNEBinpS3BFYlTXssHRry2jls9CvGvFu9d5Lt/xRMMdcgi9XD4 9ul7wjzsrq+LkDhVJ+zRSGuE64oO3aTsi3aVu4fr2lUuWKGmR0HTLuM21pB9Nms6rbqA UaHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date; bh=bjCjIfUEi9ZRm7ztwH4TVbYppt95AzBUlUzZjONgExg=; b=jWc50l5h0g7JaWN9QLM/dpMNsqs/dgiPE7RbEJOPc+TICVh0YXQMw77wMcIlmE+Y0+ xAckS8Y7al8eRSxIr2HmV/Y7BXPHTps68RujpqTYw7scHdnta4Y9Fu96l0pjWlIOFbAF tLzI3FyYNsg2ftpaDb8aVSzX1PKWn5ZxlHJYnRZn6rUrx2p8QP5kGnN6H7a4KLljdNSG fFJF5EqWbqd8LAieyR7nD687gS+55FwqfDLPG+RaEr35+x+Gy7lzBev78Jukp55ORO95 7Smf/HEwPFCbCbE6GE/yF8QIYOAS0S8p2VuEwiTdHSWf5U8FWg8RuMNO/ICemhe/KaLd 6PJw== X-Gm-Message-State: ACgBeo1eFXUSFeiCRUwbBdl/qoyA2eb7sOzuF9APRqR7/jnC33Ud9+UX yOw2m/fQ3g7vmgnGYFVhoz+0b+QHYOfwbxaGn5uDTBIe X-Google-Smtp-Source: AA6agR7icOuhvcv5FqTRlsv6alAwuUEFVgTnEoOu2MvNKnfonKYwrtKgAFwBMDuSCxK0wvBJnWGIcsjyoseJ+P9Mrh4= X-Received: by 2002:a63:4b43:0:b0:42a:b42a:d216 with SMTP id k3-20020a634b43000000b0042ab42ad216mr45777284pgl.530.1662468073177; Tue, 06 Sep 2022 05:41:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Pedro Falcato" Date: Tue, 6 Sep 2022 13:41:00 +0100 Message-ID: Subject: Re: [edk2-devel] How to switch SMBus/I2c bus number in EDK2? To: edk2-devel-groups-io , gordontcp@gmail.com Content-Type: multipart/alternative; boundary="000000000000f3c62805e80182ae" --000000000000f3c62805e80182ae Content-Type: text/plain; charset="UTF-8" Hi, You're assuming every i2c bus appears as a PCI device - that's not always the case. In fact, those Synopsys devices usually arent (AFAIK). Thanks, Pedro On Tue, 6 Sept 2022, 12:09 , wrote: > 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 = 0x80000000; > for(Bus = 0x00; Bus < 0xFF; Bus++) { > for(Dev = 0x00; Dev <= 0x1F; Dev++) { > for(Fun = 0x00; Fun <= 0x07; Fun++) { > Addr &= 0xFF000000;//clean the address > Addr |= ((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) != 0xFFFFFFFF) { > Addr = Addr + 0x08;//read class code > IoWrite32(PCI_INDEX_IO_PORT, Addr); > if (IoRead32(PCI_DATA_IO_PORT) >> 16 == 0x0C05)//it's Smbus class code > { > return Addr - 0x08; > } > } > } > } > } > return Addr; > } > > > > My question is: > How to switch to I2c-0 bus under UEFI to perform I2C IO operation on the > slave device of Synopsys I2C controller? > Any suggestion is greatly appreciated! > > --000000000000f3c62805e80182ae Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,


You're assuming every i2c bus appears as a PCI devi= ce - that's not always the case. In fact, those Synopsys devices usuall= y arent (AFAIK).

Thanks,=
Pedro=C2=A0

On Tue, 6 Sept 2022, 12:09 , <<= a href=3D"mailto:gordontcp@gmail.com">gordontcp@gmail.com> wrote:

Hi all,
My platform information is as follows:
Minnowboard Max.
I use i2cdetect under Li= nux 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));//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 Smb=
us class code
    {
       return Addr - 0x08;
    }
   }
  }
 }
}
return Addr;
}
=C2=A0

My question i= s:
How to switch to I2c-0 bus under UEFI to perform I2C IO operation on = the slave device of Synopsys I2C controller?
Any suggestion is greatly a= ppreciated!

=20

--000000000000f3c62805e80182ae--