Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/816446/?format=api
{ "id": 816446, "url": "http://patchwork.ozlabs.org/api/patches/816446/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170920201737.25723-3-f4bug@amsat.org/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170920201737.25723-3-f4bug@amsat.org>", "list_archive_url": null, "date": "2017-09-20T20:17:34", "name": "[v11,2/5] msf2: Microsemi Smartfusion2 System Register block", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "de06453d6fcc99183df85db0cb1a2ba15553c4da", "submitter": { "id": 70924, "url": "http://patchwork.ozlabs.org/api/people/70924/?format=api", "name": "Philippe Mathieu-Daudé", "email": "f4bug@amsat.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170920201737.25723-3-f4bug@amsat.org/mbox/", "series": [ { "id": 4222, "url": "http://patchwork.ozlabs.org/api/series/4222/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=4222", "date": "2017-09-20T20:17:32", "name": "Add support for Smartfusion2 SoC", "version": 11, "mbox": "http://patchwork.ozlabs.org/series/4222/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/816446/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/816446/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"FoVFmbjS\"; dkim-atps=neutral" ], "Received": [ "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xyB0R49MWz9s7v\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 06:19:03 +1000 (AEST)", "from localhost ([::1]:50483 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dulSX-00082F-KN\n\tfor incoming@patchwork.ozlabs.org; Wed, 20 Sep 2017 16:19:01 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:51267)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1dulRX-0007nq-6l\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 16:18:02 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1dulRV-0002aq-BL\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 16:17:59 -0400", "from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:35147)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1dulRV-0002aK-6g; Wed, 20 Sep 2017 16:17:57 -0400", "by mail-qt0-x244.google.com with SMTP id l25so2466075qtf.2;\n\tWed, 20 Sep 2017 13:17:57 -0700 (PDT)", "from yoga.offpageads.com ([181.93.89.178])\n\tby smtp.gmail.com with ESMTPSA id\n\tu52sm1953092qtb.34.2017.09.20.13.17.52\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tWed, 20 Sep 2017 13:17:54 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=sender:from:to:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=HxKWd1WAIC6qGxlpwEoDvXTk+yCmIqO4aYtRq77hGHk=;\n\tb=FoVFmbjS87J5P7BeoaNWec9UpH6q5+wni+mFfu20zueBs3jeQ5EQW/nSbd8a/AJnBC\n\td7VklVcUFVj00EVq3mX5+l+AHqkI9gTZFVp3ctll7qHGoe2nOSkIit3MglGYcNcV42BS\n\tjRI/zjDxmFqioK3mrpZ58ziPUTehchszzsARP7G6Cft8YAcWlpf3Gqmw71bn3tpBILcy\n\tvjb0aVja2YMolx+MSdRr9v+LNEMUsdett3l2BRpSSQOT4m2lSq6kpAioG7b6gpmjXBQn\n\t6xYWE9U3s9ukf82E4OVi2JRtM9TkpBvwgXkkg+jWDGU5OzwDPFAQf8fTOa/Yv1l2IC1f\n\t+Uuw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:sender:from:to:subject:date:message-id\n\t:in-reply-to:references:mime-version:content-transfer-encoding;\n\tbh=HxKWd1WAIC6qGxlpwEoDvXTk+yCmIqO4aYtRq77hGHk=;\n\tb=pr4WuBhw7RseDi1JdturMOkW5DmVjmsjwTOTfMrxykonCb99sr4BmDEGf5qUG64OyS\n\tYTyJbFqmBWeRVvjeEXLdiNIumyKPYrKHicg2ey9spZU18e/q1/PnBX8w/Q7KHfbW0+Yl\n\tr45Nec2KdiPB1Ht9sQSP6DwTBTMC8DXteX9j6vZcnNuz227FNU+cqGMwXnGEodQW9DLX\n\t1TeHuA6/9zvU0Y7iib1f8uO6VILi20QdeCL7kHh0Ng2/FMI82KXcF+B4mFQDkUPaSEhR\n\tbdS0hOACFuSolvc0QSnD2Bf7YnS+wOh+KTFgHTHEHl0LR5gfZS02YKYdjz/T/4am/t6V\n\tn7fA==", "X-Gm-Message-State": "AHPjjUgRkySWKHKnWleBMRugQGNOnMfqDbihdhnYHqvChxgcd5W07TxK\n\tsnuom+DE/AevXl2pYgyx3h4=", "X-Google-Smtp-Source": "AOwi7QCtCDf2eWj3ENA2lh2x9zvv4QHz7vPro2iymO7b+TKoz9ncRR5rJ9BuMH8NjDcjqpkBe3rlJA==", "X-Received": "by 10.200.56.54 with SMTP id q51mr9411746qtb.168.1505938676624; \n\tWed, 20 Sep 2017 13:17:56 -0700 (PDT)", "From": "=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <f4bug@amsat.org>", "To": "Peter Maydell <peter.maydell@linaro.org>,\n\tSubbaraya Sundeep <sundeep.lkml@gmail.com>,\n\tAlistair Francis <alistair@alistair23.me>,\n\tPeter Crosthwaite <crosthwaite.peter@gmail.com>, qemu-devel@nongnu.org,\n\tqemu-arm@nongnu.org, Igor Mammedov <imammedo@redhat.com>", "Date": "Wed, 20 Sep 2017 17:17:34 -0300", "Message-Id": "<20170920201737.25723-3-f4bug@amsat.org>", "X-Mailer": "git-send-email 2.14.1", "In-Reply-To": "<20170920201737.25723-1-f4bug@amsat.org>", "References": "<20170920201737.25723-1-f4bug@amsat.org>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "X-detected-operating-system": "by eggs.gnu.org: Genre and OS details not\n\trecognized.", "X-Received-From": "2607:f8b0:400d:c0d::244", "Subject": "[Qemu-devel] [PATCH v11 2/5] msf2: Microsemi Smartfusion2 System\n\tRegister block", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.21", "Precedence": "list", "List-Id": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "From: Subbaraya Sundeep <sundeep.lkml@gmail.com>\n\nAdded Sytem register block of Smartfusion2.\nThis block has PLL registers which are accessed by guest.\n\nSigned-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com>\nReviewed-by: Alistair Francis <alistair.francis@xilinx.com>\nAcked-by: Philippe Mathieu-Daudé <f4bug@amsat.org>\nTested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>\n---\n include/hw/misc/msf2-sysreg.h | 77 ++++++++++++++++++++\n hw/misc/msf2-sysreg.c | 160 ++++++++++++++++++++++++++++++++++++++++++\n hw/misc/Makefile.objs | 1 +\n hw/misc/trace-events | 5 ++\n 4 files changed, 243 insertions(+)\n create mode 100644 include/hw/misc/msf2-sysreg.h\n create mode 100644 hw/misc/msf2-sysreg.c", "diff": "diff --git a/include/hw/misc/msf2-sysreg.h b/include/hw/misc/msf2-sysreg.h\nnew file mode 100644\nindex 0000000000..5993f67b4e\n--- /dev/null\n+++ b/include/hw/misc/msf2-sysreg.h\n@@ -0,0 +1,77 @@\n+/*\n+ * Microsemi SmartFusion2 SYSREG\n+ *\n+ * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com>\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the \"Software\"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included in\n+ * all copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+ * THE SOFTWARE.\n+ */\n+\n+#ifndef HW_MSF2_SYSREG_H\n+#define HW_MSF2_SYSREG_H\n+\n+#include \"hw/sysbus.h\"\n+\n+enum {\n+ ESRAM_CR = 0x00 / 4,\n+ ESRAM_MAX_LAT,\n+ DDR_CR,\n+ ENVM_CR,\n+ ENVM_REMAP_BASE_CR,\n+ ENVM_REMAP_FAB_CR,\n+ CC_CR,\n+ CC_REGION_CR,\n+ CC_LOCK_BASE_ADDR_CR,\n+ CC_FLUSH_INDX_CR,\n+ DDRB_BUF_TIMER_CR,\n+ DDRB_NB_ADDR_CR,\n+ DDRB_NB_SIZE_CR,\n+ DDRB_CR,\n+\n+ SOFT_RESET_CR = 0x48 / 4,\n+ M3_CR,\n+\n+ GPIO_SYSRESET_SEL_CR = 0x58 / 4,\n+\n+ MDDR_CR = 0x60 / 4,\n+\n+ MSSDDR_PLL_STATUS_LOW_CR = 0x90 / 4,\n+ MSSDDR_PLL_STATUS_HIGH_CR,\n+ MSSDDR_FACC1_CR,\n+ MSSDDR_FACC2_CR,\n+\n+ MSSDDR_PLL_STATUS = 0x150 / 4,\n+};\n+\n+#define MSF2_SYSREG_MMIO_SIZE 0x300\n+\n+#define TYPE_MSF2_SYSREG \"msf2-sysreg\"\n+#define MSF2_SYSREG(obj) OBJECT_CHECK(MSF2SysregState, (obj), TYPE_MSF2_SYSREG)\n+\n+typedef struct MSF2SysregState {\n+ SysBusDevice parent_obj;\n+\n+ MemoryRegion iomem;\n+\n+ uint8_t apb0div;\n+ uint8_t apb1div;\n+\n+ uint32_t regs[MSF2_SYSREG_MMIO_SIZE / 4];\n+} MSF2SysregState;\n+\n+#endif /* HW_MSF2_SYSREG_H */\ndiff --git a/hw/misc/msf2-sysreg.c b/hw/misc/msf2-sysreg.c\nnew file mode 100644\nindex 0000000000..6eb501104b\n--- /dev/null\n+++ b/hw/misc/msf2-sysreg.c\n@@ -0,0 +1,160 @@\n+/*\n+ * System Register block model of Microsemi SmartFusion2.\n+ *\n+ * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com>\n+ *\n+ * This program is free software; you can redistribute it and/or\n+ * modify it under the terms of the GNU General Public License\n+ * as published by the Free Software Foundation; either version\n+ * 2 of the License, or (at your option) any later version.\n+ *\n+ * You should have received a copy of the GNU General Public License along\n+ * with this program; if not, see <http://www.gnu.org/licenses/>.\n+ */\n+\n+#include \"qemu/osdep.h\"\n+#include \"qapi/error.h\"\n+#include \"qemu/log.h\"\n+#include \"hw/misc/msf2-sysreg.h\"\n+#include \"qemu/error-report.h\"\n+#include \"trace.h\"\n+\n+static inline int msf2_divbits(uint32_t div)\n+{\n+ int r = ctz32(div);\n+\n+ return (div < 8) ? r : r + 1;\n+}\n+\n+static void msf2_sysreg_reset(DeviceState *d)\n+{\n+ MSF2SysregState *s = MSF2_SYSREG(d);\n+\n+ s->regs[MSSDDR_PLL_STATUS_LOW_CR] = 0x021A2358;\n+ s->regs[MSSDDR_PLL_STATUS] = 0x3;\n+ s->regs[MSSDDR_FACC1_CR] = msf2_divbits(s->apb0div) << 5 |\n+ msf2_divbits(s->apb1div) << 2;\n+}\n+\n+static uint64_t msf2_sysreg_read(void *opaque, hwaddr offset,\n+ unsigned size)\n+{\n+ MSF2SysregState *s = opaque;\n+ uint32_t ret = 0;\n+\n+ offset >>= 2;\n+ if (offset < ARRAY_SIZE(s->regs)) {\n+ ret = s->regs[offset];\n+ trace_msf2_sysreg_read(offset << 2, ret);\n+ } else {\n+ qemu_log_mask(LOG_GUEST_ERROR,\n+ \"%s: Bad offset 0x%08\" HWADDR_PRIx \"\\n\", __func__,\n+ offset << 2);\n+ }\n+\n+ return ret;\n+}\n+\n+static void msf2_sysreg_write(void *opaque, hwaddr offset,\n+ uint64_t val, unsigned size)\n+{\n+ MSF2SysregState *s = opaque;\n+ uint32_t newval = val;\n+\n+ offset >>= 2;\n+\n+ switch (offset) {\n+ case MSSDDR_PLL_STATUS:\n+ trace_msf2_sysreg_write_pll_status();\n+ break;\n+\n+ case ESRAM_CR:\n+ case DDR_CR:\n+ case ENVM_REMAP_BASE_CR:\n+ if (newval != s->regs[offset]) {\n+ qemu_log_mask(LOG_UNIMP,\n+ TYPE_MSF2_SYSREG\": remapping not supported\\n\");\n+ }\n+ break;\n+\n+ default:\n+ if (offset < ARRAY_SIZE(s->regs)) {\n+ trace_msf2_sysreg_write(offset << 2, newval, s->regs[offset]);\n+ s->regs[offset] = newval;\n+ } else {\n+ qemu_log_mask(LOG_GUEST_ERROR,\n+ \"%s: Bad offset 0x%08\" HWADDR_PRIx \"\\n\", __func__,\n+ offset << 2);\n+ }\n+ break;\n+ }\n+}\n+\n+static const MemoryRegionOps sysreg_ops = {\n+ .read = msf2_sysreg_read,\n+ .write = msf2_sysreg_write,\n+ .endianness = DEVICE_NATIVE_ENDIAN,\n+};\n+\n+static void msf2_sysreg_init(Object *obj)\n+{\n+ MSF2SysregState *s = MSF2_SYSREG(obj);\n+\n+ memory_region_init_io(&s->iomem, obj, &sysreg_ops, s, TYPE_MSF2_SYSREG,\n+ MSF2_SYSREG_MMIO_SIZE);\n+ sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);\n+}\n+\n+static const VMStateDescription vmstate_msf2_sysreg = {\n+ .name = TYPE_MSF2_SYSREG,\n+ .version_id = 1,\n+ .minimum_version_id = 1,\n+ .fields = (VMStateField[]) {\n+ VMSTATE_UINT32_ARRAY(regs, MSF2SysregState, MSF2_SYSREG_MMIO_SIZE / 4),\n+ VMSTATE_END_OF_LIST()\n+ }\n+};\n+\n+static Property msf2_sysreg_properties[] = {\n+ /* default divisors in Libero GUI */\n+ DEFINE_PROP_UINT8(\"apb0divisor\", MSF2SysregState, apb0div, 2),\n+ DEFINE_PROP_UINT8(\"apb1divisor\", MSF2SysregState, apb1div, 2),\n+ DEFINE_PROP_END_OF_LIST(),\n+};\n+\n+static void msf2_sysreg_realize(DeviceState *dev, Error **errp)\n+{\n+ MSF2SysregState *s = MSF2_SYSREG(dev);\n+\n+ if ((s->apb0div > 32 || !is_power_of_2(s->apb0div))\n+ || (s->apb1div > 32 || !is_power_of_2(s->apb1div))) {\n+ error_setg(errp, \"Invalid apb divisor value\");\n+ error_append_hint(errp, \"apb divisor must be a power of 2\"\n+ \" and maximum value is 32\\n\");\n+ }\n+}\n+\n+static void msf2_sysreg_class_init(ObjectClass *klass, void *data)\n+{\n+ DeviceClass *dc = DEVICE_CLASS(klass);\n+\n+ dc->vmsd = &vmstate_msf2_sysreg;\n+ dc->reset = msf2_sysreg_reset;\n+ dc->props = msf2_sysreg_properties;\n+ dc->realize = msf2_sysreg_realize;\n+}\n+\n+static const TypeInfo msf2_sysreg_info = {\n+ .name = TYPE_MSF2_SYSREG,\n+ .parent = TYPE_SYS_BUS_DEVICE,\n+ .class_init = msf2_sysreg_class_init,\n+ .instance_size = sizeof(MSF2SysregState),\n+ .instance_init = msf2_sysreg_init,\n+};\n+\n+static void msf2_sysreg_register_types(void)\n+{\n+ type_register_static(&msf2_sysreg_info);\n+}\n+\n+type_init(msf2_sysreg_register_types)\ndiff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs\nindex 29fb922cef..e8f0a02f35 100644\n--- a/hw/misc/Makefile.objs\n+++ b/hw/misc/Makefile.objs\n@@ -59,3 +59,4 @@ obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o\n obj-$(CONFIG_AUX) += auxbus.o\n obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o\n obj-y += mmio_interface.o\n+obj-$(CONFIG_MSF2) += msf2-sysreg.o\ndiff --git a/hw/misc/trace-events b/hw/misc/trace-events\nindex 3313585b12..616579a403 100644\n--- a/hw/misc/trace-events\n+++ b/hw/misc/trace-events\n@@ -61,3 +61,8 @@ mps2_scc_reset(void) \"MPS2 SCC: reset\"\n mps2_scc_leds(char led7, char led6, char led5, char led4, char led3, char led2, char led1, char led0) \"MPS2 SCC LEDs: %c%c%c%c%c%c%c%c\"\n mps2_scc_cfg_write(unsigned function, unsigned device, uint32_t value) \"MPS2 SCC config write: function %d device %d data 0x%\" PRIx32\n mps2_scc_cfg_read(unsigned function, unsigned device, uint32_t value) \"MPS2 SCC config read: function %d device %d data 0x%\" PRIx32\n+\n+# hw/misc/msf2-sysreg.c\n+msf2_sysreg_write(uint64_t offset, uint32_t val, uint32_t prev) \"msf2-sysreg write: addr 0x%08\" HWADDR_PRIx \" data 0x%\" PRIx32 \" prev 0x%\" PRIx32\n+msf2_sysreg_read(uint64_t offset, uint32_t val) \"msf2-sysreg read: addr 0x%08\" HWADDR_PRIx \" data 0x%08\" PRIx32\n+msf2_sysreg_write_pll_status(void) \"Invalid write to read only PLL status register\"\n", "prefixes": [ "v11", "2/5" ] }