Patchwork [16/20] acpi: fix piix4 smbus mapping

login
register
mail settings
Submitter Gerd Hoffmann
Date Nov. 23, 2012, 3:48 p.m.
Message ID <1353685711-24573-17-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/201377/
State New
Headers show

Comments

Gerd Hoffmann - Nov. 23, 2012, 3:48 p.m.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/acpi_piix4.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index cd876c8..a85c2d4 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -146,12 +146,33 @@  static void pm_io_space_update(PIIX4PMState *s)
     }
 }
 
+static void smbus_io_space_update(PIIX4PMState *s)
+{
+    if (s->smb.io.parent) {
+        memory_region_del_subregion(get_system_io(), &s->smb.io);
+    }
+    if (s->dev.config[0xd2] & 1) {
+        s->smb_io_base = le32_to_cpu(*(uint32_t *)(s->dev.config + 0x90));
+
+        /* XXX: need to improve memory and ioport allocation */
+        PIIX4_DPRINTF("smbus: mapping to 0x%x\n", s->smb_io_base);
+        memory_region_add_subregion(get_system_io(), s->smb_io_base,
+                                    &s->smb.io);
+    }
+}
+
 static void pm_write_config(PCIDevice *d,
                             uint32_t address, uint32_t val, int len)
 {
     pci_default_write_config(d, address, val, len);
-    if (range_covers_byte(address, len, 0x80))
+    if (range_covers_byte(address, len, 0x80) ||
+        ranges_overlap(address, len, 0x40, 4)) {
         pm_io_space_update((PIIX4PMState *)d);
+    }
+    if (range_covers_byte(address, len, 0xd2) ||
+        ranges_overlap(address, len, 0x90, 4)) {
+        smbus_io_space_update((PIIX4PMState *)d);
+    }
 }
 
 static void vmstate_pci_status_pre_save(void *opaque)