From patchwork Tue Jan 17 20:16:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 643413 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1372479pvb; Tue, 17 Jan 2023 12:18:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXtKRi26HKTecXuGTzQ98F2stCiMMTA0E/7oO4VY7Hu/PtE1KjRqe6u3IDKE8RE0aZSxUMQ9 X-Received: by 2002:a1f:3857:0:b0:3bc:3356:d850 with SMTP id f84-20020a1f3857000000b003bc3356d850mr2163887vka.10.1673986680826; Tue, 17 Jan 2023 12:18:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673986680; cv=none; d=google.com; s=arc-20160816; b=LXQgFtphiGtZarfMR2XxJHHfcwGzDOy4vfvkaOhMc6/cYGnWreLJXovlJn1A85rXNy tcmapoQgkT9mUFP7qAEZzQZhXRE+BG0STNybH74fmoyfNg5a+qvb/xP4n/V2lOdgGVf3 RR03V2rneVXazI+1hTTy7PsKQcbKhTbRY8asJNE0fNFalurdF2m5X6NYvlNltMzI2Qxs nIKnDroV7x1SvWU0cFtSh9QO1VidXns256+BRpSeZyB36XbvkM9P0JydTyI1BqeZ6rvQ Cj5D1YCylUGsyGOD5OikdfbJJftWOquiMqTu140rh6mTAiMYQDcgsdPl5nyiOHoEHkAu ikKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ydeX9QFFdks9xGDUB7zYGvimiTN6pGP8Ia7mPwpsiT8=; b=v21Vc4OaC5LCGxhd16Jw6FrDAuNb92oe7E6ljyGE0OnTNFCubRRaHmvh6w1hwxF8MC b4nffY67nc//9hhwmewX9pSw/MDw/RbvjHHCRRjnRP6xohEhoAHocJ+ZpYHxzY0mplC1 eLGlySaMIdBjoNh9o8SHIpdfM+HkFRTVsIJDr8VZSeWWxAK0SKNakhumo0KWnhN3RXXJ aOv1VIjHoleXFwV78DhQp5a29ef+9W1Tr4IakYi2Qnvq5upRiC0ExcbQfnC0Kg7K2AEU ejoWDgdm/sVPGyTw8HiR0Dv4vC9bSckCCM9mef/rlE/8LUlAX0/Jof3fNYDO89UXZQmQ vtZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="M4a/OMcr"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bp30-20020a05620a459e00b006fa9c0c5ae1si20418186qkb.24.2023.01.17.12.18.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jan 2023 12:18:00 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="M4a/OMcr"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHsO4-0002tl-Db; Tue, 17 Jan 2023 15:16:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHsO3-0002tY-3D for qemu-devel@nongnu.org; Tue, 17 Jan 2023 15:16:51 -0500 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pHsO1-0006Rg-Ly for qemu-devel@nongnu.org; Tue, 17 Jan 2023 15:16:50 -0500 Received: by mail-ed1-x536.google.com with SMTP id s21so2509298edi.12 for ; Tue, 17 Jan 2023 12:16:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ydeX9QFFdks9xGDUB7zYGvimiTN6pGP8Ia7mPwpsiT8=; b=M4a/OMcrw38n2lxsGg5Comb/Gw3G1TsBIhXkP7lju0H8oKPgaDw/zQl6fN3jqarBQO 4DiFz9wFKFmAcPshH9+AYp+xpSwFgZQyC8tDGRnYvuoTwY4TavgWA3JA4I1hFUyN3YP0 jFGymLMsrTpSlQuwWTR3smKdM+u7EDZzutHCtfSdLtpmCq9om8lnzaJDtrHJkRfoKqMk HDEzsvB7Qt6RZfpJt36HKB6DxZsLtYrgVwHt5dEd+7i2TiIaMfNLVB3lU4otUlYNrKDc irq+fcQYLxDIkUVmozwtsGzFdpad/u41gZMS+RcYiFUONXhhose8AU5qwnVjNFccblBm 59AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ydeX9QFFdks9xGDUB7zYGvimiTN6pGP8Ia7mPwpsiT8=; b=xYzZlfNemyUQdz+CagFeIeFIRc6ZG//ojhSyVjE0pyYSz8TwYnPEKeW6Ve5Zr+/f0t vCYxEf3ai1F3zhAz/ixGuKYFR+VVfj5pggwHfBm7GxHsB/AFWuiLVbVsI+5NKs32klBw TgvYis5LWYJdPAno1d9Nlw5G8DLCyeFFxxEa69gWk5tM/iq4tILoHu+ngpmHP6KftLtI LJDmDxuxEaNcDhvaYZfXjnCx0kmvL6KpfDDoRNHlQCS5KyHWCe+Qnv1nAngZOvxV1E28 TSWQ7dj9IYr3IXm2ZbdtIVZdmVb6Q4ccE93oVOjcXN7cJg1T4pBzBLfKASc8CYD6BAkm IYvA== X-Gm-Message-State: AFqh2krUx8mNHWetQUxi/1UFmXD5D9h1fPOUpK+xANt/VI3RHajSSgDx to9gn7TgY7End6FOCwrmSVh7MUT8fmP2U9Vs X-Received: by 2002:aa7:cfd3:0:b0:48e:bb08:c96 with SMTP id r19-20020aa7cfd3000000b0048ebb080c96mr4005986edy.28.1673986608204; Tue, 17 Jan 2023 12:16:48 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id w21-20020a05640234d500b0049c2b02bad4sm5746257edc.88.2023.01.17.12.16.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 17 Jan 2023 12:16:47 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, BALATON Zoltan , =?utf-8?q?Phil?= =?utf-8?q?ippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 1/2] hw/ppc/pegasos2: Extract via_i2c_bus() helper Date: Tue, 17 Jan 2023 21:16:39 +0100 Message-Id: <20230117201640.88365-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230117201640.88365-1-philmd@linaro.org> References: <20230117201640.88365-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=philmd@linaro.org; helo=mail-ed1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Simplify a bit pegasos2_init() by extracting via_i2c_bus(). Signed-off-by: Philippe Mathieu-Daudé --- hw/ppc/pegasos2.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index f46d4bf51d..ac69aee099 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -96,6 +96,14 @@ static void pegasos2_cpu_reset(void *opaque) } } +static I2CBus *via_i2c_bus(PCIDevice *via) +{ + PCIDevice *dev; + + dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "pm")); + return I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c")); +} + static void pegasos2_init(MachineState *machine) { Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine); @@ -103,7 +111,6 @@ static void pegasos2_init(MachineState *machine) MemoryRegion *rom = g_new(MemoryRegion, 1); PCIBus *pci_bus; PCIDevice *dev, *via; - I2CBus *i2c_bus; const char *fwname = machine->firmware ?: PROM_FILENAME; char *filename; int sz; @@ -171,10 +178,8 @@ static void pegasos2_init(MachineState *machine) dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide")); pci_ide_create_devs(dev); - dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "pm")); - i2c_bus = I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c")); spd_data = spd_data_generate(DDR, machine->ram_size); - smbus_eeprom_init_one(i2c_bus, 0x57, spd_data); + smbus_eeprom_init_one(via_i2c_bus(via), 0x57, spd_data); /* other PC hardware */ pci_vga_init(pci_bus); From patchwork Tue Jan 17 20:16:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 643414 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1372512pvb; Tue, 17 Jan 2023 12:18:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXt91ZWYoe98A6MA1xwn5euJ5JLLtuLmvubam8507/oH4aYC6s2qqop0+pBNMqpk6e9AvSDG X-Received: by 2002:ac8:6ede:0:b0:3b6:349e:d48b with SMTP id f30-20020ac86ede000000b003b6349ed48bmr5746601qtv.13.1673986685238; Tue, 17 Jan 2023 12:18:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673986685; cv=none; d=google.com; s=arc-20160816; b=pFh9V9zPVmLGrTK2PAzPhzEp4h1x25kI8fI9jupqVGDup4E0AeAFbv9JyudLo5MBt4 Q9xjrWsmnHlA6uFOeeIX9cgEDXjue9CiD236/HIS+u0kEICwJuUIXES4CGH7TDmz4QFU PA04ZbrXnvHPpWtkZuc67zN3EjNgAI2msI+GFpbml05ULPcRnPzdQDxccmyx8JRBCs74 nSRACDqP7RPsWnQsnwzDRsOuvZyYMLbutqihNlCX1tfdZqxBrwaC0IQBdVlS2kAqdo4N JMtVlYaixiCUeu0EyOBudcZAWIl2mA1BRQ4NIVA1vr5C82kqHEd739jf8T/0Hey0OMEd XBrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UMCy71y0Z4Vz5M1MpnhAy1/JUyaemBevfRPJi/p9hAI=; b=TRzXEWvX4q01BBQSHDmMc4jjyIK24ibikthMOTcyTF0EvGL5rj36DOlMMIqG+4Ld+a TsXNYCTnFXl4fJFoRkZFdeNPlZHoH6OTpgKlsBH0DviMaxF4JKZFZo9224Y7o3HJPX/w pIWvgBsv/16OHHDF+OBSBoRv6EFVQpaHPzOLTF0c8J3yhGxvlEwTToYc36e+Ift+voKt Evp1DZoUCgJ0B36g9/enyNUj8RPurpqWYqKBbo2B0vssyxgwFcWTEn5zHMIrcNrqCNTK YJ9Iq5tFs3LxrF6NW7B50OtC8qZVe8RQUtinr8tyxbruePZHc+P5b/J2r54MteiCZVZV Gn0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vpRVWRXF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ge20-20020a05622a5c9400b003b634e53639si2954306qtb.288.2023.01.17.12.18.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jan 2023 12:18:05 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vpRVWRXF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHsOA-0002xK-PX; Tue, 17 Jan 2023 15:17:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHsO9-0002uX-A0 for qemu-devel@nongnu.org; Tue, 17 Jan 2023 15:16:57 -0500 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pHsO6-0006S4-VK for qemu-devel@nongnu.org; Tue, 17 Jan 2023 15:16:57 -0500 Received: by mail-ej1-x62e.google.com with SMTP id qx13so19709698ejb.13 for ; Tue, 17 Jan 2023 12:16:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UMCy71y0Z4Vz5M1MpnhAy1/JUyaemBevfRPJi/p9hAI=; b=vpRVWRXF+uJG6PDprzK/7ZwGU7jjXX1E7DfWS/5HS6xA5e4oHtp4dLxx826Wn5iW0u F9hHIyYLdzFkxNOLEFX4GQkusfRfLNxjNAMCOPX+tJ1uYX/yuFASGiKKl4xpsUaOjWt7 LS/g2OYapHioBlHrr7/rsOOBOncD9Ur9m6yVDYBhvTOsZtsB+2sq5gOrv8Ti9IKcd0v0 PzheRzfj01AuSKw/ZJ49C2OEI6RyxpfwOFJMYw/IcphhAZQ1yNaAK2deR7ChoYUJGB+6 sk2wgzrtWvmkjs8G4Sm/wteVdc/GNU5Jcc3Pj3ZQ5paDvWMahIu891/sfwhKy8BLJYUQ AaKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UMCy71y0Z4Vz5M1MpnhAy1/JUyaemBevfRPJi/p9hAI=; b=4hpmLLo5DZaiePsoQGR0GwssurkUb7Stg6eSSV2C0+yQam54dAffxI3D5Ewar77rLH Pq8v2DWFP80xlqXywcc7moI/XRmQjxIAMEF1cBTL7Kf7jnVmmp/ccLwY3XEGu2O1UTCJ A0Q2jBaaCwpDU04X4MoxBSUxDR7ynZnciUAPint8AefCVhYWquOJJdfgT01pszJsu9eM +Qge9rHFmxqTaSr7lginndBgICyN/xo9XdUjnbhNvxUO7Fg+IFIwQl5zyBTiSKh4ape+ PYQlEZTUl4YYsJTeCl8cP7+10QiT2CUenRS8ky37mdsxcDu//NHzU1l9z10SWV+XFh/m 7oEw== X-Gm-Message-State: AFqh2kpYWaw+9dKPgTxl6FE8CnyjWZFmQRszFZvrY/Lb2SHyxBNxrGw2 Zb8wffLkbwlSgjhaC0IyQsTjTDN7djfG7k8v X-Received: by 2002:a17:907:c70f:b0:871:d04e:1df with SMTP id ty15-20020a170907c70f00b00871d04e01dfmr4444523ejc.29.1673986613117; Tue, 17 Jan 2023 12:16:53 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id v22-20020aa7d816000000b0049dd7eec977sm4509567edq.41.2023.01.17.12.16.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 17 Jan 2023 12:16:52 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, BALATON Zoltan , =?utf-8?q?Phil?= =?utf-8?q?ippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 2/2] hw/ppc/pegasos2: Extract via_vt8231_create() helper Date: Tue, 17 Jan 2023 21:16:40 +0100 Message-Id: <20230117201640.88365-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230117201640.88365-1-philmd@linaro.org> References: <20230117201640.88365-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=philmd@linaro.org; helo=mail-ej1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Simplify a bit pegasos2_init() by extracting the VIA southbridge creation code into a new via_vt8231_create() helper. Signed-off-by: Philippe Mathieu-Daudé --- hw/ppc/pegasos2.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index ac69aee099..445cb5ef31 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -96,6 +96,25 @@ static void pegasos2_cpu_reset(void *opaque) } } +static PCIDevice *via_vt8231_create(MachineState *machine, PCIBus *pci_bus) +{ + Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine); + PCIDevice *dev, *via; + + via = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0), + true, TYPE_VT8231_ISA); + object_property_add_alias(OBJECT(machine), "rtc-time", + object_resolve_path_component(OBJECT(via), "rtc"), + "date"); + qdev_connect_gpio_out(DEVICE(via), 0, + qdev_get_gpio_in_named(pm->mv, "gpp", 31)); + + dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide")); + pci_ide_create_devs(dev); + + return via; +} + static I2CBus *via_i2c_bus(PCIDevice *via) { PCIDevice *dev; @@ -110,7 +129,7 @@ static void pegasos2_init(MachineState *machine) CPUPPCState *env; MemoryRegion *rom = g_new(MemoryRegion, 1); PCIBus *pci_bus; - PCIDevice *dev, *via; + PCIDevice *via; const char *fwname = machine->firmware ?: PROM_FILENAME; char *filename; int sz; @@ -166,17 +185,7 @@ static void pegasos2_init(MachineState *machine) pci_bus = mv64361_get_pci_bus(pm->mv, 1); /* VIA VT8231 South Bridge (multifunction PCI device) */ - via = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0), true, - TYPE_VT8231_ISA); - object_property_add_alias(OBJECT(machine), "rtc-time", - object_resolve_path_component(OBJECT(via), - "rtc"), - "date"); - qdev_connect_gpio_out(DEVICE(via), 0, - qdev_get_gpio_in_named(pm->mv, "gpp", 31)); - - dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide")); - pci_ide_create_devs(dev); + via = via_vt8231_create(machine, pci_bus); spd_data = spd_data_generate(DDR, machine->ram_size); smbus_eeprom_init_one(via_i2c_bus(via), 0x57, spd_data);