split out piix4 pm logic.
Signed-off-by: Isaku Yamahata yamahata@valinux.co.jp --- src/acpi.c | 19 ++++++++++--------- src/acpi.h | 5 +++++ src/dev-i440fx.c | 15 +++++++++++++++ src/dev-i440fx.h | 1 + 4 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/src/acpi.c b/src/acpi.c index 1179570..32d436f 100644 --- a/src/acpi.c +++ b/src/acpi.c @@ -12,6 +12,7 @@ #include "pci_ids.h" // PCI_VENDOR_ID_INTEL #include "pci_regs.h" // PCI_INTERRUPT_LINE #include "paravirt.h" +#include "dev-i440fx.h" // piix4_fadt_init
/****************************************************/ /* ACPI tables init */ @@ -202,11 +203,6 @@ static inline u16 cpu_to_le16(u16 x) return x; }
-static inline u32 cpu_to_le32(u32 x) -{ - return x; -} - static void build_header(struct acpi_table_header *h, u32 sig, int len, u8 rev) { @@ -222,6 +218,14 @@ build_header(struct acpi_table_header *h, u32 sig, int len, u8 rev) h->checksum -= checksum(h, len); }
+static const struct pci_device_id fadt_init_tbl[] = { + /* PIIX4 Power Management device (for ACPI) */ + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, + piix4_fadt_init), + + PCI_DEVICE_END +}; + static void* build_fadt(int bdf) { @@ -251,8 +255,6 @@ build_fadt(int bdf) int pm_sci_int = pci_config_readb(bdf, PCI_INTERRUPT_LINE); fadt->sci_int = cpu_to_le16(pm_sci_int); fadt->smi_cmd = cpu_to_le32(PORT_SMI_CMD); - fadt->acpi_enable = 0xf1; - fadt->acpi_disable = 0xf0; fadt->pm1a_evt_blk = cpu_to_le32(PORT_ACPI_PM_BASE); fadt->pm1a_cnt_blk = cpu_to_le32(PORT_ACPI_PM_BASE + 0x04); fadt->pm_tmr_blk = cpu_to_le32(PORT_ACPI_PM_BASE + 0x08); @@ -261,8 +263,7 @@ build_fadt(int bdf) fadt->pm_tmr_len = 4; fadt->plvl2_lat = cpu_to_le16(0xfff); // C2 state not supported fadt->plvl3_lat = cpu_to_le16(0xfff); // C3 state not supported - fadt->gpe0_blk = cpu_to_le32(0xafe0); - fadt->gpe0_blk_len = 4; + pci_init_device(fadt_init_tbl, bdf, fadt); /* WBINVD + PROC_C1 + SLP_BUTTON + FIX_RTC */ fadt->flags = cpu_to_le32((1 << 0) | (1 << 2) | (1 << 5) | (1 << 6));
diff --git a/src/acpi.h b/src/acpi.h index e01315a..56add07 100644 --- a/src/acpi.h +++ b/src/acpi.h @@ -98,4 +98,9 @@ struct fadt_descriptor_rev1 #endif } PACKED;
+static inline u32 cpu_to_le32(u32 x) +{ + return x; +} + #endif // acpi.h diff --git a/src/dev-i440fx.c b/src/dev-i440fx.c index c9e0c3e..e5dd7dd 100644 --- a/src/dev-i440fx.c +++ b/src/dev-i440fx.c @@ -17,6 +17,7 @@ #include "post.h" #include "dev-i440fx.h" #include "post.h" +#include "acpi.h" // cpu_to_le32
#define I440FX_PAM0 0x59
@@ -97,3 +98,17 @@ void piix4_apmc_detected(u16 bdf, void *arg) ops->is_enabled = piix4_apmc_is_enabled; ops->enable = piix4_apmc_enable; } + +#define PIIX4_ACPI_ENABLE 0xf1 +#define PIIX4_ACPI_DISABLE 0xf0 +#define PIIX4_GPE0_BLK 0xafe0 +#define PIIX4_GPE0_BLK_LEN 4 + +void piix4_fadt_init(u16 bdf, void *arg) +{ + struct fadt_descriptor_rev1 *fadt = arg; + fadt->acpi_enable = PIIX4_ACPI_ENABLE; + fadt->acpi_disable = PIIX4_ACPI_DISABLE; + fadt->gpe0_blk = cpu_to_le32(PIIX4_GPE0_BLK); + fadt->gpe0_blk_len = PIIX4_GPE0_BLK_LEN; +} diff --git a/src/dev-i440fx.h b/src/dev-i440fx.h index 6250c5e..ee89c23 100644 --- a/src/dev-i440fx.h +++ b/src/dev-i440fx.h @@ -9,5 +9,6 @@ void piix_isa_bridge_init(u16 bdf, void *arg); void piix_ide_init(u16 bdf, void *arg); void piix4_pm_init(u16 bdf, void *arg); void piix4_apmc_detected(u16 bdf, void *arg); +void piix4_fadt_init(u16 bdf, void *arg);
#endif // __I440FX_H