qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org
Cc: groug@kaod.org, qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	lvivier@redhat.com, "Cédric Le Goater" <clg@kaod.org>,
	"David Gibson" <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PULL 51/60] ppc/pnv: add a OCC model for POWER9
Date: Sun, 10 Mar 2019 19:26:54 +1100	[thread overview]
Message-ID: <20190310082703.1245-52-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20190310082703.1245-1-david@gibson.dropbear.id.au>

From: Cédric Le Goater <clg@kaod.org>

The OCC on POWER9 is very similar to the one found on POWER8. Provide
the same routines with P9 values for the registers and IRQ number.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20190307223548.20516-10-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/pnv.c               | 13 +++++++
 hw/ppc/pnv_occ.c           | 72 ++++++++++++++++++++++++++++++++++++++
 include/hw/ppc/pnv.h       |  1 +
 include/hw/ppc/pnv_occ.h   |  2 ++
 include/hw/ppc/pnv_xscom.h |  3 ++
 5 files changed, 91 insertions(+)

diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 6ae9ce6795..1559a73323 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -956,6 +956,11 @@ static void pnv_chip_power9_instance_init(Object *obj)
                             TYPE_PNV9_LPC, &error_abort, NULL);
     object_property_add_const_link(OBJECT(&chip9->lpc), "psi",
                                    OBJECT(&chip9->psi), &error_abort);
+
+    object_initialize_child(obj, "occ",  &chip9->occ, sizeof(chip9->occ),
+                            TYPE_PNV9_OCC, &error_abort, NULL);
+    object_property_add_const_link(OBJECT(&chip9->occ), "psi",
+                                   OBJECT(&chip9->psi), &error_abort);
 }
 
 static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
@@ -1012,6 +1017,14 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
 
     chip->dt_isa_nodename = g_strdup_printf("/lpcm-opb@%" PRIx64 "/lpc@0",
                                             (uint64_t) PNV9_LPCM_BASE(chip));
+
+    /* Create the simplified OCC model */
+    object_property_set_bool(OBJECT(&chip9->occ), true, "realized", &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+    pnv_xscom_add_subregion(chip, PNV9_XSCOM_OCC_BASE, &chip9->occ.xscom_regs);
 }
 
 static void pnv_chip_power9_class_init(ObjectClass *klass, void *data)
diff --git a/hw/ppc/pnv_occ.c b/hw/ppc/pnv_occ.c
index ea725647c9..fdd9296e1b 100644
--- a/hw/ppc/pnv_occ.c
+++ b/hw/ppc/pnv_occ.c
@@ -109,6 +109,77 @@ static const TypeInfo pnv_occ_power8_type_info = {
     .class_init    = pnv_occ_power8_class_init,
 };
 
+#define P9_OCB_OCI_OCCMISC              0x6080
+#define P9_OCB_OCI_OCCMISC_CLEAR        0x6081
+#define P9_OCB_OCI_OCCMISC_OR           0x6082
+
+
+static uint64_t pnv_occ_power9_xscom_read(void *opaque, hwaddr addr,
+                                          unsigned size)
+{
+    PnvOCC *occ = PNV_OCC(opaque);
+    uint32_t offset = addr >> 3;
+    uint64_t val = 0;
+
+    switch (offset) {
+    case P9_OCB_OCI_OCCMISC:
+        val = occ->occmisc;
+        break;
+    default:
+        qemu_log_mask(LOG_UNIMP, "OCC Unimplemented register: Ox%"
+                      HWADDR_PRIx "\n", addr >> 3);
+    }
+    return val;
+}
+
+static void pnv_occ_power9_xscom_write(void *opaque, hwaddr addr,
+                                       uint64_t val, unsigned size)
+{
+    PnvOCC *occ = PNV_OCC(opaque);
+    uint32_t offset = addr >> 3;
+
+    switch (offset) {
+    case P9_OCB_OCI_OCCMISC_CLEAR:
+        pnv_occ_set_misc(occ, 0);
+        break;
+    case P9_OCB_OCI_OCCMISC_OR:
+        pnv_occ_set_misc(occ, occ->occmisc | val);
+        break;
+    case P9_OCB_OCI_OCCMISC:
+        pnv_occ_set_misc(occ, val);
+       break;
+    default:
+        qemu_log_mask(LOG_UNIMP, "OCC Unimplemented register: Ox%"
+                      HWADDR_PRIx "\n", addr >> 3);
+    }
+}
+
+static const MemoryRegionOps pnv_occ_power9_xscom_ops = {
+    .read = pnv_occ_power9_xscom_read,
+    .write = pnv_occ_power9_xscom_write,
+    .valid.min_access_size = 8,
+    .valid.max_access_size = 8,
+    .impl.min_access_size = 8,
+    .impl.max_access_size = 8,
+    .endianness = DEVICE_BIG_ENDIAN,
+};
+
+static void pnv_occ_power9_class_init(ObjectClass *klass, void *data)
+{
+    PnvOCCClass *poc = PNV_OCC_CLASS(klass);
+
+    poc->xscom_size = PNV9_XSCOM_OCC_SIZE;
+    poc->xscom_ops = &pnv_occ_power9_xscom_ops;
+    poc->psi_irq = PSIHB9_IRQ_OCC;
+}
+
+static const TypeInfo pnv_occ_power9_type_info = {
+    .name          = TYPE_PNV9_OCC,
+    .parent        = TYPE_PNV_OCC,
+    .instance_size = sizeof(PnvOCC),
+    .class_init    = pnv_occ_power9_class_init,
+};
+
 static void pnv_occ_realize(DeviceState *dev, Error **errp)
 {
     PnvOCC *occ = PNV_OCC(dev);
@@ -152,6 +223,7 @@ static void pnv_occ_register_types(void)
 {
     type_register_static(&pnv_occ_type_info);
     type_register_static(&pnv_occ_power8_type_info);
+    type_register_static(&pnv_occ_power9_type_info);
 }
 
 type_init(pnv_occ_register_types);
diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h
index 1cd1ad622d..39888f9d52 100644
--- a/include/hw/ppc/pnv.h
+++ b/include/hw/ppc/pnv.h
@@ -88,6 +88,7 @@ typedef struct Pnv9Chip {
     PnvXive      xive;
     Pnv9Psi      psi;
     PnvLpcController lpc;
+    PnvOCC       occ;
 } Pnv9Chip;
 
 typedef struct PnvChipClass {
diff --git a/include/hw/ppc/pnv_occ.h b/include/hw/ppc/pnv_occ.h
index dab5a05f8e..d22b65a71a 100644
--- a/include/hw/ppc/pnv_occ.h
+++ b/include/hw/ppc/pnv_occ.h
@@ -25,6 +25,8 @@
 #define PNV_OCC(obj) OBJECT_CHECK(PnvOCC, (obj), TYPE_PNV_OCC)
 #define TYPE_PNV8_OCC TYPE_PNV_OCC "-POWER8"
 #define PNV8_OCC(obj) OBJECT_CHECK(PnvOCC, (obj), TYPE_PNV8_OCC)
+#define TYPE_PNV9_OCC TYPE_PNV_OCC "-POWER9"
+#define PNV9_OCC(obj) OBJECT_CHECK(PnvOCC, (obj), TYPE_PNV9_OCC)
 
 typedef struct PnvOCC {
     DeviceState xd;
diff --git a/include/hw/ppc/pnv_xscom.h b/include/hw/ppc/pnv_xscom.h
index 403a365ed2..3292459fbb 100644
--- a/include/hw/ppc/pnv_xscom.h
+++ b/include/hw/ppc/pnv_xscom.h
@@ -73,6 +73,9 @@ typedef struct PnvXScomInterfaceClass {
 #define PNV_XSCOM_OCC_BASE        0x0066000
 #define PNV_XSCOM_OCC_SIZE        0x6000
 
+#define PNV9_XSCOM_OCC_BASE       PNV_XSCOM_OCC_BASE
+#define PNV9_XSCOM_OCC_SIZE       0x8000
+
 #define PNV9_XSCOM_PSIHB_BASE     0x5012900
 #define PNV9_XSCOM_PSIHB_SIZE     0x100
 
-- 
2.20.1

  parent reply	other threads:[~2019-03-10  8:28 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-10  8:26 [Qemu-devel] [PULL 00/60] ppc-for-4.0 queue 20190310 David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 01/60] vfio/spapr: Fix indirect levels calculation David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 02/60] vfio/spapr: Rename local systempagesize variable David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 03/60] spapr: Simulate CAS for qtest David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 04/60] Revert "spapr: support memory unplug for qtest" David Gibson
2019-03-11 10:52   ` Greg Kurz
2019-03-12  1:08     ` David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 05/60] target/ppc/spapr: Add SPAPR_CAP_LARGE_DECREMENTER David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 06/60] target/ppc: Implement large decrementer support for TCG David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 07/60] target/ppc: Implement large decrementer support for KVM David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 08/60] target/ppc/spapr: Enable the large decrementer for pseries-4.0 David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 09/60] target/ppc/spapr: Add workaround option to SPAPR_CAP_IBS David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 10/60] target/ppc/spapr: Add SPAPR_CAP_CCF_ASSIST David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 11/60] target/ppc/tcg: make spapr_caps apply cap-[cfpc/sbbc/ibs] non-fatal for tcg David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 12/60] target/ppc/spapr: Enable mitigations by default for pseries-4.0 machine type David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 13/60] target/ppc: Move exception vector offset computation into a function David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 14/60] target/ppc: Move handling of hardware breakpoints to a separate function David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 15/60] target/ppc: Refactor kvm_handle_debug David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 16/60] PPC: E500: Update u-boot to v2019.01 David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 17/60] target/ppc/spapr: Clear partition table entry when allocating hash table David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 18/60] spapr: Force SPAPR_MEMORY_BLOCK_SIZE to be a hwaddr (64-bit) David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 19/60] target/ppc/spapr: Enable H_PAGE_INIT in-kernel handling David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 20/60] PPC: E500: Add FSL I2C controller and integrate RTC with it David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 21/60] ppc/xive: hardwire the Physical CAM line of the thread context David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 22/60] ppc: externalize ppc_get_vcpu_by_pir() David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 23/60] ppc/xive: export the TIMA memory accessors David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 24/60] ppc/pnv: export the xive_router_notify() routine David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 25/60] ppc/pnv: change the CPU machine_data presenter type to Object * David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 26/60] ppc/pnv: add a XIVE interrupt controller model for POWER9 David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 27/60] ppc/pnv: introduce a new dt_populate() operation to the chip model David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 28/60] ppc/pnv: introduce a new pic_print_info() " David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 29/60] ppc/xive: activate HV support David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 30/60] ppc/pnv: fix logging primitives using Ox David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 31/60] ppc/pnv: psi: add a PSIHB_REG macro David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 32/60] ppc/pnv: psi: add a reset handler David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 33/60] spapr_iommu: Do not replay mappings from just created DMA window David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 34/60] target/ppc: introduce single fpr_offset() function David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 35/60] target/ppc: introduce single vsrl_offset() function David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 36/60] target/ppc: move Vsr* macros from internal.h to cpu.h David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 37/60] target/ppc: introduce avr_full_offset() function David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 38/60] target/ppc: improve avr64_offset() and use it to simplify get_avr64()/set_avr64() David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 39/60] target/ppc: switch fpr/vsrl registers so all VSX registers are in host endian order David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 40/60] target/ppc: introduce vsr64_offset() to simplify get_cpu_vsr{l, h}() and set_cpu_vsr{l, h}() David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 41/60] mac_oldworld: use node name instead of alias name for hd device in FWPathProvider David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 42/60] mac_newworld: " David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 43/60] ppc/pnv: add a PSI bridge class model David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 44/60] ppc/pnv: add a PSI bridge model for POWER9 David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 45/60] ppc/pnv: lpc: fix OPB address ranges David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 46/60] ppc/pnv: add a LPC Controller class model David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 47/60] ppc/pnv: add a 'dt_isa_nodename' to the chip David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 48/60] ppc/pnv: add a LPC Controller model for POWER9 David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 49/60] ppc/pnv: add SerIRQ routing registers David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 50/60] ppc/pnv: add a OCC model class David Gibson
2019-03-10  8:26 ` David Gibson [this message]
2019-03-10  8:26 ` [Qemu-devel] [PULL 52/60] ppc/pnv: extend XSCOM core support for POWER9 David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 53/60] ppc/pnv: POWER9 XSCOM quad support David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 54/60] ppc/pnv: activate XSCOM tests for POWER9 David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 55/60] ppc/pnv: add more dummy XSCOM addresses David Gibson
2019-03-10  8:26 ` [Qemu-devel] [PULL 56/60] ppc/pnv: add a "ibm, opal/power-mgt" device tree node on POWER9 David Gibson
2019-03-10  8:27 ` [Qemu-devel] [PULL 57/60] target/ppc: add HV support for POWER9 David Gibson
     [not found]   ` <20190312150115.6zuaid43gr7hklt5@unused>
     [not found]     ` <58de43c6-31d5-a0a3-b443-54a33f11d75a@kaod.org>
     [not found]       ` <20190312191409.vxnpscrephtk6otv@dhcp-17-165.bos.redhat.com>
     [not found]         ` <1746025955.7399905.1552419034356.JavaMail.zimbra@redhat.com>
     [not found]           ` <154364d7-fe5b-4f40-b976-b85ff9060ee0@kaod.org>
2019-06-28 13:20             ` Philippe Mathieu-Daudé
2019-07-01  5:04               ` David Gibson
2019-07-01  9:45                 ` Philippe Mathieu-Daudé
2019-07-02  0:14                   ` David Gibson
2019-07-02  6:13                     ` Cédric Le Goater
2019-07-02  9:22                       ` Philippe Mathieu-Daudé
2019-03-10  8:27 ` [Qemu-devel] [PULL 58/60] target/ppc: Optimize xviexpdp() using deposit_i64() David Gibson
2019-03-10  8:27 ` [Qemu-devel] [PULL 59/60] target/ppc: Optimize x[sv]xsigdp " David Gibson
2019-03-10  8:27 ` [Qemu-devel] [PULL 60/60] spapr: Use CamelCase properly David Gibson
2019-03-10  9:23 ` [Qemu-devel] [PULL 00/60] ppc-for-4.0 queue 20190310 no-reply
2019-03-10 16:06 ` Peter Maydell
2019-03-11 10:40   ` Alex Bennée
2019-03-12  0:26     ` David Gibson
2019-03-12  0:44   ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190310082703.1245-52-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=clg@kaod.org \
    --cc=groug@kaod.org \
    --cc=lvivier@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).