From patchwork Tue Dec 4 13:05:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 203618 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 720A92C008F for ; Wed, 5 Dec 2012 00:07:14 +1100 (EST) Received: from localhost ([::1]:60147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfsDQ-00037K-H4 for incoming@patchwork.ozlabs.org; Tue, 04 Dec 2012 08:07:12 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfsBm-00015q-52 for qemu-devel@nongnu.org; Tue, 04 Dec 2012 08:06:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TfsBc-0006Ab-VY for qemu-devel@nongnu.org; Tue, 04 Dec 2012 08:05:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:65443) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfsBc-00069j-Nn for qemu-devel@nongnu.org; Tue, 04 Dec 2012 08:05:20 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qB4D5Ji7006420 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 4 Dec 2012 08:05:19 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-20.ams2.redhat.com [10.36.116.20]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qB4D5Io5026371; Tue, 4 Dec 2012 08:05:19 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id A2BE240A34; Tue, 4 Dec 2012 14:05:15 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 4 Dec 2012 14:05:10 +0100 Message-Id: <1354626315-31186-14-git-send-email-kraxel@redhat.com> In-Reply-To: <1354626315-31186-1-git-send-email-kraxel@redhat.com> References: <1354626315-31186-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 13/18] acpi: fix piix4 smbus mapping X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Make write to the smbus base register and enable bit actually work. Signed-off-by: Gerd Hoffmann --- hw/acpi_piix4.c | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c index 9e6c97e..b1d5bf3 100644 --- a/hw/acpi_piix4.c +++ b/hw/acpi_piix4.c @@ -142,12 +142,29 @@ static void pm_io_space_update(PIIX4PMState *s) memory_region_transaction_commit(); } +static void smbus_io_space_update(PIIX4PMState *s) +{ + s->smb_io_base = le32_to_cpu(*(uint32_t *)(s->dev.config + 0x90)); + s->smb_io_base &= 0xffc0; + + memory_region_transaction_begin(); + memory_region_set_enabled(&s->smb.io, s->dev.config[0xd2] & 1); + memory_region_set_address(&s->smb.io, s->smb_io_base); + memory_region_transaction_commit(); +} + 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) @@ -392,6 +409,7 @@ static int piix4_pm_initfn(PCIDevice *dev) pci_conf[0x91] = s->smb_io_base >> 8; pci_conf[0xd2] = 0x09; pm_smbus_init(&s->dev.qdev, &s->smb); + memory_region_set_enabled(&s->smb.io, pci_conf[0xd2] & 1); memory_region_add_subregion(get_system_io(), s->smb_io_base, &s->smb.io); memory_region_init(&s->io, "piix4-pm", 64);