Received: by 2002:a19:c345:0:0:0:0:0 with SMTP id t66csp24323062lff; Mon, 6 Jan 2020 23:42:05 -0800 (PST) X-Google-Smtp-Source: APXvYqyPGG8pycBB3g7d5YCdMA+GyuaTmECoE0AthY8bRgjTiE3KZYlpmw6CqMLkpRTN8jP/03Dc X-Received: by 2002:a17:906:a950:: with SMTP id hh16mr111780798ejb.75.1578382925814; Mon, 06 Jan 2020 23:42:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578382925; cv=none; d=google.com; s=arc-20160816; b=CRwuMRNt+62LjYKK/OUDfFWEx+IcZ9oRx3KxLs9TjxSBgY05cBx3d9NnO/L8YWoPxq aC0SWzUwdQNnrLFR7bc3xlTi/SciYZRWnlThs94H97gyTqKxaD87tWC7n0Awy/Iz7lwI Vlb89jaZU0SmxnlGV8N3l5NGW7y2ekic9QOAIv68af95ISaeIUVqSiD3uEa+VW2lTF2a uFNln4dTa3Q4gzQVdoAvEsOTzALdMuIqL5jC676TGSPrnNyugRchnDrU6+osBA6F3k7l TRXTN44liyrODUyGzImZ/JrnXnbyqSBFlgvVO/rhl1sekcbK1Quj9GXYwrL05pTWjIjg 99qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from; bh=6fmgW6Vbab8JgdbAI2xhinQ46e73/1BJse4EvKiGtuo=; b=i097YvyBLIk1Lm1GSaUt/MZOLtxj59pOoSEpt9yndrx+ua9kxPKZxhMRWagXsEMCuP GsN2l8I1uxTt3tqF9npszFBTOz3hxd/qkJGuWJqkgB7t5YEBxBiAp7yu6AMRgqlRGnq4 lxLVsLi6GfdxfE6Wc0W3EjK7RTjaabz5ua7u6Nph8sK9bCEKcZey0t+KlsaPlRjioSXy scoy6FmMxxQKwZQr9vShUMXTBVPNIsqsGH7ju5MkSAN/940vFge0BLFt1Le8ZFsBhrOX IWqDCSeiw36ff1W2S7yzhgYP216lNH1SpXETLxAocc6JzLHp3RVKdVNvZOb/Uj0CJG0U YWOw== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t3si46226275ejd.319.2020.01.06.23.42.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Jan 2020 23:42:05 -0800 (PST) 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; 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" Received: from localhost ([::1]:44074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojUk-0000S4-6e for alex.bennee@linaro.org; Tue, 07 Jan 2020 02:41:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51402) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojO7-0002Mz-69 for qemu-arm@nongnu.org; Tue, 07 Jan 2020 02:34:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojO5-0006mc-OK for qemu-arm@nongnu.org; Tue, 07 Jan 2020 02:34:50 -0500 Received: from 11.mo5.mail-out.ovh.net ([46.105.47.167]:51507) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iojO5-0006lo-FB for qemu-arm@nongnu.org; Tue, 07 Jan 2020 02:34:49 -0500 Received: from player755.ha.ovh.net (unknown [10.109.143.183]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id DFBA026587D for ; Tue, 7 Jan 2020 08:34:47 +0100 (CET) Received: from kaod.org (lfbn-tou-1-1227-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player755.ha.ovh.net (Postfix) with ESMTPSA id 28096DFE0CA4; Tue, 7 Jan 2020 07:34:41 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: Peter Maydell Subject: [PATCH 2/5] hw/arm: ast2600: Wire up the eMMC controller Date: Tue, 7 Jan 2020 08:34:20 +0100 Message-Id: <20200107073423.30043-3-clg@kaod.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200107073423.30043-1-clg@kaod.org> References: <20200107073423.30043-1-clg@kaod.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Ovh-Tracer-Id: 3789497615109032721 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrvdehuddguddtlecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpeevrogurhhitgcunfgvucfiohgrthgvrhcuoegtlhhgsehkrghougdrohhrgheqnecukfhppedtrddtrddtrddtpdeltddrjeeirdehtddrvddvfeenucfrrghrrghmpehmohguvgepshhmthhpqdhouhhtpdhhvghlohepphhlrgihvghrjeehhedrhhgrrdhovhhhrdhnvghtpdhinhgvtheptddrtddrtddrtddpmhgrihhlfhhrohhmpegtlhhgsehkrghougdrohhrghdprhgtphhtthhopehqvghmuhdqrghrmhesnhhonhhgnhhurdhorhhgnecuvehluhhsthgvrhfuihiivgeptd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.47.167 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: , Cc: Andrew Jeffery , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-arm@nongnu.org, Joel Stanley , qemu-devel@nongnu.org Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: zRJzcgnzujvZ From: Andrew Jeffery Initialise another SDHCI model instance for the AST2600's eMMC controller and use the SDHCI's num_slots value introduced previously to determine whether we should create an SD card instance for the new slot. Signed-off-by: Andrew Jeffery Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: C=C3=A9dric Le Goater --- include/hw/arm/aspeed_soc.h | 2 ++ hw/arm/aspeed.c | 25 ++++++++++++++++--------- hw/arm/aspeed_ast2600.c | 21 +++++++++++++++++++++ 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h index e84380984f7b..90ac7f7ffa3b 100644 --- a/include/hw/arm/aspeed_soc.h +++ b/include/hw/arm/aspeed_soc.h @@ -57,6 +57,7 @@ typedef struct AspeedSoCState { AspeedGPIOState gpio; AspeedGPIOState gpio_1_8v; AspeedSDHCIState sdhci; + AspeedSDHCIState emmc; } AspeedSoCState; =20 #define TYPE_ASPEED_SOC "aspeed-soc" @@ -126,6 +127,7 @@ enum { ASPEED_MII4, ASPEED_SDRAM, ASPEED_XDMA, + ASPEED_EMMC, }; =20 #endif /* ASPEED_SOC_H */ diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 4174e313cae5..0a7dfd29868b 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -171,6 +171,18 @@ static void aspeed_board_init_flashes(AspeedSMCState= *s, const char *flashtype, } } =20 +static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo) +{ + BlockBackend *blk; + DeviceState *card; + + blk =3D dinfo ? blk_by_legacy_dinfo(dinfo) : NULL; + card =3D qdev_create(qdev_get_child_bus(DEVICE(sdhci), "sd-bus")= , + TYPE_SD_CARD); + qdev_prop_set_drive(card, "drive", blk, &error_fatal); + object_property_set_bool(OBJECT(card), true, "realized", &error_= fatal); +} + static void aspeed_machine_init(MachineState *machine) { AspeedBoardState *bmc; @@ -264,16 +276,11 @@ static void aspeed_machine_init(MachineState *machi= ne) } =20 for (i =3D 0; i < bmc->soc.sdhci.num_slots; i++) { - SDHCIState *sdhci =3D &bmc->soc.sdhci.slots[i]; - DriveInfo *dinfo =3D drive_get_next(IF_SD); - BlockBackend *blk; - DeviceState *card; + sdhci_attach_drive(&bmc->soc.sdhci.slots[i], drive_get_next(IF_S= D)); + } =20 - blk =3D dinfo ? blk_by_legacy_dinfo(dinfo) : NULL; - card =3D qdev_create(qdev_get_child_bus(DEVICE(sdhci), "sd-bus")= , - TYPE_SD_CARD); - qdev_prop_set_drive(card, "drive", blk, &error_fatal); - object_property_set_bool(OBJECT(card), true, "realized", &error_= fatal); + if (bmc->soc.emmc.num_slots) { + sdhci_attach_drive(&bmc->soc.emmc.slots[0], drive_get_next(IF_SD= )); } =20 arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo); diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c index fb73c4043ea3..e59cdd291925 100644 --- a/hw/arm/aspeed_ast2600.c +++ b/hw/arm/aspeed_ast2600.c @@ -46,6 +46,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] =3D { [ASPEED_ADC] =3D 0x1E6E9000, [ASPEED_VIDEO] =3D 0x1E700000, [ASPEED_SDHCI] =3D 0x1E740000, + [ASPEED_EMMC] =3D 0x1E750000, [ASPEED_GPIO] =3D 0x1E780000, [ASPEED_GPIO_1_8V] =3D 0x1E780800, [ASPEED_RTC] =3D 0x1E781000, @@ -64,6 +65,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] =3D { =20 #define ASPEED_SOC_AST2600_MAX_IRQ 128 =20 +/* Shared Peripheral Interrupt values below are offset by -32 from datas= heet */ static const int aspeed_soc_ast2600_irqmap[] =3D { [ASPEED_UART1] =3D 47, [ASPEED_UART2] =3D 48, @@ -77,6 +79,7 @@ static const int aspeed_soc_ast2600_irqmap[] =3D { [ASPEED_ADC] =3D 78, [ASPEED_XDMA] =3D 6, [ASPEED_SDHCI] =3D 43, + [ASPEED_EMMC] =3D 15, [ASPEED_GPIO] =3D 40, [ASPEED_GPIO_1_8V] =3D 11, [ASPEED_RTC] =3D 13, @@ -206,6 +209,14 @@ static void aspeed_soc_ast2600_init(Object *obj) sysbus_init_child_obj(obj, "sdhci[*]", OBJECT(&s->sdhci.slots[i]= ), sizeof(s->sdhci.slots[i]), TYPE_SYSBUS_SDH= CI); } + + sysbus_init_child_obj(obj, "emmc", OBJECT(&s->emmc), sizeof(s->emmc)= , + TYPE_ASPEED_SDHCI); + + object_property_set_int(OBJECT(&s->emmc), 1, "num-slots", &error_abo= rt); + + sysbus_init_child_obj(obj, "emmc[*]", OBJECT(&s->emmc.slots[0]), + sizeof(s->emmc.slots[0]), TYPE_SYSBUS_SDHCI); } =20 /* @@ -497,6 +508,16 @@ static void aspeed_soc_ast2600_realize(DeviceState *= dev, Error **errp) sc->memmap[ASPEED_SDHCI]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0, aspeed_soc_get_irq(s, ASPEED_SDHCI)); + + /* eMMC */ + object_property_set_bool(OBJECT(&s->emmc), true, "realized", &err); + if (err) { + error_propagate(errp, err); + return; + } + sysbus_mmio_map(SYS_BUS_DEVICE(&s->emmc), 0, sc->memmap[ASPEED_EMMC]= ); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->emmc), 0, + aspeed_soc_get_irq(s, ASPEED_EMMC)); } =20 static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) --=20 2.21.1