本文主要是介绍acpi来模拟dts,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
通过acpi来模拟dts 的文档在Documentation/firmware-guide/acpi/enumeration.rst 可以看到
acpi来模拟dtd的关键是使用drivers/acpi/internal.h:237:#define ACPI_DT_NAMESPACE_HID "PRP0001"static bool __acpi_match_device(struct acpi_device *device,const struct acpi_device_id *acpi_ids,const struct of_device_id *of_ids,const struct acpi_device_id **acpi_id,const struct of_device_id **of_id)
{const struct acpi_device_id *id;struct acpi_hardware_id *hwid;/** If the device is not present, it is unnecessary to load device* driver for it.*/if (!device || !device->status.present)return false;list_for_each_entry(hwid, &device->pnp.ids, list) {/* First, check the ACPI/PNP IDs provided by the caller. */if (acpi_ids) {for (id = acpi_ids; id->id[0] || id->cls; id++) {if (id->id[0] && !strcmp((char *)id->id, hwid->id))goto out_acpi_match;if (id->cls && __acpi_match_device_cls(id, hwid))goto out_acpi_match;}}
#可见在acpi match的时候会坚持如果HID是"PRP0001",就调用acpi_of_match_device 来判断是否匹配,而
acpi_of_match_device 的作用就是 Match device object using the "compatible" property./** Next, check ACPI_DT_NAMESPACE_HID and try to match the* "compatible" property if found.*/if (!strcmp(ACPI_DT_NAMESPACE_HID, hwid->id))return acpi_of_match_device(device, of_ids, of_id);}return false;out_acpi_match:if (acpi_id)*acpi_id = id;return true;
}
这样的话,在acpi系统中使用dts的驱动,只要bios 适配就可以了,bios 适配dts的驱动,举例如下:Device (TMP0){Name (_HID, "PRP0001")Name (_DSD, Package() {ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),Package () {Package (2) { "compatible", "ti,tmp75" },}})Method (_CRS, 0, Serialized){Name (SBUF, ResourceTemplate (){I2cSerialBusV2 (0x48, ControllerInitiated,400000, AddressingMode7Bit,"\\_SB.PCI0.I2C1", 0x00,ResourceConsumer, , Exclusive,)})Return (SBUF)}}
这篇关于acpi来模拟dts的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!