All of lore.kernel.org
 help / color / mirror / Atom feed
* ACPI: Can I use I2cSerialBus with a PCI I2C controller?
@ 2015-10-20 19:47 Ben Gardner
  2015-10-21  8:50 ` Mika Westerberg
  0 siblings, 1 reply; 15+ messages in thread
From: Ben Gardner @ 2015-10-20 19:47 UTC (permalink / raw)
  To: linux-acpi

Hi everyone,

I am building a custom board based on the Bayley Bay reference design, using
the Intel E3845 CPU.
I have a few I2C devices on the board that are connected to I2C buses 1-3.
The I2C controllers use the i2c-designware-pci driver.

I am currently using i2c_register_board_info() in a driver to describe what
is on the I2C buses. That seems to work just fine.

However, I would like to use the ACPI I2cSerialBus() macro to specify the
devices on those buses and have Linux automatically create the devices.

I am defining the device as shown below (in scope \_SB).
That creates an ACPI device under /sys/bus/acpi/devices/.

// M24C02 EEPROM on I2C-3 addr 0x57
Device (EEP0) {
  Name (_ADR, 1)
  Name (_CID, Package() { "24c02" })
  Method (_CRS, 0, NotSerialized) {
    Name (RBUF, ResourceTemplate () {
      I2cSerialBus (0x0057, ControllerInitiated,
        400000, AddressingMode7Bit, "\\_SB.I2C3",
        0x00, ResourceConsumer,,)
    })
    Return (RBUF)
  }
}

The problem is that the I2C controller is a PCI device. The logic that scans
for attached devices in acpi_i2c_register_devices() in i2c-core.c gives up
because the adapter is not an ACPI device.

  handle = ACPI_HANDLE(adap->dev.parent);
  if (!handle)
    return;

I am using coreboot/SeaBIOS as the BIOS, so I have full control over
the ACPI tables.

I tried enabling the I2C ACPI devices and using the i2c-designware-platform
driver, but that didn't work because Linux changes the resource allocation
for the PCI I2C devices if I specify the resources for the I2C device in ACPI.

The relevent kernel logs are:
[    0.105628] pci 0000:00:18.3: [8086:0f43] type 00 class 0x0c8000
[    0.105656] pci 0000:00:18.3: reg 0x10: [mem 0xd0723000-0xd0723fff]
[    0.105670] pci 0000:00:18.3: reg 0x14: [mem 0xd0724000-0xd0724fff]
...
[    0.122970] pci 0000:00:18.3: can't claim BAR 0 [mem
0xd0723000-0xd0723fff]: address conflict with 80860F43:00 [mem
0xd0723000-0xd0723fff]
...
[    0.136530] pci 0000:00:18.3: BAR 0: assigned [mem 0x80602000-0x80602fff]

The i2c-designware-platform driver tries to use the old BAR0 address
(0xd0723000), which obviously doesn't work.

So my questions are:
  Can I use I2cSerialBus with a PCI I2C controller?
  If so, what am I doing incorrectly?


For reference, here are the interesting parts of the ACPI device definition.
The variable \S3B0 holds the BAR0 value that coreboot sets up.
8086:0f43 is the PCI device ID. 0:18.3 is the PCI bus, device, and function.

Device (I2C3)
{
  Name (_HID, "80860F43")
  Name (_UID, 3)
  Name (_DDN, "I2C Controller #3")
  Name (_ADR, 0x00180003)

  /* Standard Mode: HCNT, LCNT, SDA Hold Time */
  Name (SSCN, Package () { 0x200, 0x200, 0x6 })

  /* Fast Mode: HCNT, LCNT, SDA Hold Time */
  Name (FMCN, Package () { 0x55, 0x99, 0x6 })

  Name (RBUF, ResourceTemplate()
  {
    /* BAR0._BAS is replaced in _CRS */
    Memory32Fixed (ReadWrite, 0, 0x1000, BAR0)
    Interrupt (ResourceConsumer, Level, ActiveLow, Exclusive,,,)
    {
      LPSS_I2C3_IRQ
    }
    FixedDMA (0x10, 0x0, Width32Bit, )
    FixedDMA (0x11, 0x1, Width32Bit, )
  })

  Method (_CRS)
  {
    CreateDwordField (^RBUF, ^BAR0._BAS, RBAS)
    Store (\S3B0, RBAS)
    Return (^RBUF)
  }
  ...
}

Thanks,
Ben Gardner

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-11-02 10:25 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-20 19:47 ACPI: Can I use I2cSerialBus with a PCI I2C controller? Ben Gardner
2015-10-21  8:50 ` Mika Westerberg
2015-10-21 23:14   ` Ben Gardner
2015-10-22  8:01     ` Mika Westerberg
2015-10-22 16:19       ` Ben Gardner
2015-10-22 17:17         ` Ben Gardner
2015-10-23  8:20           ` Mika Westerberg
2015-10-23  9:43             ` Mika Westerberg
2015-10-23 17:24             ` Ben Gardner
2015-10-26 19:56               ` Ben Gardner
2015-10-27 10:49                 ` Mika Westerberg
2015-10-27 21:11             ` Dustin Byford
2015-10-28  9:01               ` Mika Westerberg
2015-10-30 16:51                 ` Ben Gardner
2015-11-02 10:25                   ` Mika Westerberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.