Discussion:
acpi, pci, spibus -- tying it all together
Yuri Pankov
2018-09-09 07:25:44 UTC
Permalink
I have modified intelspi to attach to SPI master (Sunrise Point-H Serial
IO SPI) located on pci bus, and on attach I have the spibus0 and spibus1
buses added.

As spibus is not self-enumerating, the only way to find the slave device
I need is via acpi bus probe, that works, but I don't see a way to make
it a child of spibus1 (where it's located).

In ACPI terms it looks like the below (from DSDT):

...
\_SB_.PCI0.SPI0 "Device (SPI0)"
\_SB_.PCI0.SPI1 "Device (SPI1)"
...
Scope (SPI1) {
Device (SPIT) {
...here comes all the data we need,
including the ACPI ID we can probe...
}
}
...

I hope that made at least some sense. And the question is if there any
existing way of tying it all together, and adding that slave device to
the spibus1 (which only knows about hinted children at the moment)?
Konstantin Belousov
2018-09-09 09:22:55 UTC
Permalink
Post by Yuri Pankov
I have modified intelspi to attach to SPI master (Sunrise Point-H Serial
IO SPI) located on pci bus, and on attach I have the spibus0 and spibus1
buses added.
As spibus is not self-enumerating, the only way to find the slave device
I need is via acpi bus probe, that works, but I don't see a way to make
it a child of spibus1 (where it's located).
...
\_SB_.PCI0.SPI0 "Device (SPI0)"
\_SB_.PCI0.SPI1 "Device (SPI1)"
...
Scope (SPI1) {
Device (SPIT) {
...here comes all the data we need,
including the ACPI ID we can probe...
}
}
...
I hope that made at least some sense. And the question is if there any
existing way of tying it all together, and adding that slave device to
the spibus1 (which only knows about hinted children at the moment)?
I had very similar situation where I wrote NVDIMM driver.

The suggestion I got was to implement DEVICE_IDENTIFY() method. It
gets the driver_t and the parent bus device_t arguments. In the method,
you create children' device_t, iterating over the ACPI enumerated entries.
Practically, you would use acpica AcpiWalkNamespace(ACPI_TYPE_DEVICE, ...)
function and call BUS_ADD_CHILD() when needed. Set the ACPI handle for
the created child. [Get the Intel' ACPICA reference manual to understand
the KPI].

Then probe does nothing, and attach verifies against the handle.

You can see that in https://kib.kiev.ua/kib/nvdimm.7.patch
nvdimm_identify(), nvdimm_foreach_acpi(), and nvdimm_create_dev().
Yuri Pankov
2018-09-09 22:44:08 UTC
Permalink
Post by Konstantin Belousov
Post by Yuri Pankov
I have modified intelspi to attach to SPI master (Sunrise Point-H Serial
IO SPI) located on pci bus, and on attach I have the spibus0 and spibus1
buses added.
As spibus is not self-enumerating, the only way to find the slave device
I need is via acpi bus probe, that works, but I don't see a way to make
it a child of spibus1 (where it's located).
...
\_SB_.PCI0.SPI0 "Device (SPI0)"
\_SB_.PCI0.SPI1 "Device (SPI1)"
...
Scope (SPI1) {
Device (SPIT) {
...here comes all the data we need,
including the ACPI ID we can probe...
}
}
...
I hope that made at least some sense. And the question is if there any
existing way of tying it all together, and adding that slave device to
the spibus1 (which only knows about hinted children at the moment)?
I had very similar situation where I wrote NVDIMM driver.
The suggestion I got was to implement DEVICE_IDENTIFY() method. It
gets the driver_t and the parent bus device_t arguments. In the method,
you create children' device_t, iterating over the ACPI enumerated entries.
Practically, you would use acpica AcpiWalkNamespace(ACPI_TYPE_DEVICE, ...)
function and call BUS_ADD_CHILD() when needed. Set the ACPI handle for
the created child. [Get the Intel' ACPICA reference manual to understand
the KPI].
Then probe does nothing, and attach verifies against the handle.
You can see that in https://kib.kiev.ua/kib/nvdimm.7.patch
nvdimm_identify(), nvdimm_foreach_acpi(), and nvdimm_create_dev().
Thank you, it was helpful indeed, especially the walk part.

Loading...