From patchwork Fri Feb 1 16:06:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 157271 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp635828jaa; Fri, 1 Feb 2019 08:21:38 -0800 (PST) X-Google-Smtp-Source: AHgI3IbbQue52G+ivTCeLzPMf3A2eGalJPZ4QOJ0CJxnSfUlLb+q+Cz+e8UwX4ULFS0xFK+cfB2O X-Received: by 2002:a25:38a:: with SMTP id 132mr26170481ybd.426.1549038098060; Fri, 01 Feb 2019 08:21:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549038098; cv=none; d=google.com; s=arc-20160816; b=TSglM2qaYs9+n6on/ewZPTiRJk8EqjyWG0kXhFtwgFq6NL3e72Rpg/qyjKZOpN+eUV IU1r2zof2lAirISFX048y3Ydnct6/XoJtB+wrVOYutYMQf2YgEbVVTiBN27ibAYkGOPY TXnn+0ncQRgl5eja5yc+DRUdPz2ERqj6mSpNjDaSK2kOZLDeEI6+Mfcs20MHP4UCk+Ue noWKvrUPPrLEFH2s9e2vmiNnMVdTMsefhQjwaZRyVlBzAXT98EGNDeaqKFmVJUTKQR9+ +zBPDCe/vRDt6l7cmFLjgbYp/q8dbYbrRSr6miTBkTJvSdNgXIKItPgiMZXcgPLpiOlb h6og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=W7oLdNSaKSUjqwVpKHmmF4LmDbxYNOsBX5IaUXX+7uI=; b=AMbpPJgJc4EpHlE7R4f4M11M+SlOz1k8y/n0kEgoA0QT5VMxFOz8e/GhrtZ6kec35O RwM9G9t/EkrvzWu5+NYqGZp35k/hcF+BUWyayaLkXMctwtq00U/AsuwEMYzrVgzpKEEx yR+/6f7Nuw/nEq5CsnWS26QyPe81mCHNFuuLQyrQohRjz1vwNkP0knzzUAqOOVlqdHDn reMcgQ0N6GG/mq0VocCuSkv3Bk+dksBf6K2DM+g+FT/xotSeRwaMtUigxvWYB1qOByDq npWX18yOw7lfVIeJ40JJWKXtyh7FfV44TFpmHS2PTPirwXOgcTtKFw2BJwmpGhdoSDAh bQ0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=N1DnWinh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u40si5294913ywh.11.2019.02.01.08.21.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Feb 2019 08:21:38 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=N1DnWinh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:57413 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpbZR-0002KF-Ft for patch@linaro.org; Fri, 01 Feb 2019 11:21:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpbMI-0008Jv-K2 for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:08:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpbMB-0003ld-WC for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:08:02 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:35416) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gpbMB-0003iN-Lr for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:07:55 -0500 Received: by mail-wm1-x332.google.com with SMTP id t200so6823299wmt.0 for ; Fri, 01 Feb 2019 08:07:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=W7oLdNSaKSUjqwVpKHmmF4LmDbxYNOsBX5IaUXX+7uI=; b=N1DnWinhQcw0K83M04USH3LhBloTVqug3zvNo8QEHM3gjUO3d/NwoOQUQYbFgU9Iw4 Wy5ZuS6fVDeuSqsbLBddt48xUeeLYFBL7rllcOIdHDaB9FYnE5wBrdrZaQq3B8hvI/+v Bb8SykZ4XzI9eEER+WZUtEXIcXxIZ1Q+s/O0w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W7oLdNSaKSUjqwVpKHmmF4LmDbxYNOsBX5IaUXX+7uI=; b=ZMOVi/ciQcfgg8MPj79QHmDAKXx5YDtKxDbvV2wXoOa55K++JVOAyLScJXflrrwaJM 9enFoUICgF8E18lLJnzelSMc1w9Ejj1N9rcBKrZjRJYSeUz5glwLbuSEPw4hV+SKiyox +bquuQXDxCeV+9Ik9h9d1SXEhcPSln5/AHSA/+9RsZ2gmdkufA2t3lRlGkM2ZuJ/NYkZ eHlj4KMdF/rwEcTX7uBRlHxR7/wTlUkvYDqZEwJw++21vo7p/hsJIEsvs3GZ+nCrrljc pjDrBOcFeKKVHZhU3tVTIr87pnNE7PMZmBGXSeruj9VY4wcf2RjU5v8IAtbjN3jAtar7 W7+A== X-Gm-Message-State: AHQUAuZbM/NdDNn1pb1wJ9zniLxV+tvk+R7eMVmXt8ZBqW86xElG8+Gy dssk9zsQPdXhh5Pddx3FWpNa89gzU8SVBQ== X-Received: by 2002:a7b:cd85:: with SMTP id y5mr2950035wmj.129.1549037273642; Fri, 01 Feb 2019 08:07:53 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id n6sm2847250wmk.9.2019.02.01.08.07.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 08:07:52 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 1 Feb 2019 16:06:52 +0000 Message-Id: <20190201160653.13829-47-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201160653.13829-1-peter.maydell@linaro.org> References: <20190201160653.13829-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 Subject: [Qemu-devel] [PULL 46/47] arm: Instantiate NRF51 special NVM's and NVMC X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Steffen Görtz Instantiates UICR, FICR, FLASH and NVMC in nRF51 SOC. Signed-off-by: Steffen Görtz Reviewed-by: Peter Maydell Reviewed-by: Stefan Hajnoczi Signed-off-by: Stefan Hajnoczi Message-id: 20190201023357.22596-3-stefanha@redhat.com Signed-off-by: Peter Maydell --- include/hw/arm/nrf51_soc.h | 2 ++ hw/arm/nrf51_soc.c | 41 +++++++++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 12 deletions(-) -- 2.20.1 diff --git a/include/hw/arm/nrf51_soc.h b/include/hw/arm/nrf51_soc.h index fbdefc07e4d..fd7fcc71a56 100644 --- a/include/hw/arm/nrf51_soc.h +++ b/include/hw/arm/nrf51_soc.h @@ -15,6 +15,7 @@ #include "hw/char/nrf51_uart.h" #include "hw/misc/nrf51_rng.h" #include "hw/gpio/nrf51_gpio.h" +#include "hw/nvram/nrf51_nvm.h" #include "hw/timer/nrf51_timer.h" #define TYPE_NRF51_SOC "nrf51-soc" @@ -32,6 +33,7 @@ typedef struct NRF51State { NRF51UARTState uart; NRF51RNGState rng; + NRF51NVMState nvm; NRF51GPIOState gpio; NRF51TimerState timer[NRF51_NUM_TIMERS]; diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c index 3a1c7e200cc..bbaf050103a 100644 --- a/hw/arm/nrf51_soc.c +++ b/hw/arm/nrf51_soc.c @@ -29,8 +29,10 @@ * are supported in the future, add a sub-class of NRF51SoC for * the specific variants */ -#define NRF51822_FLASH_SIZE (256 * NRF51_PAGE_SIZE) -#define NRF51822_SRAM_SIZE (16 * NRF51_PAGE_SIZE) +#define NRF51822_FLASH_PAGES 256 +#define NRF51822_SRAM_PAGES 16 +#define NRF51822_FLASH_SIZE (NRF51822_FLASH_PAGES * NRF51_PAGE_SIZE) +#define NRF51822_SRAM_SIZE (NRF51822_SRAM_PAGES * NRF51_PAGE_SIZE) #define BASE_TO_IRQ(base) ((base >> 12) & 0x1F) @@ -81,14 +83,6 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -1); - memory_region_init_rom(&s->flash, OBJECT(s), "nrf51.flash", s->flash_size, - &err); - if (err) { - error_propagate(errp, err); - return; - } - memory_region_add_subregion(&s->container, NRF51_FLASH_BASE, &s->flash); - memory_region_init_ram(&s->sram, OBJECT(s), "nrf51.sram", s->sram_size, &err); if (err) { @@ -122,6 +116,29 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) qdev_get_gpio_in(DEVICE(&s->cpu), BASE_TO_IRQ(NRF51_RNG_BASE))); + /* UICR, FICR, NVMC, FLASH */ + object_property_set_uint(OBJECT(&s->nvm), s->flash_size, "flash-size", + &err); + if (err) { + error_propagate(errp, err); + return; + } + + object_property_set_bool(OBJECT(&s->nvm), true, "realized", &err); + if (err) { + error_propagate(errp, err); + return; + } + + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->nvm), 0); + memory_region_add_subregion_overlap(&s->container, NRF51_NVMC_BASE, mr, 0); + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->nvm), 1); + memory_region_add_subregion_overlap(&s->container, NRF51_FICR_BASE, mr, 0); + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->nvm), 2); + memory_region_add_subregion_overlap(&s->container, NRF51_UICR_BASE, mr, 0); + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->nvm), 3); + memory_region_add_subregion_overlap(&s->container, NRF51_FLASH_BASE, mr, 0); + /* GPIO */ object_property_set_bool(OBJECT(&s->gpio), true, "realized", &err); if (err) { @@ -159,8 +176,6 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) create_unimplemented_device("nrf51_soc.io", NRF51_IOMEM_BASE, NRF51_IOMEM_SIZE); - create_unimplemented_device("nrf51_soc.ficr", NRF51_FICR_BASE, - NRF51_FICR_SIZE); create_unimplemented_device("nrf51_soc.private", NRF51_PRIVATE_BASE, NRF51_PRIVATE_SIZE); } @@ -187,6 +202,8 @@ static void nrf51_soc_init(Object *obj) sysbus_init_child_obj(obj, "rng", &s->rng, sizeof(s->rng), TYPE_NRF51_RNG); + sysbus_init_child_obj(obj, "nvm", &s->nvm, sizeof(s->nvm), TYPE_NRF51_NVM); + sysbus_init_child_obj(obj, "gpio", &s->gpio, sizeof(s->gpio), TYPE_NRF51_GPIO);