public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Pedro Falcato" <pedro.falcato@gmail.com>
To: edk2-devel-groups-io <devel@edk2.groups.io>, gordontcp@gmail.com
Subject: Re: [edk2-devel] How to switch SMBus/I2c bus number in EDK2?
Date: Tue, 6 Sep 2022 13:41:00 +0100	[thread overview]
Message-ID: <CAKbZUD3cZGZkHn7TfHswfuXSagncad_=F1Ckv=A8=dPef_-QAQ@mail.gmail.com> (raw)
In-Reply-To: <rWE9.1662462595210339125.GtZ6@groups.io>

[-- Attachment #1: Type: text/plain, Size: 1403 bytes --]

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 , <gordontcp@gmail.com> 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!
> 
>

[-- Attachment #2: Type: text/html, Size: 4603 bytes --]

      reply	other threads:[~2022-09-06 12:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-06 11:09 How to switch SMBus/I2c bus number in EDK2? gordontcp
2022-09-06 12:41 ` Pedro Falcato [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKbZUD3cZGZkHn7TfHswfuXSagncad_=F1Ckv=A8=dPef_-QAQ@mail.gmail.com' \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox