1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpigen.h>
4 #include <acpi/acpigen_pci.h>
6 #include <device/device.h>
7 #include <device/pci_def.h>
8 #include <device/pci_type.h>
11 void acpigen_write_ADR_pci_devfn(pci_devfn_t devfn
)
14 * _ADR for PCI Bus is encoded as follows:
19 acpigen_write_ADR(PCI_SLOT(devfn
) << 16 | PCI_FUNC(devfn
));
22 void acpigen_write_ADR_pci_device(const struct device
*dev
)
24 assert(dev
->path
.type
== DEVICE_PATH_PCI
);
25 acpigen_write_ADR_pci_devfn(dev
->path
.pci
.devfn
);
28 void acpigen_write_PRT_GSI_entry(unsigned int pci_dev
, unsigned int acpi_pin
, unsigned int gsi
)
30 acpigen_write_package(4);
31 acpigen_write_dword((pci_dev
<< 16) | 0xffff);
32 acpigen_write_byte(acpi_pin
);
35 acpigen_write_byte(0);
38 acpigen_write_dword(gsi
);
40 acpigen_pop_len(); /* Package */
43 void acpigen_write_PRT_source_entry(unsigned int pci_dev
, unsigned int acpi_pin
,
44 const char *source_path
, unsigned int index
)
46 acpigen_write_package(4);
47 acpigen_write_dword((pci_dev
<< 16) | 0xffff);
48 acpigen_write_byte(acpi_pin
);
51 acpigen_emit_namestring(source_path
);
54 acpigen_write_dword(index
);
56 acpigen_pop_len(); /* Package */