public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Konstantin Aladyshev <aladyshev22@gmail.com>
Cc: linux-acpi@vger.kernel.org, linux-i2c@vger.kernel.org
Subject: Re: Adding I2C devices to the SMBus (PIIX4) via the ACPI SSDT overlay method
Date: Fri, 8 Nov 2024 10:29:16 +0200	[thread overview]
Message-ID: <Zy3L3IvW_E6Lnhe4@smile.fi.intel.com> (raw)
In-Reply-To: <Zy3LOV3VA5Wg9XYh@smile.fi.intel.com>

On Fri, Nov 08, 2024 at 10:26:33AM +0200, Andy Shevchenko wrote:
> On Thu, Nov 07, 2024 at 06:51:03PM +0300, Konstantin Aladyshev wrote:

> > I'm trying to add I2C devices to I2C/SMBus buses via the ACPI SSDT
> > overlay method. I've managed to do it for the I2C buses, but can't get
> > it working for the SMBus (PIIX4).

...

> > Now I'm trying to add devices to the SMBus bus. Which in my case is
> > produced from the i2c_piix4 PCI device:
> > ```
> > $ lspci -s 00:14.0 -vvvxxx
> > 00:14.0 SMBus: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller (rev 61)
> >         Subsystem: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller
> >         Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop-
> > ParErr- Stepping- SERR- FastB2B- DisINTx+
> >         Status: Cap- 66MHz+ UDF- FastB2B- ParErr- DEVSEL=medium
> > >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
> >         NUMA node: 0
> >         IOMMU group: 58
> >         Kernel driver in use: piix4_smbus
> >         Kernel modules: i2c_piix4, sp5100_tco
> > 00: 22 10 0b 79 03 04 20 02 61 00 05 0c 00 00 80 00
> > 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> > 20: 00 00 00 00 00 00 00 00 00 00 00 00 22 10 0b 79
> > 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> > ```
> > 
> > It is described as simple as this in the system ACPI code:
> > ```
> > Device (SMBS) // \_SB_.PCI0.SMBS
> > {
> >     Name (_ADR, 0x00140000)  // _ADR: Address
> 
> So, you need to add Device objects here
> 
> The driver (drivers/i2c/busses/i2c-piix4.c::1157) has this call:
> 
> 	acpi_preset_companion(&adap->dev, ACPI_COMPANION(&dev->dev), hw_port_nr);
> 
> Means, that the _ADR will be evaluated, but there is none for the ports, only
> for the physical device.
> 
> So, you need something like this:
> 
> 	Scope (\_SB_.PCI0.SMBS)
> 	{
> 	  Device (SMB1)
> 	  {
> 	    Name (_ADR, 0)
> 	  }
> 	  Device (SMB1)
> 	  {
> 	    Name (_ADR, 1)
> 	  }
> 	  Device (SMB2)
> 	  {
> 	    Name (_ADR, 2)
> 	  }
> 	}
> 
> 
> And then refer to the controller (respective port) as, for example,
> 
> 	\_SB_.PCI0.SMBS.SMB1
> 
> in your SSDT. Note, the above _ADR assignments you should also add to SSDT
> (better to the same one).
> 
> > }
> > ```
> > And produces several I2C busses to the system:
> > ```
> > i2c-7   unknown         SMBus PIIX4 adapter port 0 at 0b00      N/A
> > i2c-8   unknown         SMBus PIIX4 adapter port 2 at 0b00      N/A
> > i2c-9   unknown         SMBus PIIX4 adapter port 1 at 0b20      N/A
> > ```
> > 
> > No matter how I've tried, I can't get to add my custom devices to
> > these SMBus buses.
> > 
> > Apparently just using "\\_SB.PCI0.SMBS" is not enough for this case.
> > Maybe I need to somehow create port nodes for this Device? Or maybe it
> > is not possible at all with the current piix driver?
> > 
> > Anyway I've started digging and I've noticed that for the I2C device
> > there are two physical_nodes in the sysfs. Where the 'physical_node'
> > is a standard folder and 'physical_node1' is a direct link to the
> > proper i2c bus:
> 
> > Maybe I need to modify ACPI code somehow to create these
> > 'physical_nodesX' folders for the relevant i2c-7/8/9 buses?
> 
> If you succeed with the above, please add the respective section to
> the Documentation/i2c/busses/i2c-piix4.rst and send a patch. It will
> be very appreciated!

The last but not least remark: you have to load your SSDT _before_ the driver,
which means the only methods you may use either initramfs or EFI variable.
ACPI ConfigFS won't work!

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2024-11-08  8:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07 15:51 Adding I2C devices to the SMBus (PIIX4) via the ACPI SSDT overlay method Konstantin Aladyshev
2024-11-08  8:26 ` Andy Shevchenko
2024-11-08  8:29   ` Andy Shevchenko [this message]
2024-11-08  8:46 ` Andy Shevchenko
2024-11-08  9:27   ` Florian Eckert
2024-11-08 11:23     ` Andy Shevchenko
2024-11-08 11:48     ` Konstantin Aladyshev
2024-11-08 12:47       ` Andy Shevchenko
2024-11-11 12:09         ` Konstantin Aladyshev
2024-11-11 12:48           ` Andy Shevchenko

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-all 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=Zy3L3IvW_E6Lnhe4@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=aladyshev22@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    /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