Re: Adding I2C devices to the SMBus (PIIX4) via the ACPI SSDT overlay method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for the help!

I've created the following SSDT:
```
DefinitionBlock ("at24.aml", "SSDT", 5, "", "AT24", 1)
{
    External (_SB_.PCI0.SMBS, DeviceObj)

    Scope (\_SB_.PCI0.SMBS)
    {
        Device (SMB0) {
            Name (_ADR, 0)
        }
        Device (SMB1) {
            Name (_ADR, 1)
        }
        Device (SMB2) {
            Name (_ADR, 2)
        }
    }

    Scope (\_SB.PCI0.SMBS)
    {
        Device (EEP0) {
            Name (_HID, "PRP0001")
            Name (_DDN, "Atmel AT24 compatible EEPROM")
            Name (_CRS, ResourceTemplate () {
                I2cSerialBusV2 (
                    0x0050,              // I2C Slave Address
                    ControllerInitiated,
                    400000,              // Bus speed
                    AddressingMode7Bit,
                    "\\_SB.PCI0.SMBS.SMB0",   // Link to ACPI I2C host
controller
                    0
                )
            })

            Name (_DSD, Package () {
                ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
                Package () {
                    Package () { "compatible", Package() { "atmel,24c128" } },
                }
            })
        }
    }
}
```
and have added it via initrd.
I think I've tried this ACPI code before, but only via acpi_configfs,
which apparently was too late.

Now I can see that SMBS device contains 3 subdevices for the relevant
i2c busses:
```
$ cat /sys/bus/acpi/devices/device\:25/path
\_SB_.PCI0.SMBS
$ ls -l /sys/bus/acpi/devices/device\:25/
total 0
-r--r--r-- 1 root root 4096 Nov  8 12:23 adr
drwxr-xr-x 3 root root    0 Nov  8 12:21 device:26
drwxr-xr-x 3 root root    0 Nov  8 12:21 device:27
drwxr-xr-x 3 root root    0 Nov  8 12:21 device:28
-r--r--r-- 1 root root 4096 Nov  8 12:23 path
lrwxrwxrwx 1 root root    0 Nov  8 12:23 physical_node ->
../../../../pci0000:00/0000:00:14.0
drwxr-xr-x 2 root root    0 Nov  8 12:23 power
drwxr-xr-x 3 root root    0 Nov  8 12:21 PRP0001:00
lrwxrwxrwx 1 root root    0 Nov  8 12:21 subsystem -> ../../../../../bus/acpi
-rw-r--r-- 1 root root 4096 Nov  8 12:21 uevent
drwxr-xr-x 3 root root    0 Nov  8 12:21 wakeup

$ ls -l /sys/bus/acpi/devices/device\:25/device\:26/
total 0
-r--r--r-- 1 root root 4096 Nov  8 12:23 adr
-r--r--r-- 1 root root 4096 Nov  8 12:23 path
lrwxrwxrwx 1 root root    0 Nov  8 12:23 physical_node ->
../../../../../pci0000:00/0000:00:14.0/i2c-7
drwxr-xr-x 2 root root    0 Nov  8 12:23 power
lrwxrwxrwx 1 root root    0 Nov  8 12:21 subsystem -> ../../../../../../bus/acpi
-rw-r--r-- 1 root root 4096 Nov  8 12:21 uevent

$ ls -l /sys/bus/acpi/devices/device\:25/device\:27/
total 0
-r--r--r-- 1 root root 4096 Nov  8 12:24 adr
-r--r--r-- 1 root root 4096 Nov  8 12:24 path
lrwxrwxrwx 1 root root    0 Nov  8 12:24 physical_node ->
../../../../../pci0000:00/0000:00:14.0/i2c-9
drwxr-xr-x 2 root root    0 Nov  8 12:24 power
lrwxrwxrwx 1 root root    0 Nov  8 12:21 subsystem -> ../../../../../../bus/acpi
-rw-r--r-- 1 root root 4096 Nov  8 12:21 uevent

$ ls -l /sys/bus/acpi/devices/device\:25/device\:28/
total 0
-r--r--r-- 1 root root 4096 Nov  8 12:24 adr
-r--r--r-- 1 root root 4096 Nov  8 12:24 path
lrwxrwxrwx 1 root root    0 Nov  8 12:24 physical_node ->
../../../../../pci0000:00/0000:00:14.0/i2c-8
drwxr-xr-x 2 root root    0 Nov  8 12:24 power
lrwxrwxrwx 1 root root    0 Nov  8 12:21 subsystem -> ../../../../../../bus/acpi
-rw-r--r-- 1 root root 4096 Nov  8 12:21 uevent
```

And my PRP0001 device is finally created and added to the correct bus:
```
$ ls -l /sys/bus/acpi/devices/device\:25/PRP0001\:00/
total 0
-r--r--r-- 1 root root 4096 Nov  8 12:25 hid
-r--r--r-- 1 root root 4096 Nov  8 12:25 modalias
-r--r--r-- 1 root root 4096 Nov  8 12:25 path
lrwxrwxrwx 1 root root    0 Nov  8 12:25 physical_node ->
../../../../../pci0000:00/0000:00:14.0/i2c-7/i2c-PRP0001:00
drwxr-xr-x 2 root root    0 Nov  8 12:25 power
lrwxrwxrwx 1 root root    0 Nov  8 12:21 subsystem -> ../../../../../../bus/acpi
-rw-r--r-- 1 root root 4096 Nov  8 12:21 uevent
```

However I was using the at24 device only as an example.
My real target device is jc42
(https://github.com/torvalds/linux/blob/906bd684e4b1e517dd424a354744c5b0aebef8af/drivers/hwmon/jc42.c#L600).

Here you can see that I can actually provide a driver for it and use:
```
# echo jc42 0x30 > /sys/bus/i2c/devices/i2c-7/new_device
# i2cdetect -y 7
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: 10 11 -- -- -- -- -- -- -- -- -- -- UU -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: 30 -- -- -- -- 35 36 -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- 4a -- -- -- -- --
50: -- -- -- -- 54 -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- 73 -- -- -- --
# cat /sys/bus/i2c/devices/i2c-7/7-001c/hwmon/hwmon4/temp1_input
34000
```

But when I try to perform binding via ACPI, device is created, but for
some reason driver is not connected:
```
$ sudo i2cdetect -y 7
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: 10 11 -- -- -- -- -- -- -- -- -- -- 1c -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: 30 -- -- -- -- 35 36 -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- 4a -- -- -- -- --
50: -- -- -- -- 54 -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- 73 -- -- -- --

$ cat /sys/bus/i2c/devices/i2c-7/i2c-PRP0001\:00/name
jc-42.4-temp

ubuntu@ubuntu-SP3:~$ cat /sys/bus/i2c/devices/i2c-7/i2c-PRP0001\:00/modalias
of:Njc42TCjedec,jc-42.4-temp

$ ls -l /sys/bus/i2c/devices/i2c-7/i2c-PRP0001\:00/
total 0
lrwxrwxrwx 1 root root    0 Nov  8 14:35 firmware_node ->
../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:25/PRP0001:00
-r--r--r-- 1 root root 4096 Nov  8 14:35 modalias
-r--r--r-- 1 root root 4096 Nov  8 14:33 name
drwxr-xr-x 2 root root    0 Nov  8 14:35 power
lrwxrwxrwx 1 root root    0 Nov  8 14:33 subsystem -> ../../../../../bus/i2c
-rw-r--r-- 1 root root 4096 Nov  8 14:33 uevent
-r--r--r-- 1 root root 4096 Nov  8 14:35 waiting_for_supplier
```

Does it mean that jc42 driver doesn't support ACPI binding?

Just in case here is my SSDT:
```
DefinitionBlock ("jc42.aml", "SSDT", 5, "", "JC42", 1)
{
    External (_SB_.PCI0.SMBS, DeviceObj)

    Scope (\_SB_.PCI0.SMBS)
    {
        Device (SMB0) {
            Name (_ADR, 0)
        }
        Device (SMB1) {
            Name (_ADR, 1)
        }
        Device (SMB2) {
            Name (_ADR, 2)
        }
    }

    Scope (\_SB.PCI0.SMBS)
    {
        Device (JC42) {
            Name (_HID, "PRP0001")
            Name (_DDN, "JC42 Temperature sensor")
            Name (_CRS, ResourceTemplate () {
                I2cSerialBusV2 (
                    0x001c,              // I2C Slave Address
                    ControllerInitiated,
                    400000,              // Bus speed
                    AddressingMode7Bit,
                    "\\_SB.PCI0.SMBS.SMB0",   // Link to ACPI I2C host
controller
                    0
                )
            })

            Name (_DSD, Package () {
                ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
                Package () {
                    Package () { "compatible", Package() {
"jedec,jc-42.4-temp" } },
                }
            })
        }
    }
}
```

Best regards,
Konstantin Aladyshev

On Fri, Nov 8, 2024 at 12:27 PM Florian Eckert <fe@xxxxxxxxxx> wrote:
>
> Hello Konstantin,
>
> On 2024-11-08 09:46, Andy Shevchenko wrote:
> > +Cc: Florian (as this indeed rang a bell to me)
> >
> > https://lore.kernel.org/all/d84fb798722762862a7fb08f1e343b6a@xxxxxxxxxx/
>
> The message was forwarded by Andy because I had a similar problem with
> my APU3 [1]
> from PC-engine [2], which is also using the PIIX4 for I2C (SMBUS).
>
> >> Maybe I need to modify ACPI code somehow to create these
> >> 'physical_nodesX' folders for the relevant i2c-7/8/9 buses?
>
> I don't know if that helps, but with the following SSDT overlay I
> managed
> to get the driver to feel responsible for the mcp23017 via the I2C
> (SMBUS) of
> the APU3. The mcp23017 is used on my APU3 to add additional LEDs to
> '/sys/class/leds'.
>
> ```
> DefinitionBlock ("mcp.aml", "SSDT", 5, "TEST", "MCP", 2)
> {
>          External (\_SB.PCI0.SBUS, DeviceObj)
>
>          Scope (\_SB.PCI0.SBUS)
>          {
>                  Device (I2C0)
>                  {
>                          Name (_ADR, Zero)
>                          Device (GPIO)
>                          {
>                                  Name (_HID, "PRP0001")
>                                  Name (_DDN, "MCP23017 pinctrl")
>                                  Name (_CRS, ResourceTemplate ()
>                                  {
>                                          I2cSerialBus (
>                                                  0x24,
>                                                  ControllerInitiated,
>                                                  100000,
>                                                  AddressingMode7Bit,
>                                                  "\\_SB.PCI0.SBUS.I2C0",
>                                                  0x00
>                                          )
>                                  })
>                                  Name (_DSD, Package ()
>                                  {
>
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
>                                          Package () {
>                                                  Package () {
> "compatible", "microchip,mcp23017" },
>                                          }
>                                  })
>
>                                  Device (LEDS)
>                                  {
>                                          Name (_HID, "PRP0001")
>                                          Name (_DDN, "GPIO LEDs device")
>                                          Name (_CRS, ResourceTemplate ()
> {
>                                                  GpioIo (
>                                                          Exclusive,
>                                                          PullNone,
>                                                          0,
>                                                          0,
>
> IoRestrictionOutputOnly,
>
> "\\_SB.PCI0.SBUS.I2C0.GPIO",
>                                                          0)
>                                                  {
>                                                          0,
>                                                          1,
>                                                          2,
>                                                          3,
>                                                          4,
>                                                          5,
>                                                          6,
>                                                          7,
>                                                  }
>                                          })
>
>                                          Name (_DSD, Package () {
>
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
>                                                  Package () {
>                                                          Package () {
> "compatible", Package() { "gpio-leds" } },
>                                                  },
>
> ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
>                                                  Package () {
>                                                          Package ()
> {"led-0", "LED0"},
>                                                          Package ()
> {"led-1", "LED1"},
>                                                          Package ()
> {"led-2", "LED2"},
>                                                          Package ()
> {"led-3", "LED3"},
>                                                          Package ()
> {"led-4", "LED4"},
>                                                          Package ()
> {"led-5", "LED5"},
>                                                          Package ()
> {"led-6", "LED6"},
>                                                          Package ()
> {"led-7", "LED7"},
>                                                  }
>                                          })
>
>                                          Name (LED0, Package () {
>
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
>                                                  Package () {
>                                                          Package ()
> {"label", "khan:green:led1"},
>                                                          Package ()
> {"default-state", "off"},
>                                                          Package ()
> {"linux,default-trigger", "default-off"},
>                                                          Package ()
> {"gpios", Package () {^LEDS, 0, 0, 1}},
>                                                          Package ()
> {"retain-state-suspended", 1},
>                                                  }
>                                          })
>
>                                          Name (LED1, Package () {
>
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
>                                                  Package () {
>                                                          Package ()
> {"label", "khan:green:led2"},
>                                                          Package ()
> {"default-state", "off"},
>                                                                  Package
> () {"linux,default-trigger", "default-off"},
>                                                          Package ()
> {"gpios", Package () {^LEDS, 0, 1, 1}},
>                                                          Package ()
> {"retain-state-suspended", 1},
>                                                  }
>                                          })
>
>                                          Name (LED2, Package () {
>
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
>                                                  Package () {
>                                                          Package ()
> {"label", "khan:green:led3"},
>                                                          Package ()
> {"default-state", "off"},
>                                                          Package ()
> {"linux,default-trigger", "default-off"},
>                                                          Package ()
> {"gpios", Package () {^LEDS, 0, 2, 1}},
>                                                          Package ()
> {"retain-state-suspended", 1},
>                                                  }
>                                          })
>
>                                          Name (LED3, Package () {
>
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
>                                                  Package () {
>                                                          Package ()
> {"label", "khan:green:led4"},
>                                                          Package ()
> {"default-state", "off"},
>                                                          Package ()
> {"linux,default-trigger", "default-off"},
>                                                          Package ()
> {"gpios", Package () {^LEDS, 0, 3, 1}},
>                                                          Package ()
> {"retain-state-suspended", 1},
>                                                  }
>                                          })
>
>                                          Name (LED4, Package () {
>
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
>                                                  Package () {
>                                                          Package ()
> {"label", "khan:green:led5"},
>                                                          Package ()
> {"default-state", "off"},
>                                                          Package ()
> {"linux,default-trigger", "default-off"},
>                                                          Package ()
> {"gpios", Package () {^LEDS, 0, 4, 1}},
>                                                          Package ()
> {"retain-state-suspended", 1},
>                                                  }
>                                          })
>
>                                          Name (LED5, Package () {
>
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
>                                                  Package () {
>                                                          Package ()
> {"label", "khan:green:led6"},
>                                                          Package ()
> {"default-state", "off"},
>                                                          Package ()
> {"linux,default-trigger", "default-off"},
>                                                          Package ()
> {"gpios", Package () {^LEDS, 0, 5, 1}},
>                                                          Package ()
> {"retain-state-suspended", 1},
>                                                  }
>                                          })
>
>                                          Name (LED6, Package () {
>
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
>                                                  Package () {
>                                                          Package ()
> {"label", "khan:green:led7"},
>                                                          Package ()
> {"default-state", "off"},
>                                                          Package ()
> {"linux,default-trigger", "default-off"},
>                                                          Package ()
> {"gpios", Package () {^LEDS, 0, 6, 1}},
>                                                          Package ()
> {"retain-state-suspended", 1},
>                                                  }
>                                          })
>
>                                          Name (LED7, Package () {
>
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
>                                                  Package () {
>                                                          Package ()
> {"label", "khan:red:led8"},
>                                                          Package ()
> {"default-state", "off"},
>                                                          Package ()
> {"linux,default-trigger", "default-off"},
>                                                          Package ()
> {"gpios", Package () {^LEDS, 0, 7, 1}},
>                                                          Package ()
> {"retain-state-suspended", 1},
>                                                  }
>                                          })
>                                  }
>                          }
>                  }
>          }
> }
> ```
>
> Best regards
>
> Florian
>
> [1] https://pcengines.ch/apu3d4.htm
> [2] https://pcengines.ch/
> [3]
> https://github.com/pcengines/coreboot/blob/8d3e714804b1b2bb5bc89e3ffd9cb3c34f8eb0c6/src/southbridge/amd/pi/hudson/acpi/fch.asl#L29





[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux