From nobody Wed Nov 27 10:01:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1699390159; cv=none; d=zohomail.com; s=zohoarc; b=fBo8qM2bHILmXUeCmybYNkl/3dF1HUEjExLTenisCMofUTqDqCEqlFZQrBCE2OwMwUApU0KcWqlaWcwLWSB7CPheCICqBYpcfCJR1lik3vuCkVmBC+SjovgeKFH7/vm2Qjn7A4sKnr8NC/BZ3v+wO/SZ235WGBjg3mWLLbvUqL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699390159; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UxOhMl2wqsbZK7xoOekGJBbt7dObwp6VMHmgjJubr/E=; b=VgPkIJl1mVkk196kH7YD2j+8PJH2hdAKE37CAeE056D0XNMdE2SrhydRVSntSPJZUcu1qmt9Gp2EJPCVWyXUSaLwM3MCkDEPPVCXDHDXMk8EKuSWbpyD2fzf9jKAMYgZbyhac9wbac/1PkzVpY+/J+lWsNF1AhCSId311+V64bU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699390159326558.7458329703107; Tue, 7 Nov 2023 12:49:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0Szq-0006XN-Ej; Tue, 07 Nov 2023 15:48:26 -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 1r0Szp-0006VM-CW; Tue, 07 Nov 2023 15:48:25 -0500 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0Sze-0006RD-NI; Tue, 07 Nov 2023 15:48:21 -0500 Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6ce2fc858feso3238729a34.3; Tue, 07 Nov 2023 12:48:14 -0800 (PST) Received: from grind.. ([179.193.10.161]) by smtp.gmail.com with ESMTPSA id d13-20020ac8544d000000b0041eb13a8195sm48946qtq.61.2023.11.07.12.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 12:48:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699390093; x=1699994893; darn=nongnu.org; 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=UxOhMl2wqsbZK7xoOekGJBbt7dObwp6VMHmgjJubr/E=; b=YLvvRSHchn9Q4SurkGsg3zb4jy++rVUUjj/FhAKuiu8jWXnkRAFDhDL2hr8p7OgPeK ZCER0K9N7F69rzxBQMVA1VNxHT8pWj1LP65bJEOt6yDI3LAjD03bvleWPzMvLh4zF548 HgLrgh9FJnMH4doHSB1SQFOVdpYeFwJ0Nh4hHWou3ng9+y9WcXyjgI1Px76Jk638K4W9 UtlaElwKN4rZ5sSrZyeLuOH3aHqIWbZrv4cgh2oQ/BwTsPiOhB5ATtiiQbjPeMu7aEHH 7ZKC5ZG5Skl8nk69GJBEvS49xLacNmq7GqJxHJAQWgQxsCNWipj1+fL8TRuhbWgZTAP7 03bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699390093; x=1699994893; 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=UxOhMl2wqsbZK7xoOekGJBbt7dObwp6VMHmgjJubr/E=; b=TvSlCCSWycNUua+6fLXcwKv5OuwoQApVCTChHlQg0dA4d9Tqnpl+U2iIWOssDHYIEJ pwAmAycES1uDBCVVVfxYPfaISMms0cWPnDrp6VHSKZDo0vdcFwfyUXU4o1/Lon2BrTKU wxw3V8N0XWqmjcjm2HrdJEjCFRBYe1imKr0SPjTyoC2BgT/Ai0u3Pt1B50kJWnMlU3cu npAcgdOiY9CMp4JkqIgGeMQJagmxqS7pHFdBl9D6DSRgAQDLopQqkqISon73cJBtaFoq mrA7BhBwjH9Ilwszt2fFh86OVutsvADeaEec5C7Lhj0eLnipSMhpi80CUTEErJo5n8oI 16rQ== X-Gm-Message-State: AOJu0Yz75Z7uc/I585YcZ4GdVOcaBRoVFtyhTXM9g38ku0BvelWteTbi l/zSNABhtm2CuAn4ZZZfAV7wK/prltc= X-Google-Smtp-Source: AGHT+IFk+6KchhUacaY7DK9Lq6DMZrLg8y7yU86Sn3fyPYHbgyW+j9/cch1yVQYL3iDazIHoNjMMoA== X-Received: by 2002:a05:6830:917:b0:6c4:9fda:a1e2 with SMTP id v23-20020a056830091700b006c49fdaa1e2mr33084162ott.4.1699390092857; Tue, 07 Nov 2023 12:48:12 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, danielhb413@gmail.com, peter.maydell@linaro.org, BALATON Zoltan , Rene Engel Subject: [PULL 1/9] hw/pci-host: Add emulation of Mai Logic Articia S Date: Tue, 7 Nov 2023 17:47:58 -0300 Message-ID: <20231107204806.8507-2-danielhb413@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107204806.8507-1-danielhb413@gmail.com> References: <20231107204806.8507-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::335; envelope-from=danielhb413@gmail.com; helo=mail-ot1-x335.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1699390161378100007 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan The Articia S is a generic chipset supporting several different CPUs that were among others used on some PPC boards. This is a minimal emulation of the parts needed for emulating the AmigaOne board. Signed-off-by: BALATON Zoltan Tested-by: Rene Engel Acked-by: Daniel Henrique Barboza Message-ID: <83822787431701cf4d460298d3e3845f362e5da1.1698406922.git.balato= n@eik.bme.hu> Signed-off-by: Daniel Henrique Barboza --- hw/pci-host/Kconfig | 5 + hw/pci-host/articia.c | 293 ++++++++++++++++++++++++++++++++++ hw/pci-host/meson.build | 2 + include/hw/pci-host/articia.h | 17 ++ 4 files changed, 317 insertions(+) create mode 100644 hw/pci-host/articia.c create mode 100644 include/hw/pci-host/articia.h diff --git a/hw/pci-host/Kconfig b/hw/pci-host/Kconfig index 54a609d2ca..f046d76a68 100644 --- a/hw/pci-host/Kconfig +++ b/hw/pci-host/Kconfig @@ -73,6 +73,11 @@ config SH_PCI bool select PCI =20 +config ARTICIA + bool + select PCI + select I8259 + config MV64361 bool select PCI diff --git a/hw/pci-host/articia.c b/hw/pci-host/articia.c new file mode 100644 index 0000000000..f3fcc49f81 --- /dev/null +++ b/hw/pci-host/articia.c @@ -0,0 +1,293 @@ +/* + * Mai Logic Articia S emulation + * + * Copyright (c) 2023 BALATON Zoltan + * + * This work is licensed under the GNU GPL license version 2 or later. + * + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qapi/error.h" +#include "hw/pci/pci_device.h" +#include "hw/pci/pci_host.h" +#include "hw/irq.h" +#include "hw/i2c/bitbang_i2c.h" +#include "hw/intc/i8259.h" +#include "hw/pci-host/articia.h" + +/* + * This is a minimal emulation of this chip as used in AmigaOne board. + * Most features are missing but those are not needed by firmware and gues= ts. + */ + +OBJECT_DECLARE_SIMPLE_TYPE(ArticiaState, ARTICIA) + +OBJECT_DECLARE_SIMPLE_TYPE(ArticiaHostState, ARTICIA_PCI_HOST) +struct ArticiaHostState { + PCIDevice parent_obj; + + ArticiaState *as; +}; + +/* TYPE_ARTICIA */ + +struct ArticiaState { + PCIHostState parent_obj; + + qemu_irq irq[PCI_NUM_PINS]; + MemoryRegion io; + MemoryRegion mem; + MemoryRegion reg; + + bitbang_i2c_interface smbus; + uint32_t gpio; /* bits 0-7 in, 8-15 out, 16-23 direction (0 in, 1 out)= */ + hwaddr gpio_base; + MemoryRegion gpio_reg; +}; + +static uint64_t articia_gpio_read(void *opaque, hwaddr addr, unsigned int = size) +{ + ArticiaState *s =3D opaque; + + return (s->gpio >> (addr * 8)) & 0xff; +} + +static void articia_gpio_write(void *opaque, hwaddr addr, uint64_t val, + unsigned int size) +{ + ArticiaState *s =3D opaque; + uint32_t sh =3D addr * 8; + + if (addr =3D=3D 0) { + /* in bits read only? */ + return; + } + + if ((s->gpio & (0xff << sh)) !=3D (val & 0xff) << sh) { + s->gpio &=3D ~(0xff << sh | 0xff); + s->gpio |=3D (val & 0xff) << sh; + s->gpio |=3D bitbang_i2c_set(&s->smbus, BITBANG_I2C_SDA, + s->gpio & BIT(16) ? + !!(s->gpio & BIT(8)) : 1); + if ((s->gpio & BIT(17))) { + s->gpio &=3D ~BIT(0); + s->gpio |=3D bitbang_i2c_set(&s->smbus, BITBANG_I2C_SCL, + !!(s->gpio & BIT(9))); + } + } +} + +static const MemoryRegionOps articia_gpio_ops =3D { + .read =3D articia_gpio_read, + .write =3D articia_gpio_write, + .valid.min_access_size =3D 1, + .valid.max_access_size =3D 1, + .endianness =3D DEVICE_LITTLE_ENDIAN, +}; + +static uint64_t articia_reg_read(void *opaque, hwaddr addr, unsigned int s= ize) +{ + ArticiaState *s =3D opaque; + uint64_t ret =3D UINT_MAX; + + switch (addr) { + case 0xc00cf8: + ret =3D pci_host_conf_le_ops.read(PCI_HOST_BRIDGE(s), 0, size); + break; + case 0xe00cfc ... 0xe00cff: + ret =3D pci_host_data_le_ops.read(PCI_HOST_BRIDGE(s), addr - 0xe00= cfc, size); + break; + case 0xf00000: + ret =3D pic_read_irq(isa_pic); + break; + default: + qemu_log_mask(LOG_UNIMP, "%s: Unimplemented register read 0x%" + HWADDR_PRIx " %d\n", __func__, addr, size); + break; + } + return ret; +} + +static void articia_reg_write(void *opaque, hwaddr addr, uint64_t val, + unsigned int size) +{ + ArticiaState *s =3D opaque; + + switch (addr) { + case 0xc00cf8: + pci_host_conf_le_ops.write(PCI_HOST_BRIDGE(s), 0, val, size); + break; + case 0xe00cfc ... 0xe00cff: + pci_host_data_le_ops.write(PCI_HOST_BRIDGE(s), addr, val, size); + break; + default: + qemu_log_mask(LOG_UNIMP, "%s: Unimplemented register write 0x%" + HWADDR_PRIx " %d <- %"PRIx64"\n", __func__, addr, si= ze, val); + break; + } +} + +static const MemoryRegionOps articia_reg_ops =3D { + .read =3D articia_reg_read, + .write =3D articia_reg_write, + .valid.min_access_size =3D 1, + .valid.max_access_size =3D 4, + .endianness =3D DEVICE_LITTLE_ENDIAN, +}; + +static void articia_pcihost_set_irq(void *opaque, int n, int level) +{ + ArticiaState *s =3D opaque; + qemu_set_irq(s->irq[n], level); +} + +/* + * AmigaOne SE PCI slot to IRQ routing + * + * repository: https://source.denx.de/u-boot/custodians/u-boot-avr32.git + * refspec: v2010.06 + * file: board/MAI/AmigaOneG3SE/articiaS_pci.c + */ +static int amigaone_pcihost_bus0_map_irq(PCIDevice *pdev, int pin) +{ + int devfn_slot =3D PCI_SLOT(pdev->devfn); + + switch (devfn_slot) { + case 6: /* On board ethernet */ + return 3; + case 7: /* South bridge */ + return pin; + default: /* PCI Slot 1 Devfn slot 8, Slot 2 Devfn 9, Slot 3 Devfn 10 */ + return pci_swizzle(devfn_slot, pin); + } + +} + +static void articia_realize(DeviceState *dev, Error **errp) +{ + ArticiaState *s =3D ARTICIA(dev); + PCIHostState *h =3D PCI_HOST_BRIDGE(dev); + PCIDevice *pdev; + + bitbang_i2c_init(&s->smbus, i2c_init_bus(dev, "smbus")); + memory_region_init_io(&s->gpio_reg, OBJECT(s), &articia_gpio_ops, s, + TYPE_ARTICIA, 4); + + memory_region_init(&s->mem, OBJECT(dev), "pci-mem", UINT64_MAX); + memory_region_init(&s->io, OBJECT(dev), "pci-io", 0xc00000); + memory_region_init_io(&s->reg, OBJECT(s), &articia_reg_ops, s, + TYPE_ARTICIA, 0x1000000); + memory_region_add_subregion_overlap(&s->reg, 0, &s->io, 1); + + /* devfn_min is 8 that matches first PCI slot in AmigaOne */ + h->bus =3D pci_register_root_bus(dev, NULL, articia_pcihost_set_irq, + amigaone_pcihost_bus0_map_irq, dev, &s-= >mem, + &s->io, PCI_DEVFN(8, 0), 4, TYPE_PCI_BU= S); + pdev =3D pci_create_simple_multifunction(h->bus, PCI_DEVFN(0, 0), + TYPE_ARTICIA_PCI_HOST); + ARTICIA_PCI_HOST(pdev)->as =3D s; + pci_create_simple(h->bus, PCI_DEVFN(0, 1), TYPE_ARTICIA_PCI_BRIDGE); + + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->reg); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mem); + qdev_init_gpio_out(dev, s->irq, ARRAY_SIZE(s->irq)); +} + +static void articia_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->realize =3D articia_realize; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); +} + +/* TYPE_ARTICIA_PCI_HOST */ + +static void articia_pci_host_cfg_write(PCIDevice *d, uint32_t addr, + uint32_t val, int len) +{ + ArticiaState *s =3D ARTICIA_PCI_HOST(d)->as; + + pci_default_write_config(d, addr, val, len); + switch (addr) { + case 0x40: + s->gpio_base =3D val; + break; + case 0x44: + if (val !=3D 0x11) { + /* FIXME what do the bits actually mean? */ + break; + } + if (memory_region_is_mapped(&s->gpio_reg)) { + memory_region_del_subregion(&s->io, &s->gpio_reg); + } + memory_region_add_subregion(&s->io, s->gpio_base + 0x38, &s->gpio_= reg); + break; + } +} + +static void articia_pci_host_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); + + k->config_write =3D articia_pci_host_cfg_write; + k->vendor_id =3D 0x10cc; + k->device_id =3D 0x0660; + k->class_id =3D PCI_CLASS_BRIDGE_HOST; + /* + * PCI-facing part of the host bridge, + * not usable without the host-facing part + */ + dc->user_creatable =3D false; +} + +/* TYPE_ARTICIA_PCI_BRIDGE */ + +static void articia_pci_bridge_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); + + k->vendor_id =3D 0x10cc; + k->device_id =3D 0x0661; + k->class_id =3D PCI_CLASS_BRIDGE_HOST; + /* + * PCI-facing part of the host bridge, + * not usable without the host-facing part + */ + dc->user_creatable =3D false; +} + +static const TypeInfo articia_types[] =3D { + { + .name =3D TYPE_ARTICIA, + .parent =3D TYPE_PCI_HOST_BRIDGE, + .instance_size =3D sizeof(ArticiaState), + .class_init =3D articia_class_init, + }, + { + .name =3D TYPE_ARTICIA_PCI_HOST, + .parent =3D TYPE_PCI_DEVICE, + .instance_size =3D sizeof(ArticiaHostState), + .class_init =3D articia_pci_host_class_init, + .interfaces =3D (InterfaceInfo[]) { + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { }, + }, + }, + { + .name =3D TYPE_ARTICIA_PCI_BRIDGE, + .parent =3D TYPE_PCI_DEVICE, + .instance_size =3D sizeof(PCIDevice), + .class_init =3D articia_pci_bridge_class_init, + .interfaces =3D (InterfaceInfo[]) { + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { }, + }, + }, +}; + +DEFINE_TYPES(articia_types) diff --git a/hw/pci-host/meson.build b/hw/pci-host/meson.build index f891f026cb..de7bfb5a62 100644 --- a/hw/pci-host/meson.build +++ b/hw/pci-host/meson.build @@ -20,6 +20,8 @@ pci_ss.add(when: 'CONFIG_GRACKLE_PCI', if_true: files('gr= ackle.c')) pci_ss.add(when: 'CONFIG_UNIN_PCI', if_true: files('uninorth.c')) # PowerPC E500 boards pci_ss.add(when: 'CONFIG_PPCE500_PCI', if_true: files('ppce500.c')) +# AmigaOne +pci_ss.add(when: 'CONFIG_ARTICIA', if_true: files('articia.c')) # Pegasos2 pci_ss.add(when: 'CONFIG_MV64361', if_true: files('mv64361.c')) =20 diff --git a/include/hw/pci-host/articia.h b/include/hw/pci-host/articia.h new file mode 100644 index 0000000000..529c240274 --- /dev/null +++ b/include/hw/pci-host/articia.h @@ -0,0 +1,17 @@ +/* + * Mai Logic Articia S emulation + * + * Copyright (c) 2023 BALATON Zoltan + * + * This work is licensed under the GNU GPL license version 2 or later. + * + */ + +#ifndef ARTICIA_H +#define ARTICIA_H + +#define TYPE_ARTICIA "articia" +#define TYPE_ARTICIA_PCI_HOST "articia-pci-host" +#define TYPE_ARTICIA_PCI_BRIDGE "articia-pci-bridge" + +#endif --=20 2.41.0 From nobody Wed Nov 27 10:01:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1699390179; cv=none; d=zohomail.com; s=zohoarc; b=lZyE4pvMxyNklo/GfJRl0idpDVRj7DEPWUPNK3XE2U9E1GYRi5fibDw70XLsXTKWD16vK5P7+uSdmIeJzXhqhWcxgXJLC80f0ilN0tNJ4IFvJxQbS0ZLM31NsQEofD96MtktaLGR864et1m0S4/8H2ILbfnCP/Ws9yjWCvxye9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699390179; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=e+QMcQvAJFFcKXttw1mmwXFabfyT79u3qwaW15teDe4=; b=WEML6o9ZW1JyaPHb2rt1Jx80EhQk5IDbFDEvEgZOBMEpLHvQay1JP5QOcGBPdqpQBQd0U42tFP25bLDtrj8JC6WrThUerJl0LnCFFHzx1TZ9OsPsUd4dZzF7fLGjmaBPPy2SztqCnE2fhiVuKOWco44xaElMkDLMtzWUzd9U7vE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699390179114865.9818765821362; Tue, 7 Nov 2023 12:49:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0Szr-0006YC-Pt; Tue, 07 Nov 2023 15:48:27 -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 1r0Szp-0006Vx-8J; Tue, 07 Nov 2023 15:48:25 -0500 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0Szg-0006RX-FS; Tue, 07 Nov 2023 15:48:25 -0500 Received: by mail-qt1-x82b.google.com with SMTP id d75a77b69052e-41cb615c6fbso39046391cf.1; Tue, 07 Nov 2023 12:48:15 -0800 (PST) Received: from grind.. ([179.193.10.161]) by smtp.gmail.com with ESMTPSA id d13-20020ac8544d000000b0041eb13a8195sm48946qtq.61.2023.11.07.12.48.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 12:48:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699390095; x=1699994895; darn=nongnu.org; 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=e+QMcQvAJFFcKXttw1mmwXFabfyT79u3qwaW15teDe4=; b=YGJJW+xY/+2NxlU0Qd2jvpvs7+nArP1wUvGpXrxejbLWYoKEFh+0HKnIFj7D1H67yB X2CxAEQaxFHNesX8z1tUH/7YYg5EBKAhVA0Bwi3+jYty5FVmdNcaOb0cjRjqdJzqZjab nBeBDtg8IyOF9VgGwoEvngPtnIkRvNeFrQnsMdBzhZb+MGQMM2K4Lsd03cFjD+yhf/43 Gn2fgJhYqCKATMFXkYtVbojwiKJBxpSWQ5Nru2dw2Bv/mKUhKURzUAFQitrnyKhXbuwE 5utqyCxsL67H//lUv01dxXcpUCAuSt7aUsiBX3pwLMkjeYleC9LcYXLQI+V3b169oN9h flLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699390095; x=1699994895; 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=e+QMcQvAJFFcKXttw1mmwXFabfyT79u3qwaW15teDe4=; b=M1QIon5i20ZbdvoisuzdJ0wmHZQkcoMB2lzlnjW9DQ5wWzkGguEAI3N5DD571iAz4G YP9jbG9NoOAs2Jxv1Fh/KLuJmvOHkeCw9tIlL9f6Gc4jMzcM3TZOIcfw699Ksu2zW8Y4 kTKAad3VDPW+B4yXz1shUaQ3zOSH38SU+rLsXP6ylatlLEnZDNxuEPmlSKun0Cb5V/t2 Zk3bTvbm3LRUYLGjbOI5HMu/SdOqasBBLuksakDm2jY6iqVqTVtEjw9gO0/25Q9YwngP IYQojd+kmLdnJus8RzUS1A8sHxxgqBcW5jFcg/+zljehUMWfyJTvoR1qGpXOTv54KU+J 90OA== X-Gm-Message-State: AOJu0YygvLJ1QHTG2JcrBhRbz7HFZ+xMpmBtPQQOJsWYg516LLrSPNow s4dAYORsTJ1kBymXZygjnfmKy6Iih70= X-Google-Smtp-Source: AGHT+IFR4ZYHcx+0hzjcqQeNq2Uob8jegwbHh3J+YcF3rfS4ZvDu/q3vYRy9Y4KaFgKoNTWdT4D5cw== X-Received: by 2002:a05:622a:1885:b0:418:1f52:1421 with SMTP id v5-20020a05622a188500b004181f521421mr6483qtc.9.1699390094935; Tue, 07 Nov 2023 12:48:14 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, danielhb413@gmail.com, peter.maydell@linaro.org, BALATON Zoltan , Rene Engel Subject: [PULL 2/9] hw/ppc: Add emulation of AmigaOne XE board Date: Tue, 7 Nov 2023 17:47:59 -0300 Message-ID: <20231107204806.8507-3-danielhb413@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107204806.8507-1-danielhb413@gmail.com> References: <20231107204806.8507-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x82b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1699390181070100003 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan The AmigaOne is a rebranded MAI Teron board that uses U-Boot firmware with patches to support AmigaOS and is very similar to pegasos2 so can be easily emulated sharing most code with pegasos2. The reason to emulate it is that AmigaOS comes in different versions for AmigaOne and PegasosII which only have drivers for one machine and firmware so these only run on the specific machine. Adding this board allows another AmigaOS version to be used reusing already existing peagasos2 emulation. (The AmigaOne was the first of these boards so likely most widespread which then inspired Pegasos that was later replaced with PegasosII due to problems with Articia S, so these have a lot of similarity. Pegasos mainly ran MorphOS while the PegasosII version of AmigaOS was added later and therefore less common than the AmigaOne version.) Signed-off-by: BALATON Zoltan Tested-by: Rene Engel Acked-by: Daniel Henrique Barboza Message-ID: <804935e7a5921548d630576159ae2c758fe6e275.1699382232.git.balato= n@eik.bme.hu> Signed-off-by: Daniel Henrique Barboza --- MAINTAINERS | 8 ++ configs/devices/ppc-softmmu/default.mak | 1 + hw/ppc/Kconfig | 7 + hw/ppc/amigaone.c | 166 ++++++++++++++++++++++++ hw/ppc/meson.build | 2 + 5 files changed, 184 insertions(+) create mode 100644 hw/ppc/amigaone.c diff --git a/MAINTAINERS b/MAINTAINERS index b86ea7f75a..3d0aec7ffa 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1536,6 +1536,14 @@ F: hw/pci-host/mv64361.c F: hw/pci-host/mv643xx.h F: include/hw/pci-host/mv64361.h =20 +amigaone +M: BALATON Zoltan +L: qemu-ppc@nongnu.org +S: Maintained +F: hw/ppc/amigaone.c +F: hw/pci-host/articia.c +F: include/hw/pci-host/articia.h + Virtual Open Firmware (VOF) M: Alexey Kardashevskiy R: David Gibson diff --git a/configs/devices/ppc-softmmu/default.mak b/configs/devices/ppc-= softmmu/default.mak index a887f5438b..b85fd2bcd7 100644 --- a/configs/devices/ppc-softmmu/default.mak +++ b/configs/devices/ppc-softmmu/default.mak @@ -14,6 +14,7 @@ CONFIG_SAM460EX=3Dy CONFIG_MAC_OLDWORLD=3Dy CONFIG_MAC_NEWWORLD=3Dy =20 +CONFIG_AMIGAONE=3Dy CONFIG_PEGASOS2=3Dy =20 # For PReP diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig index 5dfbf47ef5..56f0475a8e 100644 --- a/hw/ppc/Kconfig +++ b/hw/ppc/Kconfig @@ -69,6 +69,13 @@ config SAM460EX select USB_OHCI select FDT_PPC =20 +config AMIGAONE + bool + imply ATI_VGA + select ARTICIA + select VT82C686 + select SMBUS_EEPROM + config PEGASOS2 bool imply ATI_VGA diff --git a/hw/ppc/amigaone.c b/hw/ppc/amigaone.c new file mode 100644 index 0000000000..992a55e632 --- /dev/null +++ b/hw/ppc/amigaone.c @@ -0,0 +1,166 @@ +/* + * QEMU Eyetech AmigaOne/Mai Logic Teron emulation + * + * Copyright (c) 2023 BALATON Zoltan + * + * This work is licensed under the GNU GPL license version 2 or later. + * + */ + +#include "qemu/osdep.h" +#include "qemu/units.h" +#include "qemu/datadir.h" +#include "qemu/log.h" +#include "qemu/error-report.h" +#include "qapi/error.h" +#include "hw/ppc/ppc.h" +#include "hw/boards.h" +#include "hw/loader.h" +#include "hw/pci-host/articia.h" +#include "hw/isa/vt82c686.h" +#include "hw/ide/pci.h" +#include "hw/i2c/smbus_eeprom.h" +#include "hw/ppc/ppc.h" +#include "sysemu/qtest.h" +#include "sysemu/reset.h" +#include "kvm_ppc.h" + +#define BUS_FREQ_HZ 100000000 + +/* + * Firmware binary available at + * https://www.hyperion-entertainment.com/index.php/downloads?view=3Dfiles= &parent=3D28 + * then "tail -c 524288 updater.image >u-boot-amigaone.bin" + * + * BIOS emulator in firmware cannot run QEMU vgabios and hangs on it, use + * -device VGA,romfile=3DVGABIOS-lgpl-latest.bin + * from http://www.nongnu.org/vgabios/ instead. + */ +#define PROM_FILENAME "u-boot-amigaone.bin" +#define PROM_ADDR 0xfff00000 +#define PROM_SIZE (512 * KiB) + +static void amigaone_cpu_reset(void *opaque) +{ + PowerPCCPU *cpu =3D opaque; + + cpu_reset(CPU(cpu)); + cpu_ppc_tb_reset(&cpu->env); +} + +static void fix_spd_data(uint8_t *spd) +{ + uint32_t bank_size =3D 4 * MiB * spd[31]; + uint32_t rows =3D bank_size / spd[13] / spd[17]; + spd[3] =3D ctz32(rows) - spd[4]; +} + +static void amigaone_init(MachineState *machine) +{ + PowerPCCPU *cpu; + CPUPPCState *env; + MemoryRegion *rom, *pci_mem, *mr; + const char *fwname =3D machine->firmware ?: PROM_FILENAME; + char *filename; + ssize_t sz; + PCIBus *pci_bus; + Object *via; + DeviceState *dev; + I2CBus *i2c_bus; + uint8_t *spd_data; + int i; + + /* init CPU */ + cpu =3D POWERPC_CPU(cpu_create(machine->cpu_type)); + env =3D &cpu->env; + if (PPC_INPUT(env) !=3D PPC_FLAGS_INPUT_6xx) { + error_report("Incompatible CPU, only 6xx bus supported"); + exit(1); + } + cpu_ppc_tb_init(env, BUS_FREQ_HZ / 4); + qemu_register_reset(amigaone_cpu_reset, cpu); + + /* RAM */ + if (machine->ram_size > 2 * GiB) { + error_report("RAM size more than 2 GiB is not supported"); + exit(1); + } + memory_region_add_subregion(get_system_memory(), 0, machine->ram); + if (machine->ram_size < 1 * GiB + 32 * KiB) { + /* Firmware uses this area for startup */ + mr =3D g_new(MemoryRegion, 1); + memory_region_init_ram(mr, NULL, "init-cache", 32 * KiB, &error_fa= tal); + memory_region_add_subregion(get_system_memory(), 0x40000000, mr); + } + + /* allocate and load firmware */ + filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, fwname); + if (filename) { + rom =3D g_new(MemoryRegion, 1); + memory_region_init_rom(rom, NULL, "rom", PROM_SIZE, &error_fatal); + memory_region_add_subregion(get_system_memory(), PROM_ADDR, rom); + sz =3D load_image_targphys(filename, PROM_ADDR, PROM_SIZE); + if (sz <=3D 0 || sz > PROM_SIZE) { + error_report("Could not load firmware '%s'", filename); + exit(1); + } + g_free(filename); + } else if (!qtest_enabled()) { + error_report("Could not find firmware '%s'", fwname); + exit(1); + } + + /* Articia S */ + dev =3D sysbus_create_simple(TYPE_ARTICIA, 0xfe000000, NULL); + + i2c_bus =3D I2C_BUS(qdev_get_child_bus(dev, "smbus")); + if (machine->ram_size > 512 * MiB) { + spd_data =3D spd_data_generate(SDR, machine->ram_size / 2); + } else { + spd_data =3D spd_data_generate(SDR, machine->ram_size); + } + fix_spd_data(spd_data); + smbus_eeprom_init_one(i2c_bus, 0x51, spd_data); + if (machine->ram_size > 512 * MiB) { + smbus_eeprom_init_one(i2c_bus, 0x52, spd_data); + } + + pci_mem =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 1); + mr =3D g_new(MemoryRegion, 1); + memory_region_init_alias(mr, OBJECT(dev), "pci-mem-low", pci_mem, + 0, 0x1000000); + memory_region_add_subregion(get_system_memory(), 0xfd000000, mr); + mr =3D g_new(MemoryRegion, 1); + memory_region_init_alias(mr, OBJECT(dev), "pci-mem-high", pci_mem, + 0x80000000, 0x7d000000); + memory_region_add_subregion(get_system_memory(), 0x80000000, mr); + pci_bus =3D PCI_BUS(qdev_get_child_bus(dev, "pci.0")); + + /* VIA VT82c686B South Bridge (multifunction PCI device) */ + via =3D OBJECT(pci_create_simple_multifunction(pci_bus, PCI_DEVFN(7, 0= ), + TYPE_VT82C686B_ISA)); + object_property_add_alias(OBJECT(machine), "rtc-time", + object_resolve_path_component(via, "rtc"), + "date"); + qdev_connect_gpio_out(DEVICE(via), 0, + qdev_get_gpio_in(DEVICE(cpu), PPC6xx_INPUT_INT)); + for (i =3D 0; i < PCI_NUM_PINS; i++) { + qdev_connect_gpio_out(dev, i, qdev_get_gpio_in_named(DEVICE(via), + "pirq", i)); + } + pci_ide_create_devs(PCI_DEVICE(object_resolve_path_component(via, "ide= "))); + pci_vga_init(pci_bus); +} + +static void amigaone_machine_init(MachineClass *mc) +{ + mc->desc =3D "Eyetech AmigaOne/Mai Logic Teron"; + mc->init =3D amigaone_init; + mc->block_default_type =3D IF_IDE; + mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("7457_v1.2"); + mc->default_display =3D "std"; + mc->default_ram_id =3D "ram"; + mc->default_ram_size =3D 512 * MiB; +} + +DEFINE_MACHINE("amigaone", amigaone_machine_init) diff --git a/hw/ppc/meson.build b/hw/ppc/meson.build index 7c2c52434a..7338f9432a 100644 --- a/hw/ppc/meson.build +++ b/hw/ppc/meson.build @@ -81,6 +81,8 @@ ppc_ss.add(when: 'CONFIG_E500', if_true: files( )) # PowerPC 440 Xilinx ML507 reference board. ppc_ss.add(when: 'CONFIG_VIRTEX', if_true: files('virtex_ml507.c')) +# AmigaOne +ppc_ss.add(when: 'CONFIG_AMIGAONE', if_true: files('amigaone.c')) # Pegasos2 ppc_ss.add(when: 'CONFIG_PEGASOS2', if_true: files('pegasos2.c')) =20 --=20 2.41.0 From nobody Wed Nov 27 10:01:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1699390166; cv=none; d=zohomail.com; s=zohoarc; b=iF5O0gl5d7/Rp/qzmDEuX3xpezhjyFOTzpf4K6whwREg/MqeeNBywbLxaVLJapbTRgevicA1pqe0EoMAN6cj7HOTP+tj4cNu1EelyRiAx5dy6W90O8wYYMkCBcOeoozk/R/eFuVXYjxlta+8NPtg4eZtX+YSuyKC3WCrSvlhtEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699390166; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mgDohQL10Kwza6gfUqiIwJVSkAbDVuDSCsqLlsvi+uQ=; b=THuP+p8SR79uKzCaxMcCDiBWSHlqm0Bch7CjTskqMEIuG/5IMkuLVCeS1EAl71BihqTfxRrTn3D9cjOK/itsS7+uVTXfr8zUN7JpwPc7x7xPuLnsLJq5Ld2ImuEwHHN5VhBRrDYej6uWhmfAzD4jeT5FPxaBrwDwz7Q/t8Tp0Vo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699390166343662.6915133809707; Tue, 7 Nov 2023 12:49:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0Szr-0006Y9-5b; Tue, 07 Nov 2023 15:48:27 -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 1r0Szp-0006WV-I1; Tue, 07 Nov 2023 15:48:25 -0500 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0Szh-0006Rj-W3; Tue, 07 Nov 2023 15:48:25 -0500 Received: by mail-qt1-x82a.google.com with SMTP id d75a77b69052e-41cd6e1d4fbso36741641cf.1; Tue, 07 Nov 2023 12:48:17 -0800 (PST) Received: from grind.. ([179.193.10.161]) by smtp.gmail.com with ESMTPSA id d13-20020ac8544d000000b0041eb13a8195sm48946qtq.61.2023.11.07.12.48.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 12:48:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699390096; x=1699994896; darn=nongnu.org; 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=mgDohQL10Kwza6gfUqiIwJVSkAbDVuDSCsqLlsvi+uQ=; b=Laf8ybW4nM1geZiXavmhuo8xknxIKuBquvwyiPr5903RGUitZoZKIuoF5MW1iqoFAE jkeQgrIqOQAyWjkdbNcg/9qx0jMdHEigQKHDD7AfbyFNdYSdbyD3nulThkjAmylPygO8 3t/2BSInPi572XiXVYDxveThN4w4Auc0Sht0uqxeBIh/IlyLUfu4v7BpQEL/SGgNPDML 5uzfkZtzKOaETh0qGH/sL0iP1WCfNB+2X1/mJIizDWkR3v0eMkhQ8HmOCiQ0AT26YDIE LwXT/ZTgyWTT//5QYKKZcfPabQsmGPsVeomn4XQ/+zZqe2kWcEWRYGdWHP9SLG9TExEi YKIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699390096; x=1699994896; 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=mgDohQL10Kwza6gfUqiIwJVSkAbDVuDSCsqLlsvi+uQ=; b=aZhGMqMNWhmBCE61D4Wda3A5ws+im0BxnZn1XXvaDUjxGqLKugNEL4N1LG0+kgELfz Z8HPJqFwuMEcw5uqHFKMJ9+KRzf4XIx5JnsdDmB1oPrig8IG/vloZKq3N8GzZF/rylxI fvUb2aCXYPGq9gf6uriSOLVMLRRyJNBYytKm0xwNztGoIsz/2dOOIVBMagoLZmYwa/Cd Q4NHK3Q/2ksF4dRIUQe16f54N+R6YtxhE4Jny8lmOEtfaFIxz9GgK2pOrMBnki8MAXfE i8KbUlcX6GWlhpZ3sJ/S856GQEzQbWgfc/JLCsMbdGSJtR6hVCa2nRbZrahDIov+UWvu umhw== X-Gm-Message-State: AOJu0Yyis3kcHtJuXZFRpPswfttUyJgTTf7XG5CtGP38+lRIj9+/gbYN vezKv5FL2ZmCKHV3xnfbZCYGwBGPEG8= X-Google-Smtp-Source: AGHT+IGfiGWFzLEMkneXrgfjmMI/yYIEHjo9jcyTEuqN0yjTretId1oZyftAyN8lyN9gJKLmo8yGTA== X-Received: by 2002:a05:622a:1648:b0:418:af4c:1850 with SMTP id y8-20020a05622a164800b00418af4c1850mr35080289qtj.56.1699390096640; Tue, 07 Nov 2023 12:48:16 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, danielhb413@gmail.com, peter.maydell@linaro.org, BALATON Zoltan Subject: [PULL 3/9] tests/avocado: Add test for amigaone board Date: Tue, 7 Nov 2023 17:48:00 -0300 Message-ID: <20231107204806.8507-4-danielhb413@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107204806.8507-1-danielhb413@gmail.com> References: <20231107204806.8507-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82a; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x82a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1699390166984100001 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan Add an avocado test for the amigaone board that tests it with the firmware. Signed-off-by: BALATON Zoltan Reviewed-by: Daniel Henrique Barboza Message-ID: Signed-off-by: Daniel Henrique Barboza --- tests/avocado/ppc_amiga.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/avocado/ppc_amiga.py diff --git a/tests/avocado/ppc_amiga.py b/tests/avocado/ppc_amiga.py new file mode 100644 index 0000000000..b6f866f91d --- /dev/null +++ b/tests/avocado/ppc_amiga.py @@ -0,0 +1,38 @@ +# Test AmigaNG boards +# +# Copyright (c) 2023 BALATON Zoltan +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. + +from avocado.utils import archive +from avocado.utils import process +from avocado_qemu import QemuSystemTest +from avocado_qemu import wait_for_console_pattern + +class AmigaOneMachine(QemuSystemTest): + + timeout =3D 90 + + def test_ppc_amigaone(self): + """ + :avocado: tags=3Darch:ppc + :avocado: tags=3Dmachine:amigaone + :avocado: tags=3Ddevice:articia + :avocado: tags=3Daccel:tcg + """ + self.require_accelerator("tcg") + tar_name =3D 'A1Firmware_Floppy_05-Mar-2005.zip' + tar_url =3D ('https://www.hyperion-entertainment.com/index.php/' + 'downloads?view=3Ddownload&format=3Draw&file=3D25') + tar_hash =3D 'c52e59bc73e31d8bcc3cc2106778f7ac84f6c755' + zip_file =3D self.fetch_asset(tar_name, locations=3Dtar_url, + asset_hash=3Dtar_hash) + archive.extract(zip_file, self.workdir) + cmd =3D f"tail -c 524288 {self.workdir}/floppy_edition/updater.ima= ge >{self.workdir}/u-boot-amigaone.bin" + process.run(cmd, shell=3DTrue) + + self.vm.set_console() + self.vm.add_args('-bios', self.workdir + '/u-boot-amigaone.bin') + self.vm.launch() + wait_for_console_pattern(self, 'FLASH:') --=20 2.41.0 From nobody Wed Nov 27 10:01:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1699390158; cv=none; d=zohomail.com; s=zohoarc; b=B4j5hUJb2eAQrLvmTi14h5aDfg4e2kwI1XVPtCAaY3FjK0BCXjwf+qJAfYtZV4NhIVcQ5YU/RzT06OprQ9fAfVXTaitfRlJIXYpeWVKQik9PW5H9Ao92XRgj15F2en5wb6NMW3ZDfqi2+zlEFju/V6btJ66Dgquf++s6FLJ+sUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699390158; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fPSm70mzujJdjsDPq7I1QjRN11RaLzEgW4IMuLkB9Mg=; b=YDxQj52SWMCx3f7PPVNKtuwCcZt/ATRQERiMrkScsnlWHon1X/qVuExXl4k2n5lClRlpFFAjKsa/mREWLMyy93zVWSdGMb9epEZsxIeRyfFcp/SKCl+h1BcrB8QPX9WcPbmXMzZgfzCf60vsxnSbRkJE3laTylLR/9hlEYEqdVo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699390158935495.85318498541824; Tue, 7 Nov 2023 12:49:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0Szw-0006cp-EY; Tue, 07 Nov 2023 15:48:32 -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 1r0Szu-0006av-Ht; Tue, 07 Nov 2023 15:48:30 -0500 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0Szq-0006Rv-IA; Tue, 07 Nov 2023 15:48:30 -0500 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-41ea8debcdaso23539791cf.1; Tue, 07 Nov 2023 12:48:20 -0800 (PST) Received: from grind.. ([179.193.10.161]) by smtp.gmail.com with ESMTPSA id d13-20020ac8544d000000b0041eb13a8195sm48946qtq.61.2023.11.07.12.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 12:48:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699390099; x=1699994899; darn=nongnu.org; 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=fPSm70mzujJdjsDPq7I1QjRN11RaLzEgW4IMuLkB9Mg=; b=TYqsI480AOhkttw4HOqcC3S0DhasLTjYWWiOQ3Xko9iw29qxIaOxfSVJsTtV9lDW3e p10FYvKVvUvZ6h48RuWGKkCOJRf7tIEBZPKkaSs2hBhDo3eVQ/JdM/uBFl6eeKfG0doY rbtqR2/yK2+Ok0A06LYB8AYmNfxjh9sElVAwlyfwMWN6oA8Y9hVT4hormgGgiNNAqtBL UwvF1p6PWcHejP6tMZZ/+2gOA9yXFxjRcl6kdlkPwk47BeDNFd7W0WbBz10FYMhU0dx1 3cVnoROawEEkbQLufoMamYaXtx1FaJyychwkVzgV9JFhTOpUz6HKbPvM2+gzCWaiwWX3 Vj7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699390099; x=1699994899; 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=fPSm70mzujJdjsDPq7I1QjRN11RaLzEgW4IMuLkB9Mg=; b=slJddcM/7ejMpcqR6CegrI/JXP1IKIG+foIxK+3YaCuU85sDQ5AZ/sUcYu9l2E0uLt POWDPek6KPwsvVIReOfR6K5pH6Y4aEA0bVDVPwBerQ6wnLX9+sppY7h+CEATDMazORUV Tx/1osNxOu1Fi7jvLyMZIHarE2QMkuCUB+tjghVHory76T1IS265LgTPULExv3om3TIB VhmwfW5QOZsgBO9Pw6W0qkEgi3YpRPG1tacYBnjzRSNn3QGSUCJ07lf3j4dGyMRahMnT ShFF8+Lk0N8xQTmf9yDgw2IrnluDObR3qow3BImSUtj1TQOkYOJFPXRNmgLbwmQXLma0 MAQA== X-Gm-Message-State: AOJu0YyLS7VRzd2eNW09ygXighwP/thM64PaFf5PH6T4bjecq0fUSrvl dYfnQPHB+I9gLzq5XF1wgTG6L8guRkc= X-Google-Smtp-Source: AGHT+IFOV+LaV+1IASQ5Ea0amHqUpjLgwR/s0s3GplAlsmuGgCYmiYpyQamKxf7AozLfMo4wQ/IOdw== X-Received: by 2002:a05:622a:138f:b0:41c:dd28:d16f with SMTP id o15-20020a05622a138f00b0041cdd28d16fmr40449596qtk.55.1699390098698; Tue, 07 Nov 2023 12:48:18 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, danielhb413@gmail.com, peter.maydell@linaro.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Glenn Miles Subject: [PULL 4/9] ppc/pnv: Add an I2C controller model Date: Tue, 7 Nov 2023 17:48:01 -0300 Message-ID: <20231107204806.8507-5-danielhb413@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107204806.8507-1-danielhb413@gmail.com> References: <20231107204806.8507-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::832; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x832.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1699390161275100005 From: C=C3=A9dric Le Goater The more recent IBM power processors have an embedded I2C controller that is accessible by software via the XSCOM address space. Each instance of the I2C controller is capable of controlling multiple I2C buses (one at a time). Prior to beginning a transaction on an I2C bus, the bus must be selected by writing the port number associated with the bus into the PORT_NUM field of the MODE register. Once an I2C bus is selected, the status of the bus can be determined by reading the Status and Extended Status registers. I2C bus transactions can be started by writing a command to the Command register and reading/writing data from/to the FIFO register. Not supported : . 10 bit I2C addresses . Multimaster . Slave Signed-off-by: C=C3=A9dric Le Goater [milesg: Split wiring to powernv9 into its own commit] [milesg: Added more detail to commit message] [milesg: Added SPDX Licensed Identifier to new files] [milesg: updated copyright dates] [milesg: Added use of g_autofree] [milesg: Added NULL check after pnv_i2c_get_bus] Signed-off-by: Glenn Miles Acked-by: Daniel Henrique Barboza Message-ID: <20231016222013.3739530-2-milesg@linux.vnet.ibm.com> Signed-off-by: Daniel Henrique Barboza --- hw/ppc/meson.build | 1 + hw/ppc/pnv_i2c.c | 697 +++++++++++++++++++++++++++++++++++++ include/hw/ppc/pnv_i2c.h | 38 ++ include/hw/ppc/pnv_xscom.h | 3 + 4 files changed, 739 insertions(+) create mode 100644 hw/ppc/pnv_i2c.c create mode 100644 include/hw/ppc/pnv_i2c.h diff --git a/hw/ppc/meson.build b/hw/ppc/meson.build index 7338f9432a..ea44856d43 100644 --- a/hw/ppc/meson.build +++ b/hw/ppc/meson.build @@ -43,6 +43,7 @@ ppc_ss.add(when: 'CONFIG_POWERNV', if_true: files( 'pnv.c', 'pnv_xscom.c', 'pnv_core.c', + 'pnv_i2c.c', 'pnv_lpc.c', 'pnv_psi.c', 'pnv_occ.c', diff --git a/hw/ppc/pnv_i2c.c b/hw/ppc/pnv_i2c.c new file mode 100644 index 0000000000..f75e59e709 --- /dev/null +++ b/hw/ppc/pnv_i2c.c @@ -0,0 +1,697 @@ +/* + * QEMU PowerPC PowerNV Processor I2C model + * + * Copyright (c) 2019-2023, IBM Corporation. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/module.h" +#include "qemu/log.h" +#include "sysemu/reset.h" + +#include "hw/irq.h" +#include "hw/qdev-properties.h" + +#include "hw/ppc/pnv.h" +#include "hw/ppc/pnv_chip.h" +#include "hw/ppc/pnv_i2c.h" +#include "hw/ppc/pnv_xscom.h" +#include "hw/ppc/fdt.h" + +#include + +/* I2C FIFO register */ +#define I2C_FIFO_REG 0x4 +#define I2C_FIFO PPC_BITMASK(0, 7) + +/* I2C command register */ +#define I2C_CMD_REG 0x5 +#define I2C_CMD_WITH_START PPC_BIT(0) +#define I2C_CMD_WITH_ADDR PPC_BIT(1) +#define I2C_CMD_READ_CONT PPC_BIT(2) +#define I2C_CMD_WITH_STOP PPC_BIT(3) +#define I2C_CMD_INTR_STEERING PPC_BITMASK(6, 7) /* P9 */ +#define I2C_CMD_INTR_STEER_HOST 1 +#define I2C_CMD_INTR_STEER_OCC 2 +#define I2C_CMD_DEV_ADDR PPC_BITMASK(8, 14) +#define I2C_CMD_READ_NOT_WRITE PPC_BIT(15) +#define I2C_CMD_LEN_BYTES PPC_BITMASK(16, 31) +#define I2C_MAX_TFR_LEN 0xfff0ull + +/* I2C mode register */ +#define I2C_MODE_REG 0x6 +#define I2C_MODE_BIT_RATE_DIV PPC_BITMASK(0, 15) +#define I2C_MODE_PORT_NUM PPC_BITMASK(16, 21) +#define I2C_MODE_ENHANCED PPC_BIT(28) +#define I2C_MODE_DIAGNOSTIC PPC_BIT(29) +#define I2C_MODE_PACING_ALLOW PPC_BIT(30) +#define I2C_MODE_WRAP PPC_BIT(31) + +/* I2C watermark register */ +#define I2C_WATERMARK_REG 0x7 +#define I2C_WATERMARK_HIGH PPC_BITMASK(16, 19) +#define I2C_WATERMARK_LOW PPC_BITMASK(24, 27) + +/* + * I2C interrupt mask and condition registers + * + * NB: The function of 0x9 and 0xa changes depending on whether you're rea= ding + * or writing to them. When read they return the interrupt condition b= its + * and on writes they update the interrupt mask register. + * + * The bit definitions are the same for all the interrupt registers. + */ +#define I2C_INTR_MASK_REG 0x8 + +#define I2C_INTR_RAW_COND_REG 0x9 /* read */ +#define I2C_INTR_MASK_OR_REG 0x9 /* write*/ + +#define I2C_INTR_COND_REG 0xa /* read */ +#define I2C_INTR_MASK_AND_REG 0xa /* write */ + +#define I2C_INTR_ALL PPC_BITMASK(16, 31) +#define I2C_INTR_INVALID_CMD PPC_BIT(16) +#define I2C_INTR_LBUS_PARITY_ERR PPC_BIT(17) +#define I2C_INTR_BKEND_OVERRUN_ERR PPC_BIT(18) +#define I2C_INTR_BKEND_ACCESS_ERR PPC_BIT(19) +#define I2C_INTR_ARBT_LOST_ERR PPC_BIT(20) +#define I2C_INTR_NACK_RCVD_ERR PPC_BIT(21) +#define I2C_INTR_DATA_REQ PPC_BIT(22) +#define I2C_INTR_CMD_COMP PPC_BIT(23) +#define I2C_INTR_STOP_ERR PPC_BIT(24) +#define I2C_INTR_I2C_BUSY PPC_BIT(25) +#define I2C_INTR_NOT_I2C_BUSY PPC_BIT(26) +#define I2C_INTR_SCL_EQ_1 PPC_BIT(28) +#define I2C_INTR_SCL_EQ_0 PPC_BIT(29) +#define I2C_INTR_SDA_EQ_1 PPC_BIT(30) +#define I2C_INTR_SDA_EQ_0 PPC_BIT(31) + +/* I2C status register */ +#define I2C_RESET_I2C_REG 0xb /* write */ +#define I2C_RESET_ERRORS 0xc +#define I2C_STAT_REG 0xb /* read */ +#define I2C_STAT_INVALID_CMD PPC_BIT(0) +#define I2C_STAT_LBUS_PARITY_ERR PPC_BIT(1) +#define I2C_STAT_BKEND_OVERRUN_ERR PPC_BIT(2) +#define I2C_STAT_BKEND_ACCESS_ERR PPC_BIT(3) +#define I2C_STAT_ARBT_LOST_ERR PPC_BIT(4) +#define I2C_STAT_NACK_RCVD_ERR PPC_BIT(5) +#define I2C_STAT_DATA_REQ PPC_BIT(6) +#define I2C_STAT_CMD_COMP PPC_BIT(7) +#define I2C_STAT_STOP_ERR PPC_BIT(8) +#define I2C_STAT_UPPER_THRS PPC_BITMASK(9, 15) +#define I2C_STAT_ANY_I2C_INTR PPC_BIT(16) +#define I2C_STAT_PORT_HISTORY_BUSY PPC_BIT(19) +#define I2C_STAT_SCL_INPUT_LEVEL PPC_BIT(20) +#define I2C_STAT_SDA_INPUT_LEVEL PPC_BIT(21) +#define I2C_STAT_PORT_BUSY PPC_BIT(22) +#define I2C_STAT_INTERFACE_BUSY PPC_BIT(23) +#define I2C_STAT_FIFO_ENTRY_COUNT PPC_BITMASK(24, 31) + +#define I2C_STAT_ANY_ERR (I2C_STAT_INVALID_CMD | I2C_STAT_LBUS_PARITY_ERR = | \ + I2C_STAT_BKEND_OVERRUN_ERR | \ + I2C_STAT_BKEND_ACCESS_ERR | I2C_STAT_ARBT_LOST_E= RR | \ + I2C_STAT_NACK_RCVD_ERR | I2C_STAT_STOP_ERR) + + +#define I2C_INTR_ACTIVE \ + ((I2C_STAT_ANY_ERR >> 16) | I2C_INTR_CMD_COMP | I2C_INTR_DATA_REQ) + +/* Pseudo-status used for timeouts */ +#define I2C_STAT_PSEUDO_TIMEOUT PPC_BIT(63) + +/* I2C extended status register */ +#define I2C_EXTD_STAT_REG 0xc +#define I2C_EXTD_STAT_FIFO_SIZE PPC_BITMASK(0, 7) +#define I2C_EXTD_STAT_MSM_CURSTATE PPC_BITMASK(11, 15) +#define I2C_EXTD_STAT_SCL_IN_SYNC PPC_BIT(16) +#define I2C_EXTD_STAT_SDA_IN_SYNC PPC_BIT(17) +#define I2C_EXTD_STAT_S_SCL PPC_BIT(18) +#define I2C_EXTD_STAT_S_SDA PPC_BIT(19) +#define I2C_EXTD_STAT_M_SCL PPC_BIT(20) +#define I2C_EXTD_STAT_M_SDA PPC_BIT(21) +#define I2C_EXTD_STAT_HIGH_WATER PPC_BIT(22) +#define I2C_EXTD_STAT_LOW_WATER PPC_BIT(23) +#define I2C_EXTD_STAT_I2C_BUSY PPC_BIT(24) +#define I2C_EXTD_STAT_SELF_BUSY PPC_BIT(25) +#define I2C_EXTD_STAT_I2C_VERSION PPC_BITMASK(27, 31) + +/* I2C residual front end/back end length */ +#define I2C_RESIDUAL_LEN_REG 0xd +#define I2C_RESIDUAL_FRONT_END PPC_BITMASK(0, 15) +#define I2C_RESIDUAL_BACK_END PPC_BITMASK(16, 31) + +/* Port busy register */ +#define I2C_PORT_BUSY_REG 0xe +#define I2C_SET_S_SCL_REG 0xd +#define I2C_RESET_S_SCL_REG 0xf +#define I2C_SET_S_SDA_REG 0x10 +#define I2C_RESET_S_SDA_REG 0x11 + +#define PNV_I2C_FIFO_SIZE 8 + +static I2CBus *pnv_i2c_get_bus(PnvI2C *i2c) +{ + uint8_t port =3D GETFIELD(I2C_MODE_PORT_NUM, i2c->regs[I2C_MODE_REG]); + + if (port >=3D i2c->num_busses) { + qemu_log_mask(LOG_GUEST_ERROR, "I2C: invalid bus number %d/%d\n", = port, + i2c->num_busses); + return NULL; + } + return i2c->busses[port]; +} + +static void pnv_i2c_update_irq(PnvI2C *i2c) +{ + I2CBus *bus =3D pnv_i2c_get_bus(i2c); + bool recv =3D !!(i2c->regs[I2C_CMD_REG] & I2C_CMD_READ_NOT_WRITE); + uint16_t front_end =3D GETFIELD(I2C_RESIDUAL_FRONT_END, + i2c->regs[I2C_RESIDUAL_LEN_REG]); + uint16_t back_end =3D GETFIELD(I2C_RESIDUAL_BACK_END, + i2c->regs[I2C_RESIDUAL_LEN_REG]); + uint8_t fifo_count =3D GETFIELD(I2C_STAT_FIFO_ENTRY_COUNT, + i2c->regs[I2C_STAT_REG]); + uint8_t fifo_free =3D PNV_I2C_FIFO_SIZE - fifo_count; + + if (!bus) { + qemu_log_mask(LOG_GUEST_ERROR, "I2C: invalid port\n"); + return; + } + + if (i2c_bus_busy(bus)) { + i2c->regs[I2C_STAT_REG] &=3D ~I2C_STAT_DATA_REQ; + + if (recv) { + if (fifo_count >=3D + GETFIELD(I2C_WATERMARK_HIGH, i2c->regs[I2C_WATERMARK_REG])= ) { + i2c->regs[I2C_EXTD_STAT_REG] |=3D I2C_EXTD_STAT_HIGH_WATER; + } else { + i2c->regs[I2C_EXTD_STAT_REG] &=3D ~I2C_EXTD_STAT_HIGH_WATE= R; + } + + if (((i2c->regs[I2C_EXTD_STAT_REG] & I2C_EXTD_STAT_HIGH_WATER)= && + fifo_count !=3D 0) || front_end =3D=3D 0) { + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_DATA_REQ; + } + } else { + if (fifo_count <=3D + GETFIELD(I2C_WATERMARK_LOW, i2c->regs[I2C_WATERMARK_REG]))= { + i2c->regs[I2C_EXTD_STAT_REG] |=3D I2C_EXTD_STAT_LOW_WATER; + } else { + i2c->regs[I2C_EXTD_STAT_REG] &=3D ~I2C_EXTD_STAT_LOW_WATER; + } + + if (back_end > 0 && + (fifo_free >=3D back_end || + (i2c->regs[I2C_EXTD_STAT_REG] & I2C_EXTD_STAT_LOW_WATER))= ) { + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_DATA_REQ; + } + } + + if (back_end =3D=3D 0 && front_end =3D=3D 0) { + i2c->regs[I2C_STAT_REG] &=3D ~I2C_STAT_DATA_REQ; + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_CMD_COMP; + + if (i2c->regs[I2C_CMD_REG] & I2C_CMD_WITH_STOP) { + i2c_end_transfer(bus); + i2c->regs[I2C_EXTD_STAT_REG] &=3D + ~(I2C_EXTD_STAT_I2C_BUSY | I2C_EXTD_STAT_SELF_BUSY); + } + } else { + i2c->regs[I2C_STAT_REG] &=3D ~I2C_STAT_CMD_COMP; + } + } + + /* + * Status and interrupt registers have nearly the same layout. + */ + i2c->regs[I2C_INTR_RAW_COND_REG] =3D i2c->regs[I2C_STAT_REG] >> 16; + i2c->regs[I2C_INTR_COND_REG] =3D + i2c->regs[I2C_INTR_RAW_COND_REG] & i2c->regs[I2C_INTR_MASK_REG]; + + qemu_set_irq(i2c->psi_irq, i2c->regs[I2C_INTR_COND_REG] !=3D 0); +} + +static void pnv_i2c_fifo_update_count(PnvI2C *i2c) +{ + uint64_t stat =3D i2c->regs[I2C_STAT_REG]; + + i2c->regs[I2C_STAT_REG] =3D SETFIELD(I2C_STAT_FIFO_ENTRY_COUNT, stat, + fifo8_num_used(&i2c->fifo)); +} + +static void pnv_i2c_frontend_update(PnvI2C *i2c) +{ + uint64_t residual_end =3D i2c->regs[I2C_RESIDUAL_LEN_REG]; + uint16_t front_end =3D GETFIELD(I2C_RESIDUAL_FRONT_END, residual_end); + + i2c->regs[I2C_RESIDUAL_LEN_REG] =3D + SETFIELD(I2C_RESIDUAL_FRONT_END, residual_end, front_end - 1); +} + +static void pnv_i2c_fifo_flush(PnvI2C *i2c) +{ + I2CBus *bus =3D pnv_i2c_get_bus(i2c); + uint8_t data; + int ret; + + if (!bus) { + qemu_log_mask(LOG_GUEST_ERROR, "I2C: invalid port\n"); + return; + } + if (!i2c_bus_busy(bus)) { + return; + } + + if (i2c->regs[I2C_CMD_REG] & I2C_CMD_READ_NOT_WRITE) { + if (fifo8_is_full(&i2c->fifo)) { + return; + } + + data =3D i2c_recv(bus); + fifo8_push(&i2c->fifo, data); + } else { + if (fifo8_is_empty(&i2c->fifo)) { + return; + } + + data =3D fifo8_pop(&i2c->fifo); + ret =3D i2c_send(bus, data); + if (ret) { + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_NACK_RCVD_ERR; + i2c_end_transfer(bus); + } + } + + pnv_i2c_fifo_update_count(i2c); + pnv_i2c_frontend_update(i2c); +} + +static void pnv_i2c_handle_cmd(PnvI2C *i2c, uint64_t val) +{ + I2CBus *bus =3D pnv_i2c_get_bus(i2c); + uint8_t addr =3D GETFIELD(I2C_CMD_DEV_ADDR, val); + int recv =3D !!(val & I2C_CMD_READ_NOT_WRITE); + uint32_t len_bytes =3D GETFIELD(I2C_CMD_LEN_BYTES, val); + + if (!(val & I2C_CMD_WITH_START) && !(val & I2C_CMD_WITH_ADDR) && + !(val & I2C_CMD_WITH_STOP) && !len_bytes) { + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_INVALID_CMD; + qemu_log_mask(LOG_GUEST_ERROR, "I2C: invalid command 0x%"PRIx64"\n= ", + val); + return; + } + + if (!(i2c->regs[I2C_STAT_REG] & I2C_STAT_CMD_COMP)) { + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_INVALID_CMD; + qemu_log_mask(LOG_GUEST_ERROR, "I2C: command in progress\n"); + return; + } + + if (!bus) { + qemu_log_mask(LOG_GUEST_ERROR, "I2C: invalid port\n"); + return; + } + + i2c->regs[I2C_RESIDUAL_LEN_REG] =3D + SETFIELD(I2C_RESIDUAL_FRONT_END, 0ull, len_bytes) | + SETFIELD(I2C_RESIDUAL_BACK_END, 0ull, len_bytes); + + if (val & I2C_CMD_WITH_START) { + if (i2c_start_transfer(bus, addr, recv)) { + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_NACK_RCVD_ERR; + } else { + i2c->regs[I2C_EXTD_STAT_REG] |=3D + (I2C_EXTD_STAT_I2C_BUSY | I2C_EXTD_STAT_SELF_BUSY); + pnv_i2c_fifo_flush(i2c); + } + } +} + +static void pnv_i2c_backend_update(PnvI2C *i2c) +{ + uint64_t residual_end =3D i2c->regs[I2C_RESIDUAL_LEN_REG]; + uint16_t back_end =3D GETFIELD(I2C_RESIDUAL_BACK_END, residual_end); + + if (!back_end) { + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_BKEND_ACCESS_ERR; + return; + } + + i2c->regs[I2C_RESIDUAL_LEN_REG] =3D + SETFIELD(I2C_RESIDUAL_BACK_END, residual_end, back_end - 1); +} + +static void pnv_i2c_fifo_in(PnvI2C *i2c) +{ + uint8_t data =3D GETFIELD(I2C_FIFO, i2c->regs[I2C_FIFO_REG]); + I2CBus *bus =3D pnv_i2c_get_bus(i2c); + + if (!bus) { + qemu_log_mask(LOG_GUEST_ERROR, "I2C: invalid port\n"); + return; + } + + if (!i2c_bus_busy(bus)) { + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_INVALID_CMD; + qemu_log_mask(LOG_GUEST_ERROR, "I2C: no command in progress\n"); + return; + } + + if (i2c->regs[I2C_CMD_REG] & I2C_CMD_READ_NOT_WRITE) { + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_INVALID_CMD; + qemu_log_mask(LOG_GUEST_ERROR, "I2C: read command in progress\n"); + return; + } + + if (fifo8_is_full(&i2c->fifo)) { + if (!(i2c->regs[I2C_MODE_REG] & I2C_MODE_PACING_ALLOW)) { + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_BKEND_OVERRUN_ERR; + } + return; + } + + fifo8_push(&i2c->fifo, data); + pnv_i2c_fifo_update_count(i2c); + pnv_i2c_backend_update(i2c); + pnv_i2c_fifo_flush(i2c); +} + +static void pnv_i2c_fifo_out(PnvI2C *i2c) +{ + uint8_t data; + I2CBus *bus =3D pnv_i2c_get_bus(i2c); + + if (!bus) { + qemu_log_mask(LOG_GUEST_ERROR, "I2C: invalid port\n"); + return; + } + + if (!i2c_bus_busy(bus)) { + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_INVALID_CMD; + qemu_log_mask(LOG_GUEST_ERROR, "I2C: no command in progress\n"); + return; + } + + if (!(i2c->regs[I2C_CMD_REG] & I2C_CMD_READ_NOT_WRITE)) { + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_INVALID_CMD; + qemu_log_mask(LOG_GUEST_ERROR, "I2C: write command in progress\n"); + return; + } + + if (fifo8_is_empty(&i2c->fifo)) { + if (!(i2c->regs[I2C_MODE_REG] & I2C_MODE_PACING_ALLOW)) { + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_BKEND_OVERRUN_ERR; + } + return; + } + + data =3D fifo8_pop(&i2c->fifo); + + i2c->regs[I2C_FIFO_REG] =3D SETFIELD(I2C_FIFO, 0ull, data); + pnv_i2c_fifo_update_count(i2c); + pnv_i2c_backend_update(i2c); +} + +static uint64_t pnv_i2c_xscom_read(void *opaque, hwaddr addr, + unsigned size) +{ + PnvI2C *i2c =3D PNV_I2C(opaque); + uint32_t offset =3D addr >> 3; + uint64_t val =3D -1; + int i; + + switch (offset) { + case I2C_STAT_REG: + val =3D i2c->regs[offset]; + break; + + case I2C_FIFO_REG: + pnv_i2c_fifo_out(i2c); + val =3D i2c->regs[offset]; + break; + + case I2C_PORT_BUSY_REG: /* compute busy bit for each port */ + val =3D 0; + for (i =3D 0; i < i2c->num_busses; i++) { + val |=3D i2c_bus_busy(i2c->busses[i]) << i; + } + break; + + case I2C_CMD_REG: + case I2C_MODE_REG: + case I2C_WATERMARK_REG: + case I2C_INTR_MASK_REG: + case I2C_INTR_RAW_COND_REG: + case I2C_INTR_COND_REG: + case I2C_EXTD_STAT_REG: + case I2C_RESIDUAL_LEN_REG: + val =3D i2c->regs[offset]; + break; + default: + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_INVALID_CMD; + qemu_log_mask(LOG_GUEST_ERROR, "I2C: read at register: 0x%" + HWADDR_PRIx "\n", addr >> 3); + } + + pnv_i2c_update_irq(i2c); + + return val; +} + +static void pnv_i2c_xscom_write(void *opaque, hwaddr addr, + uint64_t val, unsigned size) +{ + PnvI2C *i2c =3D PNV_I2C(opaque); + uint32_t offset =3D addr >> 3; + + switch (offset) { + case I2C_MODE_REG: + { + i2c->regs[offset] =3D val; + I2CBus *bus =3D pnv_i2c_get_bus(i2c); + if (!bus) { + qemu_log_mask(LOG_GUEST_ERROR, "I2C: invalid port\n"); + return; + } + if (i2c_bus_busy(bus)) { + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_INVALID_CMD; + qemu_log_mask(LOG_GUEST_ERROR, "I2C: command in progress\n= "); + } + } + break; + + case I2C_CMD_REG: + i2c->regs[offset] =3D val; + pnv_i2c_handle_cmd(i2c, val); + break; + + case I2C_FIFO_REG: + i2c->regs[offset] =3D val; + pnv_i2c_fifo_in(i2c); + break; + + case I2C_WATERMARK_REG: + i2c->regs[offset] =3D val; + break; + + case I2C_RESET_I2C_REG: + i2c->regs[I2C_MODE_REG] =3D 0; + i2c->regs[I2C_CMD_REG] =3D 0; + i2c->regs[I2C_WATERMARK_REG] =3D 0; + i2c->regs[I2C_INTR_MASK_REG] =3D 0; + i2c->regs[I2C_INTR_COND_REG] =3D 0; + i2c->regs[I2C_INTR_RAW_COND_REG] =3D 0; + i2c->regs[I2C_STAT_REG] =3D 0; + i2c->regs[I2C_RESIDUAL_LEN_REG] =3D 0; + i2c->regs[I2C_EXTD_STAT_REG] &=3D + (I2C_EXTD_STAT_FIFO_SIZE | I2C_EXTD_STAT_I2C_VERSION); + break; + + case I2C_RESET_ERRORS: + i2c->regs[I2C_STAT_REG] &=3D ~I2C_STAT_ANY_ERR; + i2c->regs[I2C_RESIDUAL_LEN_REG] =3D 0; + i2c->regs[I2C_EXTD_STAT_REG] &=3D + (I2C_EXTD_STAT_FIFO_SIZE | I2C_EXTD_STAT_I2C_VERSION); + fifo8_reset(&i2c->fifo); + break; + + case I2C_INTR_MASK_REG: + i2c->regs[offset] =3D val; + break; + + case I2C_INTR_MASK_OR_REG: + i2c->regs[I2C_INTR_MASK_REG] |=3D val; + break; + + case I2C_INTR_MASK_AND_REG: + i2c->regs[I2C_INTR_MASK_REG] &=3D val; + break; + + case I2C_PORT_BUSY_REG: + case I2C_SET_S_SCL_REG: + case I2C_RESET_S_SCL_REG: + case I2C_SET_S_SDA_REG: + case I2C_RESET_S_SDA_REG: + i2c->regs[offset] =3D val; + break; + default: + i2c->regs[I2C_STAT_REG] |=3D I2C_STAT_INVALID_CMD; + qemu_log_mask(LOG_GUEST_ERROR, "I2C: write at register: 0x%" + HWADDR_PRIx " val=3D0x%"PRIx64"\n", addr >> 3, val); + } + + pnv_i2c_update_irq(i2c); +} + +static const MemoryRegionOps pnv_i2c_xscom_ops =3D { + .read =3D pnv_i2c_xscom_read, + .write =3D pnv_i2c_xscom_write, + .valid.min_access_size =3D 8, + .valid.max_access_size =3D 8, + .impl.min_access_size =3D 8, + .impl.max_access_size =3D 8, + .endianness =3D DEVICE_BIG_ENDIAN, +}; + +static int pnv_i2c_bus_dt_xscom(PnvI2C *i2c, void *fdt, + int offset, int index) +{ + int i2c_bus_offset; + const char i2c_compat[] =3D + "ibm,opal-i2c\0ibm,power8-i2c-port\0ibm,power9-i2c-port"; + g_autofree char *i2c_port_name =3D NULL; + g_autofree char *name =3D g_strdup_printf("i2c-bus@%x", index); + + i2c_bus_offset =3D fdt_add_subnode(fdt, offset, name); + _FDT(i2c_bus_offset); + + _FDT((fdt_setprop_cell(fdt, i2c_bus_offset, "reg", index))); + _FDT((fdt_setprop_cell(fdt, i2c_bus_offset, "#address-cells", 1))); + _FDT((fdt_setprop_cell(fdt, i2c_bus_offset, "#size-cells", 0))); + _FDT(fdt_setprop(fdt, i2c_bus_offset, "compatible", i2c_compat, + sizeof(i2c_compat))); + _FDT((fdt_setprop_cell(fdt, i2c_bus_offset, "bus-frequency", 400000))); + + i2c_port_name =3D g_strdup_printf("p8_%08x_e%dp%d", i2c->chip->chip_id, + i2c->engine, index); + _FDT(fdt_setprop_string(fdt, i2c_bus_offset, "ibm,port-name", + i2c_port_name)); + return 0; +} + +#define XSCOM_BUS_FREQUENCY 466500000 +#define I2C_CLOCK_FREQUENCY (XSCOM_BUS_FREQUENCY / 4) + +static int pnv_i2c_dt_xscom(PnvXScomInterface *dev, void *fdt, + int offset) +{ + PnvI2C *i2c =3D PNV_I2C(dev); + int i2c_offset; + const char i2c_compat[] =3D "ibm,power8-i2cm\0ibm,power9-i2cm"; + uint32_t i2c_pcba =3D PNV9_XSCOM_I2CM_BASE + + i2c->engine * PNV9_XSCOM_I2CM_SIZE; + uint32_t reg[2] =3D { + cpu_to_be32(i2c_pcba), + cpu_to_be32(PNV9_XSCOM_I2CM_SIZE) + }; + int i; + g_autofree char *name =3D g_strdup_printf("i2cm@%x", i2c_pcba); + + i2c_offset =3D fdt_add_subnode(fdt, offset, name); + _FDT(i2c_offset); + + _FDT(fdt_setprop(fdt, i2c_offset, "reg", reg, sizeof(reg))); + + _FDT((fdt_setprop_cell(fdt, i2c_offset, "#address-cells", 1))); + _FDT((fdt_setprop_cell(fdt, i2c_offset, "#size-cells", 0))); + _FDT(fdt_setprop(fdt, i2c_offset, "compatible", i2c_compat, + sizeof(i2c_compat))); + _FDT((fdt_setprop_cell(fdt, i2c_offset, "chip-engine#", i2c->engine))); + _FDT((fdt_setprop_cell(fdt, i2c_offset, "clock-frequency", + I2C_CLOCK_FREQUENCY))); + + for (i =3D 0; i < i2c->num_busses; i++) { + pnv_i2c_bus_dt_xscom(i2c, fdt, i2c_offset, i); + } + return 0; +} + +static void pnv_i2c_reset(void *dev) +{ + PnvI2C *i2c =3D PNV_I2C(dev); + + memset(i2c->regs, 0, sizeof(i2c->regs)); + + i2c->regs[I2C_STAT_REG] =3D I2C_STAT_CMD_COMP; + i2c->regs[I2C_EXTD_STAT_REG] =3D + SETFIELD(I2C_EXTD_STAT_FIFO_SIZE, 0ull, PNV_I2C_FIFO_SIZE) | + SETFIELD(I2C_EXTD_STAT_I2C_VERSION, 0ull, 23); /* last version */ + + fifo8_reset(&i2c->fifo); +} + +static void pnv_i2c_realize(DeviceState *dev, Error **errp) +{ + PnvI2C *i2c =3D PNV_I2C(dev); + int i; + + assert(i2c->chip); + + pnv_xscom_region_init(&i2c->xscom_regs, OBJECT(i2c), &pnv_i2c_xscom_op= s, + i2c, "xscom-i2c", PNV9_XSCOM_I2CM_SIZE); + + i2c->busses =3D g_new(I2CBus *, i2c->num_busses); + for (i =3D 0; i < i2c->num_busses; i++) { + char name[32]; + + snprintf(name, sizeof(name), TYPE_PNV_I2C ".%d", i); + i2c->busses[i] =3D i2c_init_bus(dev, name); + } + + fifo8_create(&i2c->fifo, PNV_I2C_FIFO_SIZE); + + qemu_register_reset(pnv_i2c_reset, dev); + + qdev_init_gpio_out(DEVICE(dev), &i2c->psi_irq, 1); +} + +static Property pnv_i2c_properties[] =3D { + DEFINE_PROP_LINK("chip", PnvI2C, chip, TYPE_PNV_CHIP, PnvChip *), + DEFINE_PROP_UINT32("engine", PnvI2C, engine, 1), + DEFINE_PROP_UINT32("num-busses", PnvI2C, num_busses, 1), + DEFINE_PROP_END_OF_LIST(), +}; + +static void pnv_i2c_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + PnvXScomInterfaceClass *xscomc =3D PNV_XSCOM_INTERFACE_CLASS(klass); + + xscomc->dt_xscom =3D pnv_i2c_dt_xscom; + + dc->desc =3D "PowerNV I2C"; + dc->realize =3D pnv_i2c_realize; + device_class_set_props(dc, pnv_i2c_properties); +} + +static const TypeInfo pnv_i2c_info =3D { + .name =3D TYPE_PNV_I2C, + .parent =3D TYPE_DEVICE, + .instance_size =3D sizeof(PnvI2C), + .class_init =3D pnv_i2c_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_PNV_XSCOM_INTERFACE }, + { } + } +}; + +static void pnv_i2c_register_types(void) +{ + type_register_static(&pnv_i2c_info); +} + +type_init(pnv_i2c_register_types); diff --git a/include/hw/ppc/pnv_i2c.h b/include/hw/ppc/pnv_i2c.h new file mode 100644 index 0000000000..1a37730f1e --- /dev/null +++ b/include/hw/ppc/pnv_i2c.h @@ -0,0 +1,38 @@ +/* + * QEMU PowerPC PowerNV Processor I2C model + * + * Copyright (c) 2019-2023, IBM Corporation. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef PPC_PNV_I2C_H +#define PPC_PNV_I2C_H + +#include "hw/ppc/pnv.h" +#include "hw/i2c/i2c.h" +#include "qemu/fifo8.h" + +#define TYPE_PNV_I2C "pnv-i2c" +#define PNV_I2C(obj) OBJECT_CHECK(PnvI2C, (obj), TYPE_PNV_I2C) + +#define PNV_I2C_REGS 0x20 + +typedef struct PnvI2C { + DeviceState parent; + + struct PnvChip *chip; + + qemu_irq psi_irq; + + uint64_t regs[PNV_I2C_REGS]; + uint32_t engine; + uint32_t num_busses; + I2CBus **busses; + + MemoryRegion xscom_regs; + + Fifo8 fifo; +} PnvI2C; + +#endif /* PPC_PNV_I2C_H */ diff --git a/include/hw/ppc/pnv_xscom.h b/include/hw/ppc/pnv_xscom.h index 35b19610f7..056392ab60 100644 --- a/include/hw/ppc/pnv_xscom.h +++ b/include/hw/ppc/pnv_xscom.h @@ -90,6 +90,9 @@ struct PnvXScomInterfaceClass { ((uint64_t)(((core) & 0x1C) + 0x40) << 22) #define PNV9_XSCOM_EQ_SIZE 0x100000 =20 +#define PNV9_XSCOM_I2CM_BASE 0xa0000 +#define PNV9_XSCOM_I2CM_SIZE 0x1000 + #define PNV9_XSCOM_OCC_BASE PNV_XSCOM_OCC_BASE #define PNV9_XSCOM_OCC_SIZE 0x8000 =20 --=20 2.41.0 From nobody Wed Nov 27 10:01:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1699390203; cv=none; d=zohomail.com; s=zohoarc; b=Swx4flwlYs9+4Yr68vSRmWV7jUfEpN+8Me38lpdR3N+pTqONdne7qwCNcxH7gCdwE1ut+P+G8TPXmL2JGXM+nYP5jn/ZS8O7YjTcVzTMgGeK+mlbmB+p9HeLzJSLHc92mqXKd/DMijNepxBspVlP/fD2JuzYBI+ENMD+YaHqPiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699390203; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=m5xpGmY9XXVbSVdbl74ir/lrmvxBgkZdGG6zA0sfySU=; b=DQkdSse3LNVYLcRQaupa/uDH/+ejObai4G3bZF3QrF2o2NlvhbZ7nLWkdDAZMmzbtI45B/x67BfBxDqEVmQEHgiY5seSKazUAM6+LicN8CMZD6227EMbdFVU3Mn77GOH0ayAPJEuyoNsR1pXw9ieUHyRTmnX+VnzwwfBo7wK0W4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699390203385923.2849485717521; Tue, 7 Nov 2023 12:50:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0Szu-0006bD-Uq; Tue, 07 Nov 2023 15:48:30 -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 1r0Szt-0006ZO-5C; Tue, 07 Nov 2023 15:48:29 -0500 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0Szq-0006S4-AN; Tue, 07 Nov 2023 15:48:28 -0500 Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6cd09663b1cso3828877a34.3; Tue, 07 Nov 2023 12:48:24 -0800 (PST) Received: from grind.. ([179.193.10.161]) by smtp.gmail.com with ESMTPSA id d13-20020ac8544d000000b0041eb13a8195sm48946qtq.61.2023.11.07.12.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 12:48:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699390100; x=1699994900; darn=nongnu.org; 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=m5xpGmY9XXVbSVdbl74ir/lrmvxBgkZdGG6zA0sfySU=; b=Bhje6p01bbyaAHnujUflsETai8NV/oByEJ1kTEbRvSMnsTW0tcXl1CSZM9m2O1G71v jnjQK/3glBXnWD7330S0T78OHBm10wEXWyBFKPrlFA91KQIG6XeyKzOxF2Dm3kLX0olO znXKwILGst76P8FBBX7neDwGm5f8HmNwx5IRkBA/ZwQPq7DIFlmSXDOMt3kbE8jB61RU tjLgSIjN/jrkUyr02D+bLd+yLMAFklEY7aIvPYd9Cib6bB/fh61TKCfvBpyDwxwk9inb qRpE1wG6CqbwnExboPaIqqCeWYImAUlnXs1Coq1IT876mybAxKw/rhf3wen2B92O51Fi 6YeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699390100; x=1699994900; 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=m5xpGmY9XXVbSVdbl74ir/lrmvxBgkZdGG6zA0sfySU=; b=eUwGkL2S/uC4NbvxZZ7HXkqT1UIXgrTb9yO7jBFL7stuaYyfJ0VeD/0RkL8Wv4IZKY sSfbNN/ETV9Wkjh8+BTKTIdBPFCeM0PG891opNKoTPWjbMhm2bsEIu5iocm9iOiKQT36 zFwamC2VHhjuLNP2ybsQiyjq7+Ren03NQTAJi53Qe/JfF90BpXn2SMv/lysDjCWe4jog tEz94bRw+iOo9ON4iWRIktlSDzAr5cPlzsVUJir5wN0McqLkJTFw1ueKY7f5v6U7A4uQ ortPtgh9Kn6tseAaJxNq5yR4qh6t5OELIcBSG7ZqzEsKjGIlRMw087u4+DTAtujwGERr 1e6A== X-Gm-Message-State: AOJu0YyY4VJ+MiSBJW89xMpHs6k4PHhpz75tIvO3UGW2MuM19qn3ayKG MdhQUog16G1Jce5JcSifw2eRWzZGNik= X-Google-Smtp-Source: AGHT+IFx54VtUIKhQmJuOq9Ob7bCGr5mQ5U068gmVRDKnHe+KAG1sGo0xbqefdcY6BvkIEZMG/UybQ== X-Received: by 2002:a05:6830:1e57:b0:6cd:a9d:bc57 with SMTP id e23-20020a0568301e5700b006cd0a9dbc57mr32558249otj.32.1699390100725; Tue, 07 Nov 2023 12:48:20 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, danielhb413@gmail.com, peter.maydell@linaro.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Glenn Miles Subject: [PULL 5/9] ppc/pnv: Connect I2C controller model to powernv9 chip Date: Tue, 7 Nov 2023 17:48:02 -0300 Message-ID: <20231107204806.8507-6-danielhb413@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107204806.8507-1-danielhb413@gmail.com> References: <20231107204806.8507-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::335; envelope-from=danielhb413@gmail.com; helo=mail-ot1-x335.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1699390205255100003 From: C=C3=A9dric Le Goater Wires up three I2C controller instances to the powernv9 chip XSCOM address space. Each controller instance is wired up to a single I2C bus of its own. No other I2C devices are connected to the buses at this time. Signed-off-by: C=C3=A9dric Le Goater [milesg: Split wiring from addition of model itself] [milesg: Added new commit message] [milesg: Moved hardcoded attributes into PnvChipClass] [milesg: Removed TODO comment for I2C] Signed-off-by: Glenn Miles Acked-by: Daniel Henrique Barboza Message-ID: <20231016222013.3739530-3-milesg@linux.vnet.ibm.com> Signed-off-by: Daniel Henrique Barboza --- hw/ppc/pnv.c | 28 ++++++++++++++++++++++++++++ include/hw/ppc/pnv_chip.h | 8 ++++++++ 2 files changed, 36 insertions(+) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index c0e34fffbc..bb4d00e266 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1432,6 +1432,10 @@ static void pnv_chip_power9_instance_init(Object *ob= j) object_initialize_child(obj, "pec[*]", &chip9->pecs[i], TYPE_PNV_PHB4_PEC); } + + for (i =3D 0; i < pcc->i2c_num_engines; i++) { + object_initialize_child(obj, "i2c[*]", &chip9->i2c[i], TYPE_PNV_I2= C); + } } =20 static void pnv_chip_quad_realize_one(PnvChip *chip, PnvQuad *eq, @@ -1504,6 +1508,7 @@ static void pnv_chip_power9_realize(DeviceState *dev,= Error **errp) PnvChip *chip =3D PNV_CHIP(dev); Pnv9Psi *psi9 =3D &chip9->psi; Error *local_err =3D NULL; + int i; =20 /* XSCOM bridge is first */ pnv_xscom_init(chip, PNV9_XSCOM_SIZE, PNV9_XSCOM_BASE(chip)); @@ -1602,6 +1607,27 @@ static void pnv_chip_power9_realize(DeviceState *dev= , Error **errp) error_propagate(errp, local_err); return; } + + /* + * I2C + */ + for (i =3D 0; i < pcc->i2c_num_engines; i++) { + Object *obj =3D OBJECT(&chip9->i2c[i]); + + object_property_set_int(obj, "engine", i + 1, &error_fatal); + object_property_set_int(obj, "num-busses", pcc->i2c_num_ports, + &error_fatal); + object_property_set_link(obj, "chip", OBJECT(chip), &error_abort); + if (!qdev_realize(DEVICE(obj), NULL, errp)) { + return; + } + pnv_xscom_add_subregion(chip, PNV9_XSCOM_I2CM_BASE + + chip9->i2c[i].engine * PNV9_XSCOM_I2CM_SIZE, + &chip9->i2c[i].xscom_regs); + qdev_connect_gpio_out(DEVICE(&chip9->i2c[i]), 0, + qdev_get_gpio_in(DEVICE(&chip9->psi), + PSIHB9_IRQ_SBE_I2C)); + } } =20 static uint32_t pnv_chip_power9_xscom_pcba(PnvChip *chip, uint64_t addr) @@ -1629,6 +1655,8 @@ static void pnv_chip_power9_class_init(ObjectClass *k= lass, void *data) k->xscom_pcba =3D pnv_chip_power9_xscom_pcba; dc->desc =3D "PowerNV Chip POWER9"; k->num_pecs =3D PNV9_CHIP_MAX_PEC; + k->i2c_num_engines =3D PNV9_CHIP_MAX_I2C; + k->i2c_num_ports =3D PNV9_CHIP_MAX_I2C_PORTS; =20 device_class_set_parent_realize(dc, pnv_chip_power9_realize, &k->parent_realize); diff --git a/include/hw/ppc/pnv_chip.h b/include/hw/ppc/pnv_chip.h index 53e1d921d7..90cfbad1a5 100644 --- a/include/hw/ppc/pnv_chip.h +++ b/include/hw/ppc/pnv_chip.h @@ -9,6 +9,7 @@ #include "hw/ppc/pnv_psi.h" #include "hw/ppc/pnv_sbe.h" #include "hw/ppc/pnv_xive.h" +#include "hw/ppc/pnv_i2c.h" #include "hw/sysbus.h" =20 OBJECT_DECLARE_TYPE(PnvChip, PnvChipClass, @@ -86,6 +87,10 @@ struct Pnv9Chip { =20 #define PNV9_CHIP_MAX_PEC 3 PnvPhb4PecState pecs[PNV9_CHIP_MAX_PEC]; + +#define PNV9_CHIP_MAX_I2C 3 +#define PNV9_CHIP_MAX_I2C_PORTS 1 + PnvI2C i2c[PNV9_CHIP_MAX_I2C]; }; =20 /* @@ -130,6 +135,9 @@ struct PnvChipClass { uint32_t num_pecs; uint32_t num_phbs; =20 + uint32_t i2c_num_engines; + uint32_t i2c_num_ports; + DeviceRealize parent_realize; =20 uint32_t (*core_pir)(PnvChip *chip, uint32_t core_id); --=20 2.41.0 From nobody Wed Nov 27 10:01:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1699390224; cv=none; d=zohomail.com; s=zohoarc; b=G5ZY6o8ZNrbHQJqhinW/tbYc9uuFTMd5k1inq5aPFzBvFnJ0CSjRdLa/7S+FEoQGPT2rFfxBuWDJWZyQpVbocpRtKrJPfA8WrMOuG4QsPYksSRCWS2BRFr0UVCAxXXmcjT0RafMxWp8JEQP+sEhsH6hFcBV9b8aS59icxPJg5XY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699390224; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=t2SjJKUXICgckq0rxRRR2hDp8rA78V8HEAIGqAivwTg=; b=KsBs4qlo1zRiwTrfphRfZztOkMrQY52CZwHCJcUP7JfO/aT9kvDkrTKq9a6YwDcqJyAKNlUe9xuXyV4Khdc2FOausqDMyxfILNECRMbeXGcLZv7DmEDDa2P22pCMNyaAuq5TDF2rlZOnf72t5hs4jYuB0m7AANOqHLdfl2+526A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169939022485828.10085511024363; Tue, 7 Nov 2023 12:50:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0Szt-0006Zm-Ib; Tue, 07 Nov 2023 15:48:29 -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 1r0Szr-0006YB-PA; Tue, 07 Nov 2023 15:48:27 -0500 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0Szq-0006S9-2V; Tue, 07 Nov 2023 15:48:27 -0500 Received: by mail-qt1-x82c.google.com with SMTP id d75a77b69052e-41eae4ebf61so23760481cf.2; Tue, 07 Nov 2023 12:48:25 -0800 (PST) Received: from grind.. ([179.193.10.161]) by smtp.gmail.com with ESMTPSA id d13-20020ac8544d000000b0041eb13a8195sm48946qtq.61.2023.11.07.12.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 12:48:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699390102; x=1699994902; darn=nongnu.org; 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=t2SjJKUXICgckq0rxRRR2hDp8rA78V8HEAIGqAivwTg=; b=mTBI4KrQHd/8g+E/2pDStpOm//R/33YXUeFaW0DYhnWPy5K0SM2W6lrH4Z8RZPQ85z 0qNADLlsPqEVBV9/XnkmNMrKZwdeNU1URr6tYUB0K1SfwVLK7TS7gB6o0fayprnXD8E0 B8UNbd6j9wvnCpnsqumI/nASCyfmOEBz+b3qnd0HXLOYa+ppD/GOdBmiu/rCRIgSCGIy wNw5PDUjt9cnVE2tIPlFpEDrqp9lxmQLzVPAkWJ7mQpgXR/W5znJE2N9tPHoMykoN3Pz 3AhTxFVLzIiZChdlQcFeKxXqQzLfRFPsXv8JwSI14YO+2IiTBnYI/pl8kKkHG6mJyjqy eMaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699390102; x=1699994902; 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=t2SjJKUXICgckq0rxRRR2hDp8rA78V8HEAIGqAivwTg=; b=oDF7cZV3xxRWpfo5b0PFZvQqBAVwsY4OHdX45NVFDciqOFBXgo7NtHnBs0tF4ANaZ/ BIql85xvUBGQ5bDa6tGoaQ4XSbIN0q4oxYw4bhXjLWDjPK0C0fIyLO16t2ua8zdUQMZe my0M0wskBdVZ0qt9hROYHe5BllvPDSmxCK+4SZfEwJL2qv6TLZ1Ju8HZKc2BXm1oVxIM xYm85UiUL2g0OBNwbjM0nNd0B1olOuTX+yzW0p/MyNzfNkgBs7cyDwhKDgxHT+rTmzPp ig54OY7T8imutkN8dGWXxQ9RWUxCh5IKGClvxBYeGdtkaN2Bp0L8T5r8OxJsbOav16H+ dn6g== X-Gm-Message-State: AOJu0YxXAkG4rNNpy6JPtPGtczRZRs5mOzGrMA+R3gj1mToTvk/IzRs3 K/Efb2W6HnlbZV3eNiNOPN95d0B0BcQ= X-Google-Smtp-Source: AGHT+IHJVYqMpdTkfeclhEJRgbnRtbm+kyfpy223hZQigKFGHRM8kolEzVqkuyU1Hc9aRCnP3Qtkcg== X-Received: by 2002:ac8:7f83:0:b0:417:b970:f2a4 with SMTP id z3-20020ac87f83000000b00417b970f2a4mr40029225qtj.1.1699390102570; Tue, 07 Nov 2023 12:48:22 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, danielhb413@gmail.com, peter.maydell@linaro.org, Glenn Miles , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PULL 6/9] ppc/pnv: Connect PNV I2C controller to powernv10 Date: Tue, 7 Nov 2023 17:48:03 -0300 Message-ID: <20231107204806.8507-7-danielhb413@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107204806.8507-1-danielhb413@gmail.com> References: <20231107204806.8507-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82c; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x82c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1699390225299100001 From: Glenn Miles Wires up four I2C controller instances to the powernv10 chip XSCOM address space. Each controller instance is wired up to two I2C buses of its own. No other I2C devices are connected to the buses at this time. Signed-off-by: Glenn Miles Reviewed-by: C=C3=A9dric Le Goater Message-ID: <20231017221434.810363-1-milesg@linux.vnet.ibm.com> Signed-off-by: Daniel Henrique Barboza --- hw/ppc/pnv.c | 29 +++++++++++++++++++++++++++++ include/hw/ppc/pnv_chip.h | 4 ++++ include/hw/ppc/pnv_xscom.h | 3 +++ 3 files changed, 36 insertions(+) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index bb4d00e266..ae8e0b45cd 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1684,6 +1684,10 @@ static void pnv_chip_power10_instance_init(Object *o= bj) object_initialize_child(obj, "pec[*]", &chip10->pecs[i], TYPE_PNV_PHB5_PEC); } + + for (i =3D 0; i < pcc->i2c_num_engines; i++) { + object_initialize_child(obj, "i2c[*]", &chip10->i2c[i], TYPE_PNV_I= 2C); + } } =20 static void pnv_chip_power10_quad_realize(Pnv10Chip *chip10, Error **errp) @@ -1742,6 +1746,7 @@ static void pnv_chip_power10_realize(DeviceState *dev= , Error **errp) PnvChip *chip =3D PNV_CHIP(dev); Pnv10Chip *chip10 =3D PNV10_CHIP(dev); Error *local_err =3D NULL; + int i; =20 /* XSCOM bridge is first */ pnv_xscom_init(chip, PNV10_XSCOM_SIZE, PNV10_XSCOM_BASE(chip)); @@ -1847,6 +1852,28 @@ static void pnv_chip_power10_realize(DeviceState *de= v, Error **errp) error_propagate(errp, local_err); return; } + + + /* + * I2C + */ + for (i =3D 0; i < pcc->i2c_num_engines; i++) { + Object *obj =3D OBJECT(&chip10->i2c[i]); + + object_property_set_int(obj, "engine", i + 1, &error_fatal); + object_property_set_int(obj, "num-busses", pcc->i2c_num_ports, + &error_fatal); + object_property_set_link(obj, "chip", OBJECT(chip), &error_abort); + if (!qdev_realize(DEVICE(obj), NULL, errp)) { + return; + } + pnv_xscom_add_subregion(chip, PNV10_XSCOM_I2CM_BASE + + chip10->i2c[i].engine * PNV10_XSCOM_I2CM_S= IZE, + &chip10->i2c[i].xscom_regs); + qdev_connect_gpio_out(DEVICE(&chip10->i2c[i]), 0, + qdev_get_gpio_in(DEVICE(&chip10->psi), + PSIHB9_IRQ_SBE_I2C)); + } } =20 static uint32_t pnv_chip_power10_xscom_pcba(PnvChip *chip, uint64_t addr) @@ -1874,6 +1901,8 @@ static void pnv_chip_power10_class_init(ObjectClass *= klass, void *data) k->xscom_pcba =3D pnv_chip_power10_xscom_pcba; dc->desc =3D "PowerNV Chip POWER10"; k->num_pecs =3D PNV10_CHIP_MAX_PEC; + k->i2c_num_engines =3D PNV10_CHIP_MAX_I2C; + k->i2c_num_ports =3D PNV10_CHIP_MAX_I2C_PORTS; =20 device_class_set_parent_realize(dc, pnv_chip_power10_realize, &k->parent_realize); diff --git a/include/hw/ppc/pnv_chip.h b/include/hw/ppc/pnv_chip.h index 90cfbad1a5..5815d96ecf 100644 --- a/include/hw/ppc/pnv_chip.h +++ b/include/hw/ppc/pnv_chip.h @@ -120,6 +120,10 @@ struct Pnv10Chip { =20 #define PNV10_CHIP_MAX_PEC 2 PnvPhb4PecState pecs[PNV10_CHIP_MAX_PEC]; + +#define PNV10_CHIP_MAX_I2C 4 +#define PNV10_CHIP_MAX_I2C_PORTS 2 + PnvI2C i2c[PNV10_CHIP_MAX_I2C]; }; =20 #define PNV10_PIR2FUSEDCORE(pir) (((pir) >> 3) & 0xf) diff --git a/include/hw/ppc/pnv_xscom.h b/include/hw/ppc/pnv_xscom.h index 056392ab60..f5becbab41 100644 --- a/include/hw/ppc/pnv_xscom.h +++ b/include/hw/ppc/pnv_xscom.h @@ -152,6 +152,9 @@ struct PnvXScomInterfaceClass { #define PNV10_XSCOM_PSIHB_BASE 0x3011D00 #define PNV10_XSCOM_PSIHB_SIZE 0x100 =20 +#define PNV10_XSCOM_I2CM_BASE PNV9_XSCOM_I2CM_BASE +#define PNV10_XSCOM_I2CM_SIZE PNV9_XSCOM_I2CM_SIZE + #define PNV10_XSCOM_OCC_BASE PNV9_XSCOM_OCC_BASE #define PNV10_XSCOM_OCC_SIZE PNV9_XSCOM_OCC_SIZE =20 --=20 2.41.0 From nobody Wed Nov 27 10:01:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1699390239; cv=none; d=zohomail.com; s=zohoarc; b=WAY0sZYEMDb3pWd5nRgEdDSGRxrTjW5OqV+V/c6fExIBuvERwvXvwLPzXCkuZi2EBkpPCI8ZP3k7WWWLP+AgCsnn3Y5FBxyVQuOCVppDzY0CVxvhgQeV3x5yENpyypJHXDb5Yggaths8c2U3SQVdahhM5eCey+5CVpgf/+qG8eE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699390239; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AuiB8YLB6fW19Sv4iIZuZRWwFlQIhnLJeadaVGwfrms=; b=apVKDsRn23K+lX+eIzPpOUnlQhMqwFSdJstNJGeIYhrX/pbpBUR+YR4A+ML16aOus+964B0wtt8Fu4ZimOR9ZLg8kwAmG6fG3Lw6mDHwipzVHFBWaW5aZv8USblRiwek44Z1RglG8OK5HnO8OxBDpVDrOMmcl0Wl9xDbEBqSPB0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699390239234957.0583184152914; Tue, 7 Nov 2023 12:50:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0Szu-0006aS-1w; Tue, 07 Nov 2023 15:48:30 -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 1r0Szr-0006YE-TK; Tue, 07 Nov 2023 15:48:27 -0500 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0Szq-0006SM-5e; Tue, 07 Nov 2023 15:48:27 -0500 Received: by mail-qt1-x830.google.com with SMTP id d75a77b69052e-41cd6e1d4fbso36742141cf.1; Tue, 07 Nov 2023 12:48:25 -0800 (PST) Received: from grind.. ([179.193.10.161]) by smtp.gmail.com with ESMTPSA id d13-20020ac8544d000000b0041eb13a8195sm48946qtq.61.2023.11.07.12.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 12:48:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699390104; x=1699994904; darn=nongnu.org; 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=AuiB8YLB6fW19Sv4iIZuZRWwFlQIhnLJeadaVGwfrms=; b=DYYYcgIPLVJbzJhbsn6tUq0UAn2z5rKAadcdNzB1FHOVPIfXJLJeBtpLCyO3pqobsg L4oP/s6qFzzABoO2egeFrMO9UYaUu2OB6SbrcBZfoxtdoH+CmBjjMbQt1xJQFQO3M/B0 MFSsnh1aScKCfQ0iSZ7YORGIInJ30Ev0nq+oPhBoCy5q8uBCQJ4T5lPS/jNuke209u55 bs9MmabZb/G6nR53tlwBvNUOog6yTW4O3IUSiUkwApYh4kA+xXt9dYBm8gXq39cFE2L4 csYuWklbZrUBciQHiB+8NsfNnapT4sxMiz11s7t2Mhv/rRymdf7OQuaNJrKjO49zPPDz Bl0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699390104; x=1699994904; 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=AuiB8YLB6fW19Sv4iIZuZRWwFlQIhnLJeadaVGwfrms=; b=sr71KsXQ+xq6V4ewJtqIF/fkC2nMhhHe19M/lo7WhbecqdiwMKkBneT4IYIPClOjBI eD71HAw3n6oW/kkj8B4fp30iGKG6FAdU1DF/Kf5gEgQHThrOIjCdW77uXQcSyRNyKQ5Q F6L9CDyDdqzN+T6r6CDyScZpfsqyBTJ4i4jj+7UV7n+tloqXdal429HYQBRAwUIHjPAd aeP90ADudvz6+y43DeAz/CieTRGglHju91kntFFICVlVst7K6Czy6GTCCAyIHzDtocDV l8wj3OfGnb/sxMLVStf/jVXtB+sEPYgYeef4P+e4WV16cXnIXdti70Ln4yv9d7d1JXPz AZDQ== X-Gm-Message-State: AOJu0YxXEvdA7N9QN9FzIr+waMaUCI7iaIdMEcNS9FMfHjEpFwUUe4zn 9UPisEyFHGH/8e7E+OoRf00YBPoGyaI= X-Google-Smtp-Source: AGHT+IHmwHIWejHpTz+YaRHBguR/1xfLwspLpuT7RAgmXOxj7ynshxOtYUCKVsUDKwGtHYWnNjv+jg== X-Received: by 2002:a05:622a:1b8e:b0:41c:c2ad:6810 with SMTP id bp14-20020a05622a1b8e00b0041cc2ad6810mr1584qtb.2.1699390104464; Tue, 07 Nov 2023 12:48:24 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, danielhb413@gmail.com, peter.maydell@linaro.org, Glenn Miles , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PULL 7/9] ppc/pnv: Fix number of I2C engines and ports for power9/10 Date: Tue, 7 Nov 2023 17:48:04 -0300 Message-ID: <20231107204806.8507-8-danielhb413@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107204806.8507-1-danielhb413@gmail.com> References: <20231107204806.8507-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::830; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x830.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1699390241347100003 From: Glenn Miles Power9 is supposed to have 4 PIB-connected I2C engines with the following number of ports on each engine: 0: 2 1: 13 2: 2 3: 2 Power10 also has 4 engines but has the following number of ports on each engine: 0: 14 1: 14 2: 2 3: 16 Current code assumes that they all have the same (maximum) number. This can be a problem if software expects to see a certain number of ports present (Power Hypervisor seems to care). Fixed this by adding separate tables for power9 and power10 that map the I2C controller number to the number of I2C buses that should be attached for that engine. Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Glenn Miles Message-ID: <20231025152714.956664-1-milesg@linux.vnet.ibm.com> Signed-off-by: Daniel Henrique Barboza --- hw/ppc/pnv.c | 12 ++++++++---- include/hw/ppc/pnv_chip.h | 6 ++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index ae8e0b45cd..9c29727337 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1615,7 +1615,8 @@ static void pnv_chip_power9_realize(DeviceState *dev,= Error **errp) Object *obj =3D OBJECT(&chip9->i2c[i]); =20 object_property_set_int(obj, "engine", i + 1, &error_fatal); - object_property_set_int(obj, "num-busses", pcc->i2c_num_ports, + object_property_set_int(obj, "num-busses", + pcc->i2c_ports_per_engine[i], &error_fatal); object_property_set_link(obj, "chip", OBJECT(chip), &error_abort); if (!qdev_realize(DEVICE(obj), NULL, errp)) { @@ -1640,6 +1641,7 @@ static void pnv_chip_power9_class_init(ObjectClass *k= lass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); PnvChipClass *k =3D PNV_CHIP_CLASS(klass); + static const int i2c_ports_per_engine[PNV9_CHIP_MAX_I2C] =3D {2, 13, 2= , 2}; =20 k->chip_cfam_id =3D 0x220d104900008000ull; /* P9 Nimbus DD2.0 */ k->cores_mask =3D POWER9_CORE_MASK; @@ -1656,7 +1658,7 @@ static void pnv_chip_power9_class_init(ObjectClass *k= lass, void *data) dc->desc =3D "PowerNV Chip POWER9"; k->num_pecs =3D PNV9_CHIP_MAX_PEC; k->i2c_num_engines =3D PNV9_CHIP_MAX_I2C; - k->i2c_num_ports =3D PNV9_CHIP_MAX_I2C_PORTS; + k->i2c_ports_per_engine =3D i2c_ports_per_engine; =20 device_class_set_parent_realize(dc, pnv_chip_power9_realize, &k->parent_realize); @@ -1861,7 +1863,8 @@ static void pnv_chip_power10_realize(DeviceState *dev= , Error **errp) Object *obj =3D OBJECT(&chip10->i2c[i]); =20 object_property_set_int(obj, "engine", i + 1, &error_fatal); - object_property_set_int(obj, "num-busses", pcc->i2c_num_ports, + object_property_set_int(obj, "num-busses", + pcc->i2c_ports_per_engine[i], &error_fatal); object_property_set_link(obj, "chip", OBJECT(chip), &error_abort); if (!qdev_realize(DEVICE(obj), NULL, errp)) { @@ -1886,6 +1889,7 @@ static void pnv_chip_power10_class_init(ObjectClass *= klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); PnvChipClass *k =3D PNV_CHIP_CLASS(klass); + static const int i2c_ports_per_engine[PNV10_CHIP_MAX_I2C] =3D {14, 14,= 2, 16}; =20 k->chip_cfam_id =3D 0x120da04900008000ull; /* P10 DD1.0 (with NX) */ k->cores_mask =3D POWER10_CORE_MASK; @@ -1902,7 +1906,7 @@ static void pnv_chip_power10_class_init(ObjectClass *= klass, void *data) dc->desc =3D "PowerNV Chip POWER10"; k->num_pecs =3D PNV10_CHIP_MAX_PEC; k->i2c_num_engines =3D PNV10_CHIP_MAX_I2C; - k->i2c_num_ports =3D PNV10_CHIP_MAX_I2C_PORTS; + k->i2c_ports_per_engine =3D i2c_ports_per_engine; =20 device_class_set_parent_realize(dc, pnv_chip_power10_realize, &k->parent_realize); diff --git a/include/hw/ppc/pnv_chip.h b/include/hw/ppc/pnv_chip.h index 5815d96ecf..0ab5c42308 100644 --- a/include/hw/ppc/pnv_chip.h +++ b/include/hw/ppc/pnv_chip.h @@ -88,8 +88,7 @@ struct Pnv9Chip { #define PNV9_CHIP_MAX_PEC 3 PnvPhb4PecState pecs[PNV9_CHIP_MAX_PEC]; =20 -#define PNV9_CHIP_MAX_I2C 3 -#define PNV9_CHIP_MAX_I2C_PORTS 1 +#define PNV9_CHIP_MAX_I2C 4 PnvI2C i2c[PNV9_CHIP_MAX_I2C]; }; =20 @@ -122,7 +121,6 @@ struct Pnv10Chip { PnvPhb4PecState pecs[PNV10_CHIP_MAX_PEC]; =20 #define PNV10_CHIP_MAX_I2C 4 -#define PNV10_CHIP_MAX_I2C_PORTS 2 PnvI2C i2c[PNV10_CHIP_MAX_I2C]; }; =20 @@ -140,7 +138,7 @@ struct PnvChipClass { uint32_t num_phbs; =20 uint32_t i2c_num_engines; - uint32_t i2c_num_ports; + const int *i2c_ports_per_engine; =20 DeviceRealize parent_realize; =20 --=20 2.41.0 From nobody Wed Nov 27 10:01:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1699390195; cv=none; d=zohomail.com; s=zohoarc; b=j4WJjGI3T30NNbW6Ci+5LnIgd4sqip8+hb33tfXyEpwXNopI77bp4X2Jc/xKGsrthaGstds+XGIaaBJvEGoOzWBZ9RXnNq6tntJaP4QNk+UQTx36s3L6S1Ix/ZEeleHApt75Gwk1bcNlwPEXVUR9SxXWSgN/OxSiJHTV+NHsfn8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699390195; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iUcEwOhRQn+FA51Xd0pAqqI8AsQQNXtH2TgPu8rbPhc=; b=J58Wy7Gf1dRvCeCz188k+3QEJZ/Q7cweOT0kPTqpN3hFa6PVyals7P1AHGiDpjadN/Jjp5ou39+7XrPlO7f0QrlSgzmolkii5aQ5aK4YnMcJNHJDHihEffDXxTXfzWyDVxtTAhsO1laYrgG19B6a18URojEX813/BVHD8jJNcps= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699390195110471.84660721636544; Tue, 7 Nov 2023 12:49:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0Szy-0006cu-AN; Tue, 07 Nov 2023 15:48:34 -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 1r0Szu-0006aW-6W; Tue, 07 Nov 2023 15:48:30 -0500 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0Szs-0006Sx-4E; Tue, 07 Nov 2023 15:48:29 -0500 Received: by mail-qt1-x82f.google.com with SMTP id d75a77b69052e-41e1974783cso38560111cf.3; Tue, 07 Nov 2023 12:48:27 -0800 (PST) Received: from grind.. ([179.193.10.161]) by smtp.gmail.com with ESMTPSA id d13-20020ac8544d000000b0041eb13a8195sm48946qtq.61.2023.11.07.12.48.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 12:48:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699390106; x=1699994906; darn=nongnu.org; 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=iUcEwOhRQn+FA51Xd0pAqqI8AsQQNXtH2TgPu8rbPhc=; b=FNKW0dVwdJ3wor+upaXPJMUJhuiokdH/9VYhnOD2RAJH5qfR6A9vq/De4he86MRY0x /6KG0RjY6y45WtQHYg3BJqZmJzHbfpD9Q5R2Lks7QxtmU6pn7eRAeCqDsDkvSKVTFvP8 R9ceA3ucnuePRl9m2EpZQKcQjUguPN7hq1fP9I6ne7WNjsWlePmRk7KkPtKhn+2pX/Or u+kKu3aES2rQ6BlJmf943RLR0GF1TEXpyJ/HFGnCMmCxVy16s5p+w27BI2j1YhvaEkPK KtpXiA+dWW26gFvvdtUHfbwVVQwzHE33MjIhhuRsYHUfh9AXwhjmYmZRkybfp9MlvIpf ND+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699390106; x=1699994906; 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=iUcEwOhRQn+FA51Xd0pAqqI8AsQQNXtH2TgPu8rbPhc=; b=T//WbAY4XkCe852n7HfwuW27pJB8+m/FQ+wVkQNToKQ3AF4W9cOkl96tCCd5KnT/yG n1GSOvUy5O96uy5nIssiH5Msck7XuiPHxBSys33RBfxtza0Xt/TwgtximlFCnfL1oWdm s4Qma1rtcS0FCR1d+wGj/jcCADRZSOavmrxeaLM1UEjNsK62EQuQupA8STFicGfwejkR Nms9P/Ld9EyzlVpf2WSW/Aq0iagoUcAjDovtTX2BiC1PkFwgMtw6PEKaLV0I3aKRwwya hllpKTRppjQ3IChDBMz4UfkGL/3uS2pmEf8ohc0fEuYtUFLfrRdBmqcQJKwRMxJ29RsL U3eQ== X-Gm-Message-State: AOJu0YyK729+KClpCOcVFZw2SVLo/qTbNaOmO5zxuxMeOMvRZPB3weTu qanzM+D1rTpPrjhsILnfkbzxS74ApBI= X-Google-Smtp-Source: AGHT+IHArDYyyPE7KOGaqcUxIrwEwh6GAqgQYPD0K+bmFwsc2xHaCrCONWueIrnlk9HVjG3b3tH50A== X-Received: by 2002:a05:622a:1791:b0:417:9962:4de9 with SMTP id s17-20020a05622a179100b0041799624de9mr12993qtk.1.1699390106542; Tue, 07 Nov 2023 12:48:26 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, danielhb413@gmail.com, peter.maydell@linaro.org, Saif Abrar , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Harsh Prateek Bora Subject: [PULL 8/9] hw/pci-host: Update PHB5 XSCOM registers Date: Tue, 7 Nov 2023 17:48:05 -0300 Message-ID: <20231107204806.8507-9-danielhb413@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107204806.8507-1-danielhb413@gmail.com> References: <20231107204806.8507-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x82f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1699390197213100007 From: Saif Abrar Add new XSCOM registers introduced in PHB5. Apply bit-masks within xscom-write methods. Bit-masks specified using PPC_BITMASK macro. Signed-off-by: Saif Abrar Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Harsh Prateek Bora Message-ID: <20231016175948.10869-1-saif.abrar@linux.vnet.ibm.com> Signed-off-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb4.c | 46 ++++++++++++++++++----------- hw/pci-host/pnv_phb4_pec.c | 33 +++++++++++++++++---- include/hw/pci-host/pnv_phb4.h | 2 +- include/hw/pci-host/pnv_phb4_regs.h | 4 ++- 4 files changed, 60 insertions(+), 25 deletions(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 37c7afc18c..075499d36d 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -855,7 +855,7 @@ static uint64_t pnv_pec_stk_nest_xscom_read(void *opaqu= e, hwaddr addr, PnvPHB4 *phb =3D PNV_PHB4(opaque); uint32_t reg =3D addr >> 3; =20 - /* TODO: add list of allowed registers and error out if not */ + /* All registers are read-able */ return phb->nest_regs[reg]; } =20 @@ -1000,7 +1000,7 @@ static void pnv_pec_stk_nest_xscom_write(void *opaque= , hwaddr addr, =20 switch (reg) { case PEC_NEST_STK_PCI_NEST_FIR: - phb->nest_regs[PEC_NEST_STK_PCI_NEST_FIR] =3D val; + phb->nest_regs[PEC_NEST_STK_PCI_NEST_FIR] =3D val & PPC_BITMASK(0,= 27); break; case PEC_NEST_STK_PCI_NEST_FIR_CLR: phb->nest_regs[PEC_NEST_STK_PCI_NEST_FIR] &=3D val; @@ -1009,7 +1009,8 @@ static void pnv_pec_stk_nest_xscom_write(void *opaque= , hwaddr addr, phb->nest_regs[PEC_NEST_STK_PCI_NEST_FIR] |=3D val; break; case PEC_NEST_STK_PCI_NEST_FIR_MSK: - phb->nest_regs[PEC_NEST_STK_PCI_NEST_FIR_MSK] =3D val; + phb->nest_regs[PEC_NEST_STK_PCI_NEST_FIR_MSK] =3D val & + PPC_BITMASK(0, 27); break; case PEC_NEST_STK_PCI_NEST_FIR_MSKC: phb->nest_regs[PEC_NEST_STK_PCI_NEST_FIR_MSK] &=3D val; @@ -1019,7 +1020,7 @@ static void pnv_pec_stk_nest_xscom_write(void *opaque= , hwaddr addr, break; case PEC_NEST_STK_PCI_NEST_FIR_ACT0: case PEC_NEST_STK_PCI_NEST_FIR_ACT1: - phb->nest_regs[reg] =3D val; + phb->nest_regs[reg] =3D val & PPC_BITMASK(0, 27); break; case PEC_NEST_STK_PCI_NEST_FIR_WOF: phb->nest_regs[reg] =3D 0; @@ -1030,7 +1031,7 @@ static void pnv_pec_stk_nest_xscom_write(void *opaque= , hwaddr addr, /* Flag error ? */ break; case PEC_NEST_STK_PBCQ_MODE: - phb->nest_regs[reg] =3D val & 0xff00000000000000ull; + phb->nest_regs[reg] =3D val & PPC_BITMASK(0, 7); break; case PEC_NEST_STK_MMIO_BAR0: case PEC_NEST_STK_MMIO_BAR0_MASK: @@ -1041,28 +1042,33 @@ static void pnv_pec_stk_nest_xscom_write(void *opaq= ue, hwaddr addr, PEC_NEST_STK_BAR_EN_MMIO1)) { phb_pec_error(pec, "Changing enabled BAR unsupported"); } - phb->nest_regs[reg] =3D val & 0xffffffffff000000ull; + phb->nest_regs[reg] =3D val & PPC_BITMASK(0, 39); break; case PEC_NEST_STK_PHB_REGS_BAR: if (phb->nest_regs[PEC_NEST_STK_BAR_EN] & PEC_NEST_STK_BAR_EN_PHB)= { phb_pec_error(pec, "Changing enabled BAR unsupported"); } - phb->nest_regs[reg] =3D val & 0xffffffffffc00000ull; + phb->nest_regs[reg] =3D val & PPC_BITMASK(0, 41); break; case PEC_NEST_STK_INT_BAR: if (phb->nest_regs[PEC_NEST_STK_BAR_EN] & PEC_NEST_STK_BAR_EN_INT)= { phb_pec_error(pec, "Changing enabled BAR unsupported"); } - phb->nest_regs[reg] =3D val & 0xfffffff000000000ull; + phb->nest_regs[reg] =3D val & PPC_BITMASK(0, 27); break; case PEC_NEST_STK_BAR_EN: - phb->nest_regs[reg] =3D val & 0xf000000000000000ull; + phb->nest_regs[reg] =3D val & PPC_BITMASK(0, 3); pnv_pec_phb_update_map(phb); break; case PEC_NEST_STK_DATA_FRZ_TYPE: - case PEC_NEST_STK_PBCQ_TUN_BAR: /* Not used for now */ - phb->nest_regs[reg] =3D val; + phb->nest_regs[reg] =3D val & PPC_BITMASK(0, 27); + break; + case PEC_NEST_STK_PBCQ_SPARSE_PAGE: + phb->nest_regs[reg] =3D val & PPC_BITMASK(3, 5); + break; + case PEC_NEST_STK_PBCQ_CACHE_INJ: + phb->nest_regs[reg] =3D val & PPC_BITMASK(0, 7); break; default: qemu_log_mask(LOG_UNIMP, "phb4_pec: nest_xscom_write 0x%"HWADDR_PR= Ix @@ -1086,7 +1092,7 @@ static uint64_t pnv_pec_stk_pci_xscom_read(void *opaq= ue, hwaddr addr, PnvPHB4 *phb =3D PNV_PHB4(opaque); uint32_t reg =3D addr >> 3; =20 - /* TODO: add list of allowed registers and error out if not */ + /* All registers are read-able */ return phb->pci_regs[reg]; } =20 @@ -1095,10 +1101,9 @@ static void pnv_pec_stk_pci_xscom_write(void *opaque= , hwaddr addr, { PnvPHB4 *phb =3D PNV_PHB4(opaque); uint32_t reg =3D addr >> 3; - switch (reg) { case PEC_PCI_STK_PCI_FIR: - phb->pci_regs[reg] =3D val; + phb->pci_regs[reg] =3D val & PPC_BITMASK(0, 5); break; case PEC_PCI_STK_PCI_FIR_CLR: phb->pci_regs[PEC_PCI_STK_PCI_FIR] &=3D val; @@ -1107,7 +1112,7 @@ static void pnv_pec_stk_pci_xscom_write(void *opaque,= hwaddr addr, phb->pci_regs[PEC_PCI_STK_PCI_FIR] |=3D val; break; case PEC_PCI_STK_PCI_FIR_MSK: - phb->pci_regs[reg] =3D val; + phb->pci_regs[reg] =3D val & PPC_BITMASK(0, 5); break; case PEC_PCI_STK_PCI_FIR_MSKC: phb->pci_regs[PEC_PCI_STK_PCI_FIR_MSK] &=3D val; @@ -1117,20 +1122,25 @@ static void pnv_pec_stk_pci_xscom_write(void *opaqu= e, hwaddr addr, break; case PEC_PCI_STK_PCI_FIR_ACT0: case PEC_PCI_STK_PCI_FIR_ACT1: - phb->pci_regs[reg] =3D val; + phb->pci_regs[reg] =3D val & PPC_BITMASK(0, 5); break; case PEC_PCI_STK_PCI_FIR_WOF: phb->pci_regs[reg] =3D 0; break; case PEC_PCI_STK_ETU_RESET: - phb->pci_regs[reg] =3D val & 0x8000000000000000ull; + phb->pci_regs[reg] =3D val & PPC_BIT(0); /* TODO: Implement reset */ break; case PEC_PCI_STK_PBAIB_ERR_REPORT: break; case PEC_PCI_STK_PBAIB_TX_CMD_CRED: + phb->pci_regs[reg] =3D val & + ((PPC_BITMASK(0, 2) | PPC_BITMASK(10, 18) + | PPC_BITMASK(26, 34) | PPC_BITMASK(41,= 50) + | PPC_BITMASK(58, 63))); + break; case PEC_PCI_STK_PBAIB_TX_DAT_CRED: - phb->pci_regs[reg] =3D val; + phb->pci_regs[reg] =3D val & (PPC_BITMASK(33, 34) | PPC_BITMASK(44= , 47)); break; default: qemu_log_mask(LOG_UNIMP, "phb4_pec_stk: pci_xscom_write 0x%"HWADDR= _PRIx diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c index 3b2850f7a3..ce8e228f98 100644 --- a/hw/pci-host/pnv_phb4_pec.c +++ b/hw/pci-host/pnv_phb4_pec.c @@ -34,7 +34,7 @@ static uint64_t pnv_pec_nest_xscom_read(void *opaque, hwa= ddr addr, PnvPhb4PecState *pec =3D PNV_PHB4_PEC(opaque); uint32_t reg =3D addr >> 3; =20 - /* TODO: add list of allowed registers and error out if not */ + /* All registers are readable */ return pec->nest_regs[reg]; } =20 @@ -45,18 +45,36 @@ static void pnv_pec_nest_xscom_write(void *opaque, hwad= dr addr, uint32_t reg =3D addr >> 3; =20 switch (reg) { - case PEC_NEST_PBCQ_HW_CONFIG: case PEC_NEST_DROP_PRIO_CTRL: + pec->nest_regs[reg] =3D val & PPC_BITMASK(0, 25); + break; case PEC_NEST_PBCQ_ERR_INJECT: + pec->nest_regs[reg] =3D val & PPC_BITMASK(0, 11); + break; case PEC_NEST_PCI_NEST_CLK_TRACE_CTL: + pec->nest_regs[reg] =3D val & PPC_BITMASK(0, 16); + break; case PEC_NEST_PBCQ_PMON_CTRL: + pec->nest_regs[reg] =3D val & PPC_BITMASK(0, 37); + break; case PEC_NEST_PBCQ_PBUS_ADDR_EXT: + pec->nest_regs[reg] =3D val & PPC_BITMASK(0, 6); + break; case PEC_NEST_PBCQ_PRED_VEC_TIMEOUT: - case PEC_NEST_CAPP_CTRL: + pec->nest_regs[reg] =3D val & PPC_BITMASK(0, 15); + break; case PEC_NEST_PBCQ_READ_STK_OVR: + pec->nest_regs[reg] =3D val & PPC_BITMASK(0, 48); + break; case PEC_NEST_PBCQ_WRITE_STK_OVR: case PEC_NEST_PBCQ_STORE_STK_OVR: + pec->nest_regs[reg] =3D val & PPC_BITMASK(0, 24); + break; case PEC_NEST_PBCQ_RETRY_BKOFF_CTRL: + pec->nest_regs[reg] =3D val & PPC_BITMASK(0, 41); + break; + case PEC_NEST_PBCQ_HW_CONFIG: + case PEC_NEST_CAPP_CTRL: pec->nest_regs[reg] =3D val; break; default: @@ -81,7 +99,7 @@ static uint64_t pnv_pec_pci_xscom_read(void *opaque, hwad= dr addr, PnvPhb4PecState *pec =3D PNV_PHB4_PEC(opaque); uint32_t reg =3D addr >> 3; =20 - /* TODO: add list of allowed registers and error out if not */ + /* All registers are readable */ return pec->pci_regs[reg]; } =20 @@ -93,8 +111,13 @@ static void pnv_pec_pci_xscom_write(void *opaque, hwadd= r addr, =20 switch (reg) { case PEC_PCI_PBAIB_HW_CONFIG: + pec->pci_regs[reg] =3D val & PPC_BITMASK(0, 42); + break; + case PEC_PCI_PBAIB_HW_OVR: + pec->pci_regs[reg] =3D val & PPC_BITMASK(0, 15); + break; case PEC_PCI_PBAIB_READ_STK_OVR: - pec->pci_regs[reg] =3D val; + pec->pci_regs[reg] =3D val & PPC_BITMASK(0, 48); break; default: phb_pec_error(pec, "%s @0x%"HWADDR_PRIx"=3D%"PRIx64"\n", __func__, diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h index 2d026db9a3..3212e68160 100644 --- a/include/hw/pci-host/pnv_phb4.h +++ b/include/hw/pci-host/pnv_phb4.h @@ -117,7 +117,7 @@ struct PnvPHB4 { MemoryRegion pci_regs_mr; =20 /* Nest registers */ -#define PHB4_PEC_NEST_STK_REGS_COUNT 0x17 +#define PHB4_PEC_NEST_STK_REGS_COUNT 0x18 uint64_t nest_regs[PHB4_PEC_NEST_STK_REGS_COUNT]; MemoryRegion nest_regs_mr; =20 diff --git a/include/hw/pci-host/pnv_phb4_regs.h b/include/hw/pci-host/pnv_= phb4_regs.h index 4a0d3b28ef..bea96f4d91 100644 --- a/include/hw/pci-host/pnv_phb4_regs.h +++ b/include/hw/pci-host/pnv_phb4_regs.h @@ -77,10 +77,12 @@ #define PEC_NEST_STK_BAR_EN_PHB PPC_BIT(2) #define PEC_NEST_STK_BAR_EN_INT PPC_BIT(3) #define PEC_NEST_STK_DATA_FRZ_TYPE 0x15 -#define PEC_NEST_STK_PBCQ_TUN_BAR 0x16 +#define PEC_NEST_STK_PBCQ_SPARSE_PAGE 0x16 /* P10 */ +#define PEC_NEST_STK_PBCQ_CACHE_INJ 0x17 /* P10 */ =20 /* XSCOM PCI global registers */ #define PEC_PCI_PBAIB_HW_CONFIG 0x00 +#define PEC_PCI_PBAIB_HW_OVR 0x01 #define PEC_PCI_PBAIB_READ_STK_OVR 0x02 =20 /* XSCOM PCI per-stack registers */ --=20 2.41.0 From nobody Wed Nov 27 10:01:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1699390194; cv=none; d=zohomail.com; s=zohoarc; b=IqNusluwzREROOf5nGY0akurYnu4SClX00wRLmAOnR91UFbUCAIh/Vy4qLRJtlH3RumDfFUclrsV7QyNMXpwOnIB+wp34U/BmF4XkhtbpZ5Bbu70WQ9SITdihyJIwn75g1i2qd+FZLW4pehpksfMMQD7AF7zC4zEKQIOmnwONfs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699390194; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LA7zqqCSSp/grUHtdG2jb7l1ICp+1C84x01i7sVE+a0=; b=iMda+xSkm3hPXIR28b8RHJ9/DbjDy+AquLX63spb8F0NHUqiS9qFZqPhXCeAmroZYdNYrwQPOoCo+R1pX2jd3p9jAnjTi4LPYf2cU8AR7eI55iFlsJP+HJQEt8H3NCoEsZwvToxSlzHoEuzBSvLhIy/0ZlxWySFR2bk+pZ/l3FU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169939019417914.635482743304237; Tue, 7 Nov 2023 12:49:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0T00-0006e6-Ro; Tue, 07 Nov 2023 15:48:36 -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 1r0Szv-0006bc-Jz; Tue, 07 Nov 2023 15:48:31 -0500 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0Szu-0006TU-1F; Tue, 07 Nov 2023 15:48:31 -0500 Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6d319933f9fso3683696a34.2; Tue, 07 Nov 2023 12:48:29 -0800 (PST) Received: from grind.. ([179.193.10.161]) by smtp.gmail.com with ESMTPSA id d13-20020ac8544d000000b0041eb13a8195sm48946qtq.61.2023.11.07.12.48.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 12:48:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699390108; x=1699994908; darn=nongnu.org; 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=LA7zqqCSSp/grUHtdG2jb7l1ICp+1C84x01i7sVE+a0=; b=Wo5rSW/ddjN1ifNId2+1qheqjXefuG/ZPpW7a7+o3NcPuRZjpv8YxthANSQdhX/6X+ NfSGVK9UjZaRJweYnYz/2kUNaGvkcDBauQ+IPcCV2feONgV9+SqkWejrS7cKGToTS2lG HGV01kWtdEQyMSYn4VYtS81zvPZrXNDcOod9S8+aLXUUWt2qYnMLSKimhc0qUvgp8Ho/ AtPXXFFLGrZTInzFHhsEHGA/w5Re9l654WPvXf2j6JDuMuF/4ouVxhINL5hFoQOZFarH M/hgVBJlWQImhlGJ4qFTEjT5Tj+TV5hNsEfOJbAUhBpIDK4qAnFP5ulFWrqHS5pJ9eca C2EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699390108; x=1699994908; 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=LA7zqqCSSp/grUHtdG2jb7l1ICp+1C84x01i7sVE+a0=; b=XOFxcWGWxw7n1HnMcDyhl2WdQr6KhXGtuf8YjExjLG/DGib5CDnAfITK2GFFamS0zA vMKoPVU8CpAeQnkEm7AR8iX65kf7GePjVh4Cfzyexzp7U+U4DAu8FJaTv9ke4TOy+VBl +U30xtiRZxYcH/QDrB2Ig04jCPZXFfCnBwfk9jObfF5yFwZ4nI491bmABPTZ+/B8CUFL blSC0kQ7eMtZJ2zcwq220OYp8USkfKf7XtlPg4AxuEQ2U0fZatckA88NGr+cpMkr6sI/ +ERAbYSAz7B9IPQo0ka+pjTHbToZdR1nU2ztwsWK/1LL08DGvJgQvMYh91fiAZzqTL6h A+8A== X-Gm-Message-State: AOJu0YwIfwg1dDz6lsH/ZVKRMb0v98F+h53myITtcqSQQVtuIjcteh7Q lEKg1/lvyJtfcT8XDw3rXkdUbEf5wYc= X-Google-Smtp-Source: AGHT+IG+CvdxMTskSJxyhanBitmIuacx1pFEBr2eJbkurkn1nJGoZGysvFi3mH3xKkJrfp0nqcScgg== X-Received: by 2002:a05:6830:4492:b0:6cc:d4f7:e37d with SMTP id r18-20020a056830449200b006ccd4f7e37dmr705688otv.5.1699390108532; Tue, 07 Nov 2023 12:48:28 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, danielhb413@gmail.com, peter.maydell@linaro.org, Juan Quintela , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PULL 9/9] ppc: qtest already exports qtest_rtas_call() Date: Tue, 7 Nov 2023 17:48:06 -0300 Message-ID: <20231107204806.8507-10-danielhb413@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107204806.8507-1-danielhb413@gmail.com> References: <20231107204806.8507-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::335; envelope-from=danielhb413@gmail.com; helo=mail-ot1-x335.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1699390195238100001 From: Juan Quintela Having two functions with the same name is a bad idea. As spapr only uses the function locally, made it static. When you compile with clang, you get this compilation error: /usr/bin/ld: tests/qtest/libqos/libqos.fa.p/.._libqtest.c.o: in function `q= test_rtas_call': /scratch/qemu/clang/full/all/../../../../../mnt/code/qemu/full/tests/qtest/= libqtest.c:1195: multiple definition of `qtest_rtas_call'; libqemu-ppc64-so= ftmmu.fa.p/hw_ppc_spapr_rtas.c.o:/scratch/qemu/clang/full/all/../../../../.= ./mnt/code/qemu/full/hw/ppc/spapr_rtas.c:536: first defined here clang-16: error: linker command failed with exit code 1 (use -v to see invo= cation) ninja: build stopped: subcommand failed. make: *** [Makefile:162: run-ninja] Error 1 Signed-off-by: Juan Quintela Reviewed-by: C=C3=A9dric Le Goater Message-ID: <20231030163834.4638-1-quintela@redhat.com> [dhb: remove 'spapr_rtas.h' include from spapr_rtas.c] Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr_rtas.c | 5 ++--- include/hw/ppc/spapr_rtas.h | 10 ---------- 2 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 include/hw/ppc/spapr_rtas.h diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 26c384b261..f329693c55 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -38,7 +38,6 @@ =20 #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" -#include "hw/ppc/spapr_rtas.h" #include "hw/ppc/spapr_cpu_core.h" #include "hw/ppc/ppc.h" =20 @@ -531,8 +530,8 @@ target_ulong spapr_rtas_call(PowerPCCPU *cpu, SpaprMach= ineState *spapr, return H_PARAMETER; } =20 -uint64_t qtest_rtas_call(char *cmd, uint32_t nargs, uint64_t args, - uint32_t nret, uint64_t rets) +static uint64_t qtest_rtas_call(char *cmd, uint32_t nargs, uint64_t args, + uint32_t nret, uint64_t rets) { int token; =20 diff --git a/include/hw/ppc/spapr_rtas.h b/include/hw/ppc/spapr_rtas.h deleted file mode 100644 index 383611f10f..0000000000 --- a/include/hw/ppc/spapr_rtas.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef HW_SPAPR_RTAS_H -#define HW_SPAPR_RTAS_H -/* - * This work is licensed under the terms of the GNU GPL, version 2 or late= r. - * See the COPYING file in the top-level directory. - */ - -uint64_t qtest_rtas_call(char *cmd, uint32_t nargs, uint64_t args, - uint32_t nret, uint64_t rets); -#endif /* HW_SPAPR_RTAS_H */ --=20 2.41.0