From patchwork Thu Aug 25 10:14:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Peng X-Patchwork-Id: 662727 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sKgQF1Vv6z9sBm for ; Thu, 25 Aug 2016 20:29:09 +1000 (AEST) Received: from localhost ([::1]:55461 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcruF-0000Bg-38 for incoming@patchwork.ozlabs.org; Thu, 25 Aug 2016 06:29:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34506) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcroZ-00034x-01 for qemu-devel@nongnu.org; Thu, 25 Aug 2016 06:23:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bcroS-0001WP-TO for qemu-devel@nongnu.org; Thu, 25 Aug 2016 06:23:13 -0400 Received: from mga03.intel.com ([134.134.136.65]:15072) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcroS-0001Ur-NK for qemu-devel@nongnu.org; Thu, 25 Aug 2016 06:23:08 -0400 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP; 25 Aug 2016 03:23:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,575,1464678000"; d="scan'208";a="160746991" Received: from vmm-docker1.bj.intel.com ([10.240.193.52]) by fmsmga004.fm.intel.com with ESMTP; 25 Aug 2016 03:23:05 -0700 From: Chao Peng To: qemu-devel@nongnu.org Date: Thu, 25 Aug 2016 06:14:54 -0400 Message-Id: <1472120105-29235-2-git-send-email-chao.p.peng@linux.intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1472120105-29235-1-git-send-email-chao.p.peng@linux.intel.com> References: <1472120105-29235-1-git-send-email-chao.p.peng@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.65 Subject: [Qemu-devel] [RFC PATCH v2 01/12] pc: make smbus configurable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Haozhong Zhang , Xiao Guangrong , Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , gor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Chao Peng --- hw/i386/pc.c | 23 +++++++++++++++++++++++ hw/i386/pc_q35.c | 12 +++++++----- include/hw/i386/pc.h | 3 +++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 022dd1b..66e1961 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2005,6 +2005,27 @@ static HotplugHandler *pc_get_hotpug_handler(MachineState *machine, pcmc->get_hotplug_handler(machine, dev) : NULL; } +static void pc_machine_get_prop_bool(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + bool value = *(bool *)opaque; + + visit_type_bool(v, name, &value, errp); +} + +static void pc_machine_set_prop_bool(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + visit_type_bool(v, name, (bool *)opaque, errp); +} + +#define PC_MACHINE_DEFINE_PROP_BOOL(pcms, prop, field, defval) \ + pcms->field = defval; \ + object_property_add(OBJECT(pcms), prop, "bool", \ + pc_machine_get_prop_bool, \ + pc_machine_set_prop_bool, \ + NULL, &pcms->field, &error_abort); + static void pc_machine_get_hotplug_memory_region_size(Object *obj, Visitor *v, const char *name, void *opaque, @@ -2168,6 +2189,8 @@ static void pc_machine_initfn(Object *obj) pcms->acpi_nvdimm_state.is_enabled = false; object_property_add_bool(obj, PC_MACHINE_NVDIMM, pc_machine_get_nvdimm, pc_machine_set_nvdimm, &error_abort); + + PC_MACHINE_DEFINE_PROP_BOOL(pcms, PC_MACHINE_SMBUS, smbus, true); } static void pc_machine_reset(void) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index c0b9961..5bb19c1 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -247,11 +247,13 @@ static void pc_q35_init(MachineState *machine) ehci_create_ich9_with_companions(host_bus, 0x1d); } - /* TODO: Populate SPD eeprom data. */ - smbus_eeprom_init(ich9_smb_init(host_bus, - PCI_DEVFN(ICH9_SMB_DEV, ICH9_SMB_FUNC), - 0xb100), - 8, NULL, 0); + if (pcms->smbus) { + /* TODO: Populate SPD eeprom data. */ + smbus_eeprom_init(ich9_smb_init(host_bus, + PCI_DEVFN(ICH9_SMB_DEV, ICH9_SMB_FUNC), + 0xb100), + 8, NULL, 0); + } pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 74c175c..aec809c 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -76,6 +76,8 @@ struct PCMachineState { /* Address space used by IOAPIC device. All IOAPIC interrupts * will be translated to MSI messages in the address space. */ AddressSpace *ioapic_as; + + bool smbus; }; #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device" @@ -84,6 +86,7 @@ struct PCMachineState { #define PC_MACHINE_VMPORT "vmport" #define PC_MACHINE_SMM "smm" #define PC_MACHINE_NVDIMM "nvdimm" +#define PC_MACHINE_SMBUS "smbus" /** * PCMachineClass: