[{"id":1769827,"web_url":"http://patchwork.ozlabs.org/comment/1769827/","msgid":"<9d3d6ffd-bf3b-8102-8a08-beee28656a54@amsat.org>","list_archive_url":null,"date":"2017-09-18T01:08:32","subject":"Re: [Qemu-devel] [Qemu devel v9 PATCH 4/5] msf2: Add Smartfusion2\n\tSoC","submitter":{"id":70924,"url":"http://patchwork.ozlabs.org/api/people/70924/","name":"Philippe Mathieu-Daudé","email":"f4bug@amsat.org"},"content":"On 09/15/2017 01:59 PM, Subbaraya Sundeep wrote:\n> Smartfusion2 SoC has hardened Microcontroller subsystem\n> and flash based FPGA fabric. This patch adds support for\n> Microcontroller subsystem in the SoC.\n> \n> Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com>\n> Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>\n> ---\n>   default-configs/arm-softmmu.mak |   1 +\n>   hw/arm/Makefile.objs            |   1 +\n>   hw/arm/msf2-soc.c               | 232 ++++++++++++++++++++++++++++++++++++++++\n>   include/hw/arm/msf2-soc.h       |  66 ++++++++++++\n>   4 files changed, 300 insertions(+)\n>   create mode 100644 hw/arm/msf2-soc.c\n>   create mode 100644 include/hw/arm/msf2-soc.h\n> \n> diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak\n> index bbdd3c1..5059d13 100644\n> --- a/default-configs/arm-softmmu.mak\n> +++ b/default-configs/arm-softmmu.mak\n> @@ -129,3 +129,4 @@ CONFIG_ACPI=y\n>   CONFIG_SMBIOS=y\n>   CONFIG_ASPEED_SOC=y\n>   CONFIG_GPIO_KEY=y\n> +CONFIG_MSF2=y\n> diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs\n> index a2e56ec..df36a03 100644\n> --- a/hw/arm/Makefile.objs\n> +++ b/hw/arm/Makefile.objs\n> @@ -19,3 +19,4 @@ obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o\n>   obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o\n>   obj-$(CONFIG_ASPEED_SOC) += aspeed_soc.o aspeed.o\n>   obj-$(CONFIG_MPS2) += mps2.o\n> +obj-$(CONFIG_MSF2) += msf2-soc.o\n> diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c\n> new file mode 100644\n> index 0000000..5c0a2ea\n> --- /dev/null\n> +++ b/hw/arm/msf2-soc.c\n> @@ -0,0 +1,232 @@\n> +/*\n> + * SmartFusion2 SoC emulation.\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> +#include \"qemu/osdep.h\"\n> +#include \"qapi/error.h\"\n> +#include \"qemu-common.h\"\n> +#include \"hw/arm/arm.h\"\n> +#include \"exec/address-spaces.h\"\n> +#include \"hw/char/serial.h\"\n> +#include \"hw/boards.h\"\n> +#include \"sysemu/block-backend.h\"\n> +#include \"qemu/cutils.h\"\n> +#include \"hw/arm/msf2-soc.h\"\n> +#include \"hw/misc/unimp.h\"\n> +\n> +#define MSF2_TIMER_BASE       0x40004000\n> +#define MSF2_SYSREG_BASE      0x40038000\n> +\n> +#define ENVM_BASE_ADDRESS     0x60000000\n> +\n> +#define SRAM_BASE_ADDRESS     0x20000000\n> +\n> +#define MSF2_ENVM_MAX_SIZE    (512 * K_BYTE)\n> +\n> +/*\n> + * eSRAM max size is 80k without SECDED(Single error correction and\n> + * dual error detection) feature and 64k with SECDED.\n> + * We do not support SECDED now.\n> + */\n> +#define MSF2_ESRAM_MAX_SIZE       (80 * K_BYTE)\n> +\n> +static const uint32_t spi_addr[MSF2_NUM_SPIS] = { 0x40001000 , 0x40011000 };\n> +static const uint32_t uart_addr[MSF2_NUM_UARTS] = { 0x40000000 , 0x40010000 };\n> +\n> +static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 };\n> +static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 };\n> +static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 };\n> +\n> +static void m2sxxx_soc_initfn(Object *obj)\n> +{\n> +    MSF2State *s = MSF2_SOC(obj);\n> +    int i;\n> +\n> +    object_initialize(&s->armv7m, sizeof(s->armv7m), TYPE_ARMV7M);\n> +    qdev_set_parent_bus(DEVICE(&s->armv7m), sysbus_get_default());\n> +\n> +    object_initialize(&s->sysreg, sizeof(s->sysreg), TYPE_MSF2_SYSREG);\n> +    qdev_set_parent_bus(DEVICE(&s->sysreg), sysbus_get_default());\n> +\n> +    object_initialize(&s->timer, sizeof(s->timer), TYPE_MSS_TIMER);\n> +    qdev_set_parent_bus(DEVICE(&s->timer), sysbus_get_default());\n> +\n> +    for (i = 0; i < MSF2_NUM_SPIS; i++) {\n> +        object_initialize(&s->spi[i], sizeof(s->spi[i]),\n> +                          TYPE_MSS_SPI);\n> +        qdev_set_parent_bus(DEVICE(&s->spi[i]), sysbus_get_default());\n> +    }\n> +}\n> +\n> +static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)\n> +{\n> +    MSF2State *s = MSF2_SOC(dev_soc);\n> +    DeviceState *dev, *armv7m;\n> +    SysBusDevice *busdev;\n> +    Error *err = NULL;\n> +    int i;\n> +\n> +    MemoryRegion *system_memory = get_system_memory();\n> +    MemoryRegion *nvm = g_new(MemoryRegion, 1);\n> +    MemoryRegion *nvm_alias = g_new(MemoryRegion, 1);\n> +    MemoryRegion *sram = g_new(MemoryRegion, 1);\n> +\n> +    memory_region_init_rom(nvm, NULL, \"MSF2.eNVM\", s->envm_size,\n> +                           &error_fatal);\n> +    /*\n> +     * On power-on, the eNVM region 0x60000000 is automatically\n> +     * remapped to the Cortex-M3 processor executable region\n> +     * start address (0x0). We do not support remapping other eNVM,\n> +     * eSRAM and DDR regions by guest(via Sysreg) currently.\n> +     */\n> +    memory_region_init_alias(nvm_alias, NULL, \"MSF2.eNVM\",\n> +                             nvm, 0, s->envm_size);\n> +\n> +    memory_region_add_subregion(system_memory, ENVM_BASE_ADDRESS, nvm);\n> +    memory_region_add_subregion(system_memory, 0, nvm_alias);\n> +\n> +    memory_region_init_ram(sram, NULL, \"MSF2.eSRAM\", s->esram_size,\n> +                           &error_fatal);\n> +    memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, sram);\n> +\n> +    armv7m = DEVICE(&s->armv7m);\n> +    qdev_prop_set_uint32(armv7m, \"num-irq\", 81);\n> +    qdev_prop_set_string(armv7m, \"cpu-model\", \"cortex-m3\");\n> +    object_property_set_link(OBJECT(&s->armv7m), OBJECT(get_system_memory()),\n> +                                     \"memory\", &error_abort);\n> +    object_property_set_bool(OBJECT(&s->armv7m), true, \"realized\", &err);\n> +    if (err != NULL) {\n> +        error_propagate(errp, err);\n> +        return;\n> +    }\n> +\n> +    system_clock_scale = NANOSECONDS_PER_SECOND / s->m3clk;\n> +\n> +    for (i = 0; i < MSF2_NUM_UARTS; i++) {\n> +        if (serial_hds[i]) {\n> +            serial_mm_init(get_system_memory(), uart_addr[i], 2,\n> +                           qdev_get_gpio_in(armv7m, uart_irq[i]),\n> +                           115200, serial_hds[i], DEVICE_NATIVE_ENDIAN);\n> +        }\n> +    }\n> +\n> +    dev = DEVICE(&s->timer);\n> +    /* APB0 clock is the timer input clock */\n> +    qdev_prop_set_uint32(dev, \"clock-frequency\", s->m3clk / s->apb0div);\n> +    object_property_set_bool(OBJECT(&s->timer), true, \"realized\", &err);\n> +    if (err != NULL) {\n> +        error_propagate(errp, err);\n> +        return;\n> +    }\n> +    busdev = SYS_BUS_DEVICE(dev);\n> +    sysbus_mmio_map(busdev, 0, MSF2_TIMER_BASE);\n> +    sysbus_connect_irq(busdev, 0,\n> +                           qdev_get_gpio_in(armv7m, timer_irq[0]));\n> +    sysbus_connect_irq(busdev, 1,\n> +                           qdev_get_gpio_in(armv7m, timer_irq[1]));\n> +\n> +    dev = DEVICE(&s->sysreg);\n> +    qdev_prop_set_uint32(dev, \"apb0divisor\", s->apb0div);\n> +    qdev_prop_set_uint32(dev, \"apb1divisor\", s->apb1div);\n> +    object_property_set_bool(OBJECT(&s->sysreg), true, \"realized\", &err);\n> +    if (err != NULL) {\n> +        error_propagate(errp, err);\n> +        return;\n> +    }\n> +    busdev = SYS_BUS_DEVICE(dev);\n> +    sysbus_mmio_map(busdev, 0, MSF2_SYSREG_BASE);\n> +\n> +    for (i = 0; i < MSF2_NUM_SPIS; i++) {\n> +        gchar *bus_name;\n> +\n> +        object_property_set_bool(OBJECT(&s->spi[i]), true, \"realized\", &err);\n> +        if (err != NULL) {\n> +            error_propagate(errp, err);\n> +            return;\n> +        }\n> +\n> +        sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, spi_addr[i]);\n> +        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,\n> +                           qdev_get_gpio_in(armv7m, spi_irq[i]));\n> +\n> +        /* Alias controller SPI bus to the SoC itself */\n> +        bus_name = g_strdup_printf(\"spi%d\", i);\n> +        object_property_add_alias(OBJECT(s), bus_name,\n> +                                  OBJECT(&s->spi[i]), \"spi\",\n> +                                  &error_abort);\n> +        g_free(bus_name);\n> +    }\n> +\n> +    /* Below devices are not modelled yet. */\n> +    create_unimplemented_device(\"i2c_0\", 0x40002000, 0x1000);\n> +    create_unimplemented_device(\"pdma\", 0x40003000, 0x1000);\n\nname it \"dma\" only.\n\n> +    create_unimplemented_device(\"watchdog\", 0x40005000, 0x1000);\n> +    create_unimplemented_device(\"i2c_1\", 0x40012000, 0x1000);\n> +    create_unimplemented_device(\"gpio\", 0x40013000, 0x1000);\n> +    create_unimplemented_device(\"hpdma\", 0x40014000, 0x1000);\n\n\"hs-dma\" ?\n\n> +    create_unimplemented_device(\"can\", 0x40015000, 0x1000);\n> +    create_unimplemented_device(\"rtc\", 0x40017000, 0x1000);\n> +    create_unimplemented_device(\"apb_config\", 0x40020000, 0x10000);\n\nhmm ok.\n\n> +    create_unimplemented_device(\"emac\", 0x40041000, 0x1000);\n> +    create_unimplemented_device(\"usb\", 0x40043000, 0x1000);\n> +}\n\nnow the cpu memory tree looks:\n\n(qemu) info mtree\naddress-space: cpu-memory\n   0000000000000000-ffffffffffffffff (prio 0, i/o): armv7m-container\n     0000000000000000-ffffffffffffffff (prio -1, i/o): system\n       0000000000000000-000000000003ffff (prio 0, i/o): alias MSF2.eNVM \n@MSF2.eNVM 0000000000000000-000000000003ffff\n       0000000020000000-000000002000ffff (prio 0, ram): MSF2.eSRAM\n       0000000040000000-000000004000001f (prio 0, i/o): serial\n       0000000040001000-000000004000103f (prio 0, i/o): mss-spi\n       0000000040002000-0000000040002fff (prio -1000, i/o): i2c_0\n       0000000040003000-0000000040003fff (prio -1000, i/o): pdma\n       0000000040004000-000000004000402f (prio 0, i/o): mss-timer\n       0000000040005000-0000000040005fff (prio -1000, i/o): watchdog\n       0000000040011000-000000004001103f (prio 0, i/o): mss-spi\n       0000000040012000-0000000040012fff (prio -1000, i/o): i2c_1\n       0000000040013000-0000000040013fff (prio -1000, i/o): gpio\n       0000000040014000-0000000040014fff (prio -1000, i/o): hpdma\n       0000000040015000-0000000040015fff (prio -1000, i/o): can\n       0000000040017000-0000000040017fff (prio -1000, i/o): rtc\n       0000000040020000-000000004002ffff (prio -1000, i/o): apb_config\n       0000000040038000-00000000400382ff (prio 0, i/o): msf2-sysreg\n       0000000040041000-0000000040041fff (prio -1000, i/o): emac\n       0000000040043000-0000000040043fff (prio -1000, i/o): usb\n       0000000060000000-000000006003ffff (prio 0, rom): MSF2.eNVM\n       00000000a0000000-00000000a3ffffff (prio 0, ram): ddr-ram\n     0000000022000000-0000000023ffffff (prio 0, i/o): bitband\n     0000000042000000-0000000043ffffff (prio 0, i/o): bitband\n     00000000e000e000-00000000e000efff (prio 0, i/o): nvic\n       00000000e000e000-00000000e000efff (prio 0, i/o): nvic_sysregs\n       00000000e000e010-00000000e000e0ef (prio 1, i/o): systick\n\n> +\n> +static Property m2sxxx_soc_properties[] = {\n> +    /*\n> +     * part name specifies the type of SmartFusion2 device variant(this\n> +     * property is for information purpose only.\n> +     */\n> +    DEFINE_PROP_STRING(\"part-name\", MSF2State, part_name),\n> +    DEFINE_PROP_UINT64(\"eNVM-size\", MSF2State, envm_size, MSF2_ENVM_MAX_SIZE),\n> +    DEFINE_PROP_UINT64(\"eSRAM-size\", MSF2State, esram_size,\n> +                        MSF2_ESRAM_MAX_SIZE),\n> +    /* Libero GUI shows 100Mhz as default for clocks */\n> +    DEFINE_PROP_UINT32(\"m3clk\", MSF2State, m3clk, 100 * 1000000),\n> +    /* default divisors in Libero GUI */\n> +    DEFINE_PROP_UINT32(\"apb0div\", MSF2State, apb0div, 2),\n> +    DEFINE_PROP_UINT32(\"apb1div\", MSF2State, apb1div, 2),\n\nDEFINE_PROP_UINT8 ?\n\n> +    DEFINE_PROP_END_OF_LIST(),\n> +};\n> +\n> +static void m2sxxx_soc_class_init(ObjectClass *klass, void *data)\n> +{\n> +    DeviceClass *dc = DEVICE_CLASS(klass);\n> +\n> +    dc->realize = m2sxxx_soc_realize;\n> +    dc->props = m2sxxx_soc_properties;\n> +}\n> +\n> +static const TypeInfo m2sxxx_soc_info = {\n> +    .name          = TYPE_MSF2_SOC,\n> +    .parent        = TYPE_SYS_BUS_DEVICE,\n> +    .instance_size = sizeof(MSF2State),\n> +    .instance_init = m2sxxx_soc_initfn,\n> +    .class_init    = m2sxxx_soc_class_init,\n> +};\n> +\n> +static void m2sxxx_soc_types(void)\n> +{\n> +    type_register_static(&m2sxxx_soc_info);\n> +}\n> +\n> +type_init(m2sxxx_soc_types)\n> diff --git a/include/hw/arm/msf2-soc.h b/include/hw/arm/msf2-soc.h\n> new file mode 100644\n> index 0000000..eb239fa\n> --- /dev/null\n> +++ b/include/hw/arm/msf2-soc.h\n> @@ -0,0 +1,66 @@\n> +/*\n> + * Microsemi Smartfusion2 SoC\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_ARM_MSF2_SOC_H\n> +#define HW_ARM_MSF2_SOC_H\n> +\n> +#include \"hw/arm/armv7m.h\"\n> +#include \"hw/timer/mss-timer.h\"\n> +#include \"hw/misc/msf2-sysreg.h\"\n> +#include \"hw/ssi/mss-spi.h\"\n> +\n> +#define TYPE_MSF2_SOC     \"msf2-soc\"\n> +#define MSF2_SOC(obj)     OBJECT_CHECK(MSF2State, (obj), TYPE_MSF2_SOC)\n> +\n> +#define MSF2_NUM_SPIS         2\n> +#define MSF2_NUM_UARTS        2\n> +\n> +/*\n> + * System timer consists of two programmable 32-bit\n> + * decrementing counters that generate individual interrupts to\n> + * the Cortex-M3 processor\n> + */\n> +#define MSF2_NUM_TIMERS       2\n> +\n> +typedef struct MSF2State {\n> +    /*< private >*/\n> +    SysBusDevice parent_obj;\n> +    /*< public >*/\n> +\n> +    ARMv7MState armv7m;\n> +\n> +    char *part_name;\n> +    uint64_t envm_size;\n> +    uint64_t esram_size;\n> +\n> +    uint32_t m3clk;\n> +    uint32_t apb0div;\n> +    uint32_t apb1div;\n\nuint8_t ?\n\n> +\n> +    MSF2SysregState sysreg;\n> +    MSSTimerState timer;\n> +    MSSSpiState spi[MSF2_NUM_SPIS];\n> +} MSF2State;\n> +\n> +#endif\n> \n\nReviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>\nTested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>","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=\"CAeM3N2H\"; 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 3xwSZk2qrXz9sDB\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 11:09:17 +1000 (AEST)","from localhost ([::1]:34176 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 1dtkYk-0003u5-Jf\n\tfor incoming@patchwork.ozlabs.org; Sun, 17 Sep 2017 21:09:14 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:33510)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1dtkYK-0003s0-Ck\n\tfor qemu-devel@nongnu.org; Sun, 17 Sep 2017 21:08:51 -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 1dtkYI-0001w2-1z\n\tfor qemu-devel@nongnu.org; Sun, 17 Sep 2017 21:08:48 -0400","from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:37680)\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 1dtkY9-0001qm-5Q; Sun, 17 Sep 2017 21:08:37 -0400","by mail-qk0-x242.google.com with SMTP id r66so4639025qke.4;\n\tSun, 17 Sep 2017 18:08:37 -0700 (PDT)","from [192.168.1.10] ([181.93.89.178])\n\tby smtp.gmail.com with ESMTPSA id\n\ta12sm4416284qta.3.2017.09.17.18.08.33\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSun, 17 Sep 2017 18:08:35 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=sender:subject:to:cc:references:from:message-id:date:user-agent\n\t:mime-version:in-reply-to:content-language:content-transfer-encoding; \n\tbh=kKjdw77eCXKP+TakHtdnpN4tcG2OOAUM9GZkMU5tsN0=;\n\tb=CAeM3N2HqjjZecTJe8UWEnwV6LFjyHe5INK4e9u2mdK4Z0zulcXlypI5ODXLHPKFlA\n\tB8/9ihUOpc/FRr5VhoEBX6fyCkRoyAEaz2upR2WMJoy0z/3vd5wdmYz4DKfGqrcnp1Ry\n\tVjC/YnZ+TyXrJ5iQH5yqJPE3pcfF/Pl8mmLIPxs2W5iFIH7gp5eecI1fpCqWJSh8E9VL\n\t4fkofypKNdocwOznnfyQ3BSG/W0ogro1rKb5XaL6wZfHs+d8HfGOztPwwdjuUbYtD+4t\n\toMBhImn7egMlJwBTRKFHHQqDVW0e4miX0djpaP9OkXyjNjCLe53fSVLoFO82GuGiArhb\n\tdSIw==","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:subject:to:cc:references:from:message-id\n\t:date:user-agent:mime-version:in-reply-to:content-language\n\t:content-transfer-encoding;\n\tbh=kKjdw77eCXKP+TakHtdnpN4tcG2OOAUM9GZkMU5tsN0=;\n\tb=Hhd/uYmRGKbLdX5yo7+kVO9nYS/zHIaV4tF3Ih1C6VmoLsaY0KXiN32ulSSUpm/B3v\n\tJ+1gsVTpgPlDfbNOeY3kRCjcDP4UuJ0eyvx3H9VABeqMz64994HZlWhBP7ihADJQpEVC\n\tN/tzOBHMOY1H+mA3g1RDtE1vVJFKb+Qy9gKjFZ8VmrZYG2sYzgpNCOpisXbjM5cqkMJT\n\tERSrzv3wbDYYOOmmVcr10P4Dw1CiLALly7qe+PYJMtw8nG2YKHFW2xHoQXIov6evCDZU\n\tbNx7jQYOGy0GSVc3OXy4l375heFCr4EqMZ4pbaLme7OQJIVJvLFGo74EG/39146j+iXV\n\tQatQ==","X-Gm-Message-State":"AHPjjUh1FNeIiAT4Wsha5J3jmGiQ/o8LUhmMyTwIXxUmExJNx6e+RFa2\n\teSRlDFKeKBkCyA==","X-Google-Smtp-Source":"AOwi7QD67xV7oWIMpCexQ2flPhkATwpcVT00oFAagF9l+x7vRD7E6dfjKLZ5Q85LKazmlvqZTHboAg==","X-Received":"by 10.55.215.211 with SMTP id t80mr17941096qkt.30.1505696916341; \n\tSun, 17 Sep 2017 18:08:36 -0700 (PDT)","To":"Subbaraya Sundeep <sundeep.lkml@gmail.com>","References":"<1505494753-10837-1-git-send-email-sundeep.lkml@gmail.com>\n\t<1505494753-10837-5-git-send-email-sundeep.lkml@gmail.com>","From":"=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <f4bug@amsat.org>","Message-ID":"<9d3d6ffd-bf3b-8102-8a08-beee28656a54@amsat.org>","Date":"Sun, 17 Sep 2017 22:08:32 -0300","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<1505494753-10837-5-git-send-email-sundeep.lkml@gmail.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Language":"en-US","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:c09::242","Subject":"Re: [Qemu-devel] [Qemu devel v9 PATCH 4/5] msf2: Add Smartfusion2\n\tSoC","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>","Cc":"peter.maydell@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org,\n\talistair23@gmail.com, crosthwaite.peter@gmail.com","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>"}},{"id":1770030,"web_url":"http://patchwork.ozlabs.org/comment/1770030/","msgid":"<CALHRZurrbATjkAbBc-RJBH-+nX8jA4WcV2tqS+CNw8VaKEEkjQ@mail.gmail.com>","list_archive_url":null,"date":"2017-09-18T09:49:27","subject":"Re: [Qemu-devel] [Qemu devel v9 PATCH 4/5] msf2: Add Smartfusion2\n\tSoC","submitter":{"id":64324,"url":"http://patchwork.ozlabs.org/api/people/64324/","name":"sundeep subbaraya","email":"sundeep.lkml@gmail.com"},"content":"Hi Philippe,\n\nOn Mon, Sep 18, 2017 at 6:38 AM, Philippe Mathieu-Daudé <f4bug@amsat.org>\nwrote:\n\n> On 09/15/2017 01:59 PM, Subbaraya Sundeep wrote:\n>\n>> Smartfusion2 SoC has hardened Microcontroller subsystem\n>> and flash based FPGA fabric. This patch adds support for\n>> Microcontroller subsystem in the SoC.\n>>\n>> Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com>\n>> Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>\n>> ---\n>>   default-configs/arm-softmmu.mak |   1 +\n>>   hw/arm/Makefile.objs            |   1 +\n>>   hw/arm/msf2-soc.c               | 232 ++++++++++++++++++++++++++++++\n>> ++++++++++\n>>   include/hw/arm/msf2-soc.h       |  66 ++++++++++++\n>>   4 files changed, 300 insertions(+)\n>>   create mode 100644 hw/arm/msf2-soc.c\n>>   create mode 100644 include/hw/arm/msf2-soc.h\n>>\n>> diff --git a/default-configs/arm-softmmu.mak\n>> b/default-configs/arm-softmmu.mak\n>> index bbdd3c1..5059d13 100644\n>> --- a/default-configs/arm-softmmu.mak\n>> +++ b/default-configs/arm-softmmu.mak\n>> @@ -129,3 +129,4 @@ CONFIG_ACPI=y\n>>   CONFIG_SMBIOS=y\n>>   CONFIG_ASPEED_SOC=y\n>>   CONFIG_GPIO_KEY=y\n>> +CONFIG_MSF2=y\n>> diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs\n>> index a2e56ec..df36a03 100644\n>> --- a/hw/arm/Makefile.objs\n>> +++ b/hw/arm/Makefile.objs\n>> @@ -19,3 +19,4 @@ obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o\n>>   obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o\n>>   obj-$(CONFIG_ASPEED_SOC) += aspeed_soc.o aspeed.o\n>>   obj-$(CONFIG_MPS2) += mps2.o\n>> +obj-$(CONFIG_MSF2) += msf2-soc.o\n>> diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c\n>> new file mode 100644\n>> index 0000000..5c0a2ea\n>> --- /dev/null\n>> +++ b/hw/arm/msf2-soc.c\n>> @@ -0,0 +1,232 @@\n>> +/*\n>> + * SmartFusion2 SoC emulation.\n>> + *\n>> + * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com>\n>> + *\n>> + * Permission is hereby granted, free of charge, to any person obtaining\n>> a copy\n>> + * of this software and associated documentation files (the \"Software\"),\n>> to deal\n>> + * in the Software without restriction, including without limitation the\n>> rights\n>> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or\n>> 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\n>> included in\n>> + * all copies or substantial portions of the Software.\n>> + *\n>> + * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n>> EXPRESS OR\n>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n>> MERCHANTABILITY,\n>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT\n>> SHALL\n>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n>> OTHER\n>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\n>> ARISING FROM,\n>> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n>> DEALINGS IN\n>> + * THE SOFTWARE.\n>> + */\n>> +\n>> +#include \"qemu/osdep.h\"\n>> +#include \"qapi/error.h\"\n>> +#include \"qemu-common.h\"\n>> +#include \"hw/arm/arm.h\"\n>> +#include \"exec/address-spaces.h\"\n>> +#include \"hw/char/serial.h\"\n>> +#include \"hw/boards.h\"\n>> +#include \"sysemu/block-backend.h\"\n>> +#include \"qemu/cutils.h\"\n>> +#include \"hw/arm/msf2-soc.h\"\n>> +#include \"hw/misc/unimp.h\"\n>> +\n>> +#define MSF2_TIMER_BASE       0x40004000\n>> +#define MSF2_SYSREG_BASE      0x40038000\n>> +\n>> +#define ENVM_BASE_ADDRESS     0x60000000\n>> +\n>> +#define SRAM_BASE_ADDRESS     0x20000000\n>> +\n>> +#define MSF2_ENVM_MAX_SIZE    (512 * K_BYTE)\n>> +\n>> +/*\n>> + * eSRAM max size is 80k without SECDED(Single error correction and\n>> + * dual error detection) feature and 64k with SECDED.\n>> + * We do not support SECDED now.\n>> + */\n>> +#define MSF2_ESRAM_MAX_SIZE       (80 * K_BYTE)\n>> +\n>> +static const uint32_t spi_addr[MSF2_NUM_SPIS] = { 0x40001000 ,\n>> 0x40011000 };\n>> +static const uint32_t uart_addr[MSF2_NUM_UARTS] = { 0x40000000 ,\n>> 0x40010000 };\n>> +\n>> +static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 };\n>> +static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 };\n>> +static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 };\n>> +\n>> +static void m2sxxx_soc_initfn(Object *obj)\n>> +{\n>> +    MSF2State *s = MSF2_SOC(obj);\n>> +    int i;\n>> +\n>> +    object_initialize(&s->armv7m, sizeof(s->armv7m), TYPE_ARMV7M);\n>> +    qdev_set_parent_bus(DEVICE(&s->armv7m), sysbus_get_default());\n>> +\n>> +    object_initialize(&s->sysreg, sizeof(s->sysreg), TYPE_MSF2_SYSREG);\n>> +    qdev_set_parent_bus(DEVICE(&s->sysreg), sysbus_get_default());\n>> +\n>> +    object_initialize(&s->timer, sizeof(s->timer), TYPE_MSS_TIMER);\n>> +    qdev_set_parent_bus(DEVICE(&s->timer), sysbus_get_default());\n>> +\n>> +    for (i = 0; i < MSF2_NUM_SPIS; i++) {\n>> +        object_initialize(&s->spi[i], sizeof(s->spi[i]),\n>> +                          TYPE_MSS_SPI);\n>> +        qdev_set_parent_bus(DEVICE(&s->spi[i]), sysbus_get_default());\n>> +    }\n>> +}\n>> +\n>> +static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)\n>> +{\n>> +    MSF2State *s = MSF2_SOC(dev_soc);\n>> +    DeviceState *dev, *armv7m;\n>> +    SysBusDevice *busdev;\n>> +    Error *err = NULL;\n>> +    int i;\n>> +\n>> +    MemoryRegion *system_memory = get_system_memory();\n>> +    MemoryRegion *nvm = g_new(MemoryRegion, 1);\n>> +    MemoryRegion *nvm_alias = g_new(MemoryRegion, 1);\n>> +    MemoryRegion *sram = g_new(MemoryRegion, 1);\n>> +\n>> +    memory_region_init_rom(nvm, NULL, \"MSF2.eNVM\", s->envm_size,\n>> +                           &error_fatal);\n>> +    /*\n>> +     * On power-on, the eNVM region 0x60000000 is automatically\n>> +     * remapped to the Cortex-M3 processor executable region\n>> +     * start address (0x0). We do not support remapping other eNVM,\n>> +     * eSRAM and DDR regions by guest(via Sysreg) currently.\n>> +     */\n>> +    memory_region_init_alias(nvm_alias, NULL, \"MSF2.eNVM\",\n>> +                             nvm, 0, s->envm_size);\n>> +\n>> +    memory_region_add_subregion(system_memory, ENVM_BASE_ADDRESS, nvm);\n>> +    memory_region_add_subregion(system_memory, 0, nvm_alias);\n>> +\n>> +    memory_region_init_ram(sram, NULL, \"MSF2.eSRAM\", s->esram_size,\n>> +                           &error_fatal);\n>> +    memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, sram);\n>> +\n>> +    armv7m = DEVICE(&s->armv7m);\n>> +    qdev_prop_set_uint32(armv7m, \"num-irq\", 81);\n>> +    qdev_prop_set_string(armv7m, \"cpu-model\", \"cortex-m3\");\n>> +    object_property_set_link(OBJECT(&s->armv7m),\n>> OBJECT(get_system_memory()),\n>> +                                     \"memory\", &error_abort);\n>> +    object_property_set_bool(OBJECT(&s->armv7m), true, \"realized\",\n>> &err);\n>> +    if (err != NULL) {\n>> +        error_propagate(errp, err);\n>> +        return;\n>> +    }\n>> +\n>> +    system_clock_scale = NANOSECONDS_PER_SECOND / s->m3clk;\n>> +\n>> +    for (i = 0; i < MSF2_NUM_UARTS; i++) {\n>> +        if (serial_hds[i]) {\n>> +            serial_mm_init(get_system_memory(), uart_addr[i], 2,\n>> +                           qdev_get_gpio_in(armv7m, uart_irq[i]),\n>> +                           115200, serial_hds[i], DEVICE_NATIVE_ENDIAN);\n>> +        }\n>> +    }\n>> +\n>> +    dev = DEVICE(&s->timer);\n>> +    /* APB0 clock is the timer input clock */\n>> +    qdev_prop_set_uint32(dev, \"clock-frequency\", s->m3clk / s->apb0div);\n>> +    object_property_set_bool(OBJECT(&s->timer), true, \"realized\", &err);\n>> +    if (err != NULL) {\n>> +        error_propagate(errp, err);\n>> +        return;\n>> +    }\n>> +    busdev = SYS_BUS_DEVICE(dev);\n>> +    sysbus_mmio_map(busdev, 0, MSF2_TIMER_BASE);\n>> +    sysbus_connect_irq(busdev, 0,\n>> +                           qdev_get_gpio_in(armv7m, timer_irq[0]));\n>> +    sysbus_connect_irq(busdev, 1,\n>> +                           qdev_get_gpio_in(armv7m, timer_irq[1]));\n>> +\n>> +    dev = DEVICE(&s->sysreg);\n>> +    qdev_prop_set_uint32(dev, \"apb0divisor\", s->apb0div);\n>> +    qdev_prop_set_uint32(dev, \"apb1divisor\", s->apb1div);\n>> +    object_property_set_bool(OBJECT(&s->sysreg), true, \"realized\",\n>> &err);\n>> +    if (err != NULL) {\n>> +        error_propagate(errp, err);\n>> +        return;\n>> +    }\n>> +    busdev = SYS_BUS_DEVICE(dev);\n>> +    sysbus_mmio_map(busdev, 0, MSF2_SYSREG_BASE);\n>> +\n>> +    for (i = 0; i < MSF2_NUM_SPIS; i++) {\n>> +        gchar *bus_name;\n>> +\n>> +        object_property_set_bool(OBJECT(&s->spi[i]), true, \"realized\",\n>> &err);\n>> +        if (err != NULL) {\n>> +            error_propagate(errp, err);\n>> +            return;\n>> +        }\n>> +\n>> +        sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, spi_addr[i]);\n>> +        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,\n>> +                           qdev_get_gpio_in(armv7m, spi_irq[i]));\n>> +\n>> +        /* Alias controller SPI bus to the SoC itself */\n>> +        bus_name = g_strdup_printf(\"spi%d\", i);\n>> +        object_property_add_alias(OBJECT(s), bus_name,\n>> +                                  OBJECT(&s->spi[i]), \"spi\",\n>> +                                  &error_abort);\n>> +        g_free(bus_name);\n>> +    }\n>> +\n>> +    /* Below devices are not modelled yet. */\n>> +    create_unimplemented_device(\"i2c_0\", 0x40002000, 0x1000);\n>> +    create_unimplemented_device(\"pdma\", 0x40003000, 0x1000);\n>>\n>\n> name it \"dma\" only.\n\n\nJust named so that it matches documentation. No strong feelings regd. names.\nI will change to dma and hs-dma .\n\n>\n>\n> +    create_unimplemented_device(\"watchdog\", 0x40005000, 0x1000);\n>> +    create_unimplemented_device(\"i2c_1\", 0x40012000, 0x1000);\n>> +    create_unimplemented_device(\"gpio\", 0x40013000, 0x1000);\n>> +    create_unimplemented_device(\"hpdma\", 0x40014000, 0x1000);\n>>\n>\n> \"hs-dma\" ?\n\n\nOk\n\n>\n>\n> +    create_unimplemented_device(\"can\", 0x40015000, 0x1000);\n>> +    create_unimplemented_device(\"rtc\", 0x40017000, 0x1000);\n>> +    create_unimplemented_device(\"apb_config\", 0x40020000, 0x10000);\n>>\n>\n> hmm ok.\n>\n> +    create_unimplemented_device(\"emac\", 0x40041000, 0x1000);\n>> +    create_unimplemented_device(\"usb\", 0x40043000, 0x1000);\n>> +}\n>>\n>\n> now the cpu memory tree looks:\n>\n> (qemu) info mtree\n> address-space: cpu-memory\n>   0000000000000000-ffffffffffffffff (prio 0, i/o): armv7m-container\n>     0000000000000000-ffffffffffffffff (prio -1, i/o): system\n>       0000000000000000-000000000003ffff (prio 0, i/o): alias MSF2.eNVM\n> @MSF2.eNVM 0000000000000000-000000000003ffff\n>       0000000020000000-000000002000ffff (prio 0, ram): MSF2.eSRAM\n>       0000000040000000-000000004000001f (prio 0, i/o): serial\n>       0000000040001000-000000004000103f (prio 0, i/o): mss-spi\n>       0000000040002000-0000000040002fff (prio -1000, i/o): i2c_0\n>       0000000040003000-0000000040003fff (prio -1000, i/o): pdma\n>       0000000040004000-000000004000402f (prio 0, i/o): mss-timer\n>       0000000040005000-0000000040005fff (prio -1000, i/o): watchdog\n>       0000000040011000-000000004001103f (prio 0, i/o): mss-spi\n>       0000000040012000-0000000040012fff (prio -1000, i/o): i2c_1\n>       0000000040013000-0000000040013fff (prio -1000, i/o): gpio\n>       0000000040014000-0000000040014fff (prio -1000, i/o): hpdma\n>       0000000040015000-0000000040015fff (prio -1000, i/o): can\n>       0000000040017000-0000000040017fff (prio -1000, i/o): rtc\n>       0000000040020000-000000004002ffff (prio -1000, i/o): apb_config\n>       0000000040038000-00000000400382ff (prio 0, i/o): msf2-sysreg\n>       0000000040041000-0000000040041fff (prio -1000, i/o): emac\n>       0000000040043000-0000000040043fff (prio -1000, i/o): usb\n>       0000000060000000-000000006003ffff (prio 0, rom): MSF2.eNVM\n>       00000000a0000000-00000000a3ffffff (prio 0, ram): ddr-ram\n>     0000000022000000-0000000023ffffff (prio 0, i/o): bitband\n>     0000000042000000-0000000043ffffff (prio 0, i/o): bitband\n>     00000000e000e000-00000000e000efff (prio 0, i/o): nvic\n>       00000000e000e000-00000000e000efff (prio 0, i/o): nvic_sysregs\n>       00000000e000e010-00000000e000e0ef (prio 1, i/o): systick\n>\n> +\n>> +static Property m2sxxx_soc_properties[] = {\n>> +    /*\n>> +     * part name specifies the type of SmartFusion2 device variant(this\n>> +     * property is for information purpose only.\n>> +     */\n>> +    DEFINE_PROP_STRING(\"part-name\", MSF2State, part_name),\n>> +    DEFINE_PROP_UINT64(\"eNVM-size\", MSF2State, envm_size,\n>> MSF2_ENVM_MAX_SIZE),\n>> +    DEFINE_PROP_UINT64(\"eSRAM-size\", MSF2State, esram_size,\n>> +                        MSF2_ESRAM_MAX_SIZE),\n>> +    /* Libero GUI shows 100Mhz as default for clocks */\n>> +    DEFINE_PROP_UINT32(\"m3clk\", MSF2State, m3clk, 100 * 1000000),\n>> +    /* default divisors in Libero GUI */\n>> +    DEFINE_PROP_UINT32(\"apb0div\", MSF2State, apb0div, 2),\n>> +    DEFINE_PROP_UINT32(\"apb1div\", MSF2State, apb1div, 2),\n>>\n>\n> DEFINE_PROP_UINT8 ?\n>\n>\n> Ok\n\n\n> +    DEFINE_PROP_END_OF_LIST(),\n>> +};\n>> +\n>> +static void m2sxxx_soc_class_init(ObjectClass *klass, void *data)\n>> +{\n>> +    DeviceClass *dc = DEVICE_CLASS(klass);\n>> +\n>> +    dc->realize = m2sxxx_soc_realize;\n>> +    dc->props = m2sxxx_soc_properties;\n>> +}\n>> +\n>> +static const TypeInfo m2sxxx_soc_info = {\n>> +    .name          = TYPE_MSF2_SOC,\n>> +    .parent        = TYPE_SYS_BUS_DEVICE,\n>> +    .instance_size = sizeof(MSF2State),\n>> +    .instance_init = m2sxxx_soc_initfn,\n>> +    .class_init    = m2sxxx_soc_class_init,\n>> +};\n>> +\n>> +static void m2sxxx_soc_types(void)\n>> +{\n>> +    type_register_static(&m2sxxx_soc_info);\n>> +}\n>> +\n>> +type_init(m2sxxx_soc_types)\n>> diff --git a/include/hw/arm/msf2-soc.h b/include/hw/arm/msf2-soc.h\n>> new file mode 100644\n>> index 0000000..eb239fa\n>> --- /dev/null\n>> +++ b/include/hw/arm/msf2-soc.h\n>> @@ -0,0 +1,66 @@\n>> +/*\n>> + * Microsemi Smartfusion2 SoC\n>> + *\n>> + * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com>\n>> + *\n>> + * Permission is hereby granted, free of charge, to any person obtaining\n>> a copy\n>> + * of this software and associated documentation files (the \"Software\"),\n>> to deal\n>> + * in the Software without restriction, including without limitation the\n>> rights\n>> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or\n>> 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\n>> included in\n>> + * all copies or substantial portions of the Software.\n>> + *\n>> + * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n>> EXPRESS OR\n>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n>> MERCHANTABILITY,\n>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT\n>> SHALL\n>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n>> OTHER\n>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\n>> ARISING FROM,\n>> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n>> DEALINGS IN\n>> + * THE SOFTWARE.\n>> + */\n>> +\n>> +#ifndef HW_ARM_MSF2_SOC_H\n>> +#define HW_ARM_MSF2_SOC_H\n>> +\n>> +#include \"hw/arm/armv7m.h\"\n>> +#include \"hw/timer/mss-timer.h\"\n>> +#include \"hw/misc/msf2-sysreg.h\"\n>> +#include \"hw/ssi/mss-spi.h\"\n>> +\n>> +#define TYPE_MSF2_SOC     \"msf2-soc\"\n>> +#define MSF2_SOC(obj)     OBJECT_CHECK(MSF2State, (obj), TYPE_MSF2_SOC)\n>> +\n>> +#define MSF2_NUM_SPIS         2\n>> +#define MSF2_NUM_UARTS        2\n>> +\n>> +/*\n>> + * System timer consists of two programmable 32-bit\n>> + * decrementing counters that generate individual interrupts to\n>> + * the Cortex-M3 processor\n>> + */\n>> +#define MSF2_NUM_TIMERS       2\n>> +\n>> +typedef struct MSF2State {\n>> +    /*< private >*/\n>> +    SysBusDevice parent_obj;\n>> +    /*< public >*/\n>> +\n>> +    ARMv7MState armv7m;\n>> +\n>> +    char *part_name;\n>> +    uint64_t envm_size;\n>> +    uint64_t esram_size;\n>> +\n>> +    uint32_t m3clk;\n>> +    uint32_t apb0div;\n>> +    uint32_t apb1div;\n>>\n>\n> uint8_t ?\n\n\nOk\n\n>\n>\n> +\n>> +    MSF2SysregState sysreg;\n>> +    MSSTimerState timer;\n>> +    MSSSpiState spi[MSF2_NUM_SPIS];\n>> +} MSF2State;\n>> +\n>> +#endif\n>>\n>>\n> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>\n> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>\n>\n\nThank you,\nSundeep","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=\"icD/CejM\"; 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 3xwh7Y2LKfz9s06\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 19:50:01 +1000 (AEST)","from localhost ([::1]:35488 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 1dtsgh-00034b-81\n\tfor incoming@patchwork.ozlabs.org; Mon, 18 Sep 2017 05:49:59 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:33802)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <sundeep.lkml@gmail.com>) id 1dtsgG-00034A-G6\n\tfor qemu-devel@nongnu.org; Mon, 18 Sep 2017 05:49:37 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <sundeep.lkml@gmail.com>) id 1dtsgC-0008AL-RD\n\tfor qemu-devel@nongnu.org; Mon, 18 Sep 2017 05:49:32 -0400","from mail-vk0-x234.google.com ([2607:f8b0:400c:c05::234]:45735)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <sundeep.lkml@gmail.com>)\n\tid 1dtsgC-0008AB-Jo; Mon, 18 Sep 2017 05:49:28 -0400","by mail-vk0-x234.google.com with SMTP id w23so3419089vkw.2;\n\tMon, 18 Sep 2017 02:49:28 -0700 (PDT)","by 10.176.66.68 with HTTP; Mon, 18 Sep 2017 02:49:27 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=32eOL52Y60PAmDt90Sm5/RmizKXuevw9T4pyw3iA2zQ=;\n\tb=icD/CejMA2cBRmKY6Fm+w+IWBexppDVNnygRR4UnsBoYjAVsivFrl1dH86Sztn4EGj\n\tBRH5AzBhOC5apUo0bXiq0O7UTIjhz8o2D8PjHqYwkDpZN5LaEctWoHL9AalBS42ENbIl\n\tFI7NQjgugQQ3dK+XxybxuF7amakuHhOfWlx4+CNB2ERqkN26r6DNYcOFt/9sZgaeyC/T\n\tpYeF7WlDHNsQxmcuqtmqbCa9PjO5gYOJ5Y7Uz7Zew6EXf+X/6wIiXw8bLwkbs3zRXKK9\n\tgUUCI3I96ZQEuFVuVSXjqCpFFomF7rUXjPxbsZb5y+Xni9CV3JoP0q93om/12gnFeUB8\n\tdcZA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=32eOL52Y60PAmDt90Sm5/RmizKXuevw9T4pyw3iA2zQ=;\n\tb=D9GKvP66+QRbvZYQd7nldfSU4WpJAG4m5pPAeE0kQLu4AypzAq5yk7F5KNEU7UFL/6\n\t8qv0O9Kev7yX8/H6e13r2G+aIOq5tJnuYmaduMK2Myj9qa/Oiv0ECAM1r1+6mbhyBmr2\n\tlDZso0/cmLyInyElIj9X5rDOZ3PoI5q9uSA8Ph7WfGUY4508fJRs0iywbybaugSXcyA0\n\tsQOUGU2z/XqiXhRa1ndB+7K1Wykj5mLKGAkwTkRJwmfM/m1TLRNT/Rd/xMzo7nI3eXSr\n\t4PoFpEhppBoKiBq6B6+pg6A+GksxsspiW2SQLVbtdqi5shij2LTLGqKGRxaSNsIm2Mmj\n\t+CeQ==","X-Gm-Message-State":"AHPjjUjm4dPH7tQXAQ7yx++Kzy0rhINeW6CTz1hbNxDkb7+HSW4ab/x4\n\tRf6Ulac0iZrJuZ6AmWGrjxb8AS2jmrQtyBGa/60=","X-Google-Smtp-Source":"AOwi7QD/4w+5iRg6mg2ByYb7vMmxJGAJW5D3XtrDckMnHrELHTvd4MwMfD/0M+Ofu3hGxIbmL20LMStI5i82WBHpbJk=","X-Received":"by 10.31.60.203 with SMTP id j194mr22327878vka.134.1505728167479;\n\tMon, 18 Sep 2017 02:49:27 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<9d3d6ffd-bf3b-8102-8a08-beee28656a54@amsat.org>","References":"<1505494753-10837-1-git-send-email-sundeep.lkml@gmail.com>\n\t<1505494753-10837-5-git-send-email-sundeep.lkml@gmail.com>\n\t<9d3d6ffd-bf3b-8102-8a08-beee28656a54@amsat.org>","From":"sundeep subbaraya <sundeep.lkml@gmail.com>","Date":"Mon, 18 Sep 2017 15:19:27 +0530","Message-ID":"<CALHRZurrbATjkAbBc-RJBH-+nX8jA4WcV2tqS+CNw8VaKEEkjQ@mail.gmail.com>","To":"=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <f4bug@amsat.org>","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2607:f8b0:400c:c05::234","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [Qemu devel v9 PATCH 4/5] msf2: Add Smartfusion2\n\tSoC","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>","Cc":"Peter Maydell <peter.maydell@linaro.org>, qemu-arm <qemu-arm@nongnu.org>,\n\tQEMU Developers <qemu-devel@nongnu.org>,\n\tAlistair Francis <alistair23@gmail.com>,\n\tPeter Crosthwaite <crosthwaite.peter@gmail.com>","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>"}}]