Received: by 2002:ac2:5042:0:0:0:0:0 with SMTP id a2csp1204263lfm; Tue, 7 Jul 2020 11:53:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlpQIWwMIHLu73gIEQb7rd7Vc4XYjLXxCgdMee0aQIQeNz+6X15kuBmAA2DcI1nQVEEKA4 X-Received: by 2002:a25:ce8a:: with SMTP id x132mr32135132ybe.423.1594148012232; Tue, 07 Jul 2020 11:53:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594148012; cv=none; d=google.com; s=arc-20160816; b=HmDVBSXOzPPHsLQ12pEwNKuw05ddSw18OvUYRPGjgxtfJ4VMR9WOHTdp1rjYhlXaB1 kluNUwPZYxNxt28YV1FfhR4v5UXSFLADKI0G51QWympyp557Uuwz05NrDx0KRSAHEJyn 68u44yQ0ho3L4BhxRaJCN4priXbLRnVQA3XaF0tlfLoctfVMbBwEA1KnYX7U7TZL0Qx/ PiLKGWIHwPiE8SybJyNkvCVMUzzI6yKzkTi1T+p9hstqeJMrGCsnq28yDbe84R5x8Atc p3+nXUFiVFyzws92VMDBdagnYeYgVYoI8ae0DEWV72MTfkRcUWeUEaI4anKnAJoGrAaN phwA== 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:content-transfer-encoding:cc:to :from:subject:references:mime-version:message-id:in-reply-to:date :dkim-signature; bh=UbC22jahfl+w2uRvEhSFpeDwZfsnpqdU4TMex24g6uU=; b=o18ADS9/cJ3yjn2tv/vFrY+UYvtLpdFlzCVniJk91/bk2WhuF4z38K6e9ChIciDM1W 62gari1soZFw4L1ut+TDsVweEakJwIuKwEMf5FC3VeZVV1NotRg83wQ1HFYZUZg9ts1N BZcBgCuLn+oUVmHO3mfGB4uU6QfnwW+itM7A1S70H1Xv/5JVDksyQgKowgyB3rScSwoh 6Jzpxu5NXJkYdHO0Qj19qHKOY+T9w4VlSS8adJZKgXXluFTkClN+tsOvcsT/jLrEMIm1 YkVCbSFs0TvaaSsxZ8zx3dbda2vjj5QcT8VSsWaSVR/CW8bjkCxEEfgrNk0bs2adndf4 VShA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WzyaXhHy; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b140si8065002ybg.287.2020.07.07.11.53.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jul 2020 11:53:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WzyaXhHy; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from localhost ([::1]:53566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jssih-0002Dt-JZ for alex.bennee@linaro.org; Tue, 07 Jul 2020 14:53:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3WsMEXwsKCPEaldbggXfhXgZhhZeX.VhfjXfn-TkfghgZgn.hkZ@flex--hskinnemoen.bounces.google.com>) id 1jssdK-0000Xt-MR for qemu-arm@nongnu.org; Tue, 07 Jul 2020 14:47:58 -0400 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]:37013) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3WsMEXwsKCPEaldbggXfhXgZhhZeX.VhfjXfn-TkfghgZgn.hkZ@flex--hskinnemoen.bounces.google.com>) id 1jssdI-0007bb-29 for qemu-arm@nongnu.org; Tue, 07 Jul 2020 14:47:58 -0400 Received: by mail-yb1-xb4a.google.com with SMTP id y3so48686214ybf.4 for ; Tue, 07 Jul 2020 11:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=UbC22jahfl+w2uRvEhSFpeDwZfsnpqdU4TMex24g6uU=; b=WzyaXhHy679UIcGYn3w63fKuiuHTp91yg7ugQeY9e/dSc86KSTqypUFG9Sd+qQTm1w 7pMomgbPwDIReol37U3/rPLGCBs4h1HwOVq9FFwzgPsz1AqyUpx8ylT61ZwltJQ9B+w8 IQxhSmRYz5mApwRw9SS8gBjh8y0MsDa2UfEj4PqLmobyJwxCA822OUExhCa5DU4EjTjy foOMyxAeaWILK4h8x+TZWEIqMOZTAPaJk1DrYUG78f5k2YIBIgxkTkaI20xnFWON+1Df Va9khUM49l9OoxpmvzGmyj1zWWTc4FymWSflkuprvkYFBB7EQCWGGnD+SFRwG/mbWhUX oQEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=UbC22jahfl+w2uRvEhSFpeDwZfsnpqdU4TMex24g6uU=; b=j0wSe5DZ255cXcDNlOpxGI2sisyIZG+pimvBy/sHOS48ofYYxvZXseZjM9r/J958lZ d0sOvslfh/8lmlEnOYUZktfOK2qN8qOYQTAUSwh8ksEBhqwqt4R+77SyaDASa7PQ1NPG ONfJEMDKU40QyoWTEHoOu0FBRS+sA+Kdy8sFNnItW+d9eQyJx++e99i7IC1qYeiM9FTk jF87+x7U0wTJ2qlgt4yjow9mJOVDfnYyIJLZJRO4qJP3uVI9cozOhvaHsB3DX8SCKUaN u69AOgvawLWDN1lvag4ZtYWj09JIirrggKz7Z2Doyc6UP6Yd+QMNcNlQH3aGV1FDOrZ5 gH1w== X-Gm-Message-State: AOAM530MZACEuNIU910xepmg2Ex8hFUVnQ8pvNyunb+A4S/urIz2bxvb Z25Zhot0QGcwCTfaDagqnT/wSy1GL5fYADThdQ== X-Received: by 2002:a05:6902:1002:: with SMTP id w2mr43447327ybt.321.1594147674664; Tue, 07 Jul 2020 11:47:54 -0700 (PDT) Date: Tue, 7 Jul 2020 11:47:27 -0700 In-Reply-To: <20200707184730.3047754-1-hskinnemoen@google.com> Message-Id: <20200707184730.3047754-10-hskinnemoen@google.com> Mime-Version: 1.0 References: <20200707184730.3047754-1-hskinnemoen@google.com> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog Subject: [PATCH v4 09/12] hw/mem: Stubbed out NPCM7xx Memory Controller model From: Havard Skinnemoen To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, philmd@redhat.com, Havard Skinnemoen , "=?UTF-8?q?C=C3=A9dric=20Le=20Goater?=" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::b4a; envelope-from=3WsMEXwsKCPEaldbggXfhXgZhhZeX.VhfjXfn-TkfghgZgn.hkZ@flex--hskinnemoen.bounces.google.com; helo=mail-yb1-xb4a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -105 X-Spam_score: -10.6 X-Spam_bar: ---------- X-Spam_report: (-10.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: ioIx9fC3Y/2w This just implements the bare minimum to cause the boot block to skip memory initialization. Reviewed-by: Tyrone Ting Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Havard Skinnemoen --- hw/arm/npcm7xx.c | 10 +++++ hw/mem/Makefile.objs | 1 + hw/mem/npcm7xx_mc.c | 84 +++++++++++++++++++++++++++++++++++++ include/hw/arm/npcm7xx.h | 2 + include/hw/mem/npcm7xx_mc.h | 36 ++++++++++++++++ 5 files changed, 133 insertions(+) create mode 100644 hw/mem/npcm7xx_mc.c create mode 100644 include/hw/mem/npcm7xx_mc.h diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c index 71cc141f3c..5e6d05642e 100644 --- a/hw/arm/npcm7xx.c +++ b/hw/arm/npcm7xx.c @@ -46,6 +46,7 @@ #define NPCM7XX_CPUP_BA (0xF03FE000) #define NPCM7XX_GCR_BA (0xF0800000) #define NPCM7XX_CLK_BA (0xF0801000) +#define NPCM7XX_MC_BA (0xF0824000) =20 /* Memory blocks at the end of the address space */ #define NPCM7XX_RAM2_BA (0xFFFD0000) @@ -160,6 +161,7 @@ static void npcm7xx_init(Object *obj) TYPE_NPCM7XX_KEY_STORAGE); object_initialize_child(obj, "otp2", &s->fuse_array, TYPE_NPCM7XX_FUSE_ARRAY); + object_initialize_child(obj, "mc", &s->mc, TYPE_NPCM7XX_MC); =20 for (i =3D 0; i < ARRAY_SIZE(s->tim); i++) { object_initialize_child(obj, "tim[*]", &s->tim[i], TYPE_NPCM7XX_TI= MER); @@ -255,6 +257,14 @@ static void npcm7xx_realize(DeviceState *dev, Error **= errp) sysbus_mmio_map(SYS_BUS_DEVICE(&s->fuse_array), 0, NPCM7XX_OTP2_BA); npcm7xx_init_fuses(s); =20 + /* Fake Memory Controller (MC) */ + sysbus_realize(SYS_BUS_DEVICE(&s->mc), &err); + if (err) { + error_propagate(errp, err); + return; + } + sysbus_mmio_map(SYS_BUS_DEVICE(&s->mc), 0, NPCM7XX_MC_BA); + /* Timer Modules (TIM) */ QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_tim_addr) !=3D ARRAY_SIZE(s->tim)= ); for (i =3D 0; i < ARRAY_SIZE(s->tim); i++) { diff --git a/hw/mem/Makefile.objs b/hw/mem/Makefile.objs index 56345befd0..9a33ef7b35 100644 --- a/hw/mem/Makefile.objs +++ b/hw/mem/Makefile.objs @@ -1,3 +1,4 @@ common-obj-$(CONFIG_DIMM) +=3D pc-dimm.o common-obj-y +=3D memory-device.o +common-obj-$(CONFIG_NPCM7XX) +=3D npcm7xx_mc.o common-obj-$(CONFIG_NVDIMM) +=3D nvdimm.o diff --git a/hw/mem/npcm7xx_mc.c b/hw/mem/npcm7xx_mc.c new file mode 100644 index 0000000000..0435d06ab4 --- /dev/null +++ b/hw/mem/npcm7xx_mc.c @@ -0,0 +1,84 @@ +/* + * Nuvoton NPCM7xx Memory Controller stub + * + * Copyright 2020 Google LLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WIT= HOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "qemu/osdep.h" + +#include "hw/mem/npcm7xx_mc.h" +#include "qapi/error.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qemu/units.h" + +#define NPCM7XX_MC_REGS_SIZE (4 * KiB) + +static uint64_t npcm7xx_mc_read(void *opaque, hwaddr addr, unsigned int si= ze) +{ + /* + * If bits 8..11 @ offset 0 are not zero, the boot block thinks the me= mory + * controller has already been initialized and will skip DDR training. + */ + if (addr =3D=3D 0) { + return 0x100; + } + + qemu_log_mask(LOG_UNIMP, "%s: mostly unimplemented\n", __func__); + + return 0; +} + +static void npcm7xx_mc_write(void *opaque, hwaddr addr, uint64_t v, + unsigned int size) +{ + qemu_log_mask(LOG_UNIMP, "%s: mostly unimplemented\n", __func__); +} + +static const MemoryRegionOps npcm7xx_mc_ops =3D { + .read =3D npcm7xx_mc_read, + .write =3D npcm7xx_mc_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + .unaligned =3D false, + }, +}; + +static void npcm7xx_mc_realize(DeviceState *dev, Error **errp) +{ + NPCM7xxMCState *s =3D NPCM7XX_MC(dev); + + memory_region_init_io(&s->mmio, OBJECT(s), &npcm7xx_mc_ops, s, "regs", + NPCM7XX_MC_REGS_SIZE); + sysbus_init_mmio(&s->parent, &s->mmio); +} + +static void npcm7xx_mc_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->desc =3D "NPCM7xx Memory Controller stub"; + dc->realize =3D npcm7xx_mc_realize; +} + +static const TypeInfo npcm7xx_mc_types[] =3D { + { + .name =3D TYPE_NPCM7XX_MC, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(NPCM7xxMCState), + .class_init =3D npcm7xx_mc_class_init, + }, +}; +DEFINE_TYPES(npcm7xx_mc_types); diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h index 2f2d44aad7..a6c1d4082b 100644 --- a/include/hw/arm/npcm7xx.h +++ b/include/hw/arm/npcm7xx.h @@ -18,6 +18,7 @@ =20 #include "hw/boards.h" #include "hw/cpu/a9mpcore.h" +#include "hw/mem/npcm7xx_mc.h" #include "hw/misc/npcm7xx_clk.h" #include "hw/misc/npcm7xx_gcr.h" #include "hw/nvram/npcm7xx_otp.h" @@ -66,6 +67,7 @@ typedef struct NPCM7xxState { NPCM7xxTimerCtrlState tim[3]; NPCM7xxOTPState key_storage; NPCM7xxOTPState fuse_array; + NPCM7xxMCState mc; } NPCM7xxState; =20 #define TYPE_NPCM7XX "npcm7xx" diff --git a/include/hw/mem/npcm7xx_mc.h b/include/hw/mem/npcm7xx_mc.h new file mode 100644 index 0000000000..7ed38be243 --- /dev/null +++ b/include/hw/mem/npcm7xx_mc.h @@ -0,0 +1,36 @@ +/* + * Nuvoton NPCM7xx Memory Controller stub + * + * Copyright 2020 Google LLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WIT= HOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ +#ifndef NPCM7XX_MC_H +#define NPCM7XX_MC_H + +#include "exec/memory.h" +#include "hw/sysbus.h" + +/** + * struct NPCM7xxMCState - Device state for the memory controller. + * @parent: System bus device. + * @mmio: Memory region through which registers are accessed. + */ +typedef struct NPCM7xxMCState { + SysBusDevice parent; + + MemoryRegion mmio; +} NPCM7xxMCState; + +#define TYPE_NPCM7XX_MC "npcm7xx-mc" +#define NPCM7XX_MC(obj) OBJECT_CHECK(NPCM7xxMCState, (obj), TYPE_NPCM7XX_M= C) + +#endif /* NPCM7XX_MC_H */ --=20 2.27.0.212.ge8ba1cc988-goog