From nobody Tue Nov 26 08:46:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709040888; cv=none; d=zohomail.com; s=zohoarc; b=FxSQn21YOs74VdxgTxMcGXDFCAG1OizV9jsiPkb9D1YdasUZdsRBpzD7OJ8gbPQ3dx0GdkA0krrC1PtWA8tC8ZWztgKgxO7Aed4ByYdmkxTKxsTq08HGuBjaJ2r9DfBIIHHcMTznwq6KzZNqQBrhKj+pfAcSbTFa4MSNU8lZ6Bc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709040888; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=ew4Z8LeQFT3auV97++3nsulAkoTYVN/ntWXGduMaWl4=; b=eE+lRfG2jK+CCtL0PQ3Onepdz23F3+xgOvIgpMqwUbflTmXW/yvUBkIut+JUap30JDpljIVnekJ8rJoSlSVHZTh3Dkg+Lx4UCzVZMJ5Wdfhxt/0Vt3dl1nDgx0NgS0iIk6Zq0ZXiaTaqLYK/bqzQac/SUiue4ZfG8eZXuEno/SY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170904088866241.79261649225475; Tue, 27 Feb 2024 05:34:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rexaK-0000jp-TI; Tue, 27 Feb 2024 08:33:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rexaG-0000i0-Lw for qemu-devel@nongnu.org; Tue, 27 Feb 2024 08:33:24 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rexaE-0002qt-Rk for qemu-devel@nongnu.org; Tue, 27 Feb 2024 08:33:24 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-412a14299a4so21618635e9.1 for ; Tue, 27 Feb 2024 05:33:22 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id i13-20020adfe48d000000b0033ae7d768b2sm11319552wrm.117.2024.02.27.05.33.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 05:33:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709040801; x=1709645601; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ew4Z8LeQFT3auV97++3nsulAkoTYVN/ntWXGduMaWl4=; b=EH1pFjcP/9FGu+H95v3rt24m4CqE5i6kKx2EtWpmt0fWGf2FNG+6eaWMwm/oklw5OM LWlSLe4Lf4PRF5HIjsdGzwFmQ1osH8z9a/OvcIzs1qbgBI3cLzbkyOLGQ+BJSuptwB0B HVOvFHhPkhSjDOJuRQ383RPMcisGyhfa00lVD2U1+7Q9272HiPiNYs+PAkGuHBZxmzIv +04RbIyeJtBv4XYKjLcN2wu+Wxng/rwFHskdlr90KykydbCvYAQpfLhEn+pKbcKJp0+p KC4pUwZjWXdH1CdCETstVqmsBDhihulEzgKfAgE3DXww2E1S5szDIfK76/aqWRqXyOJ4 GDew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709040801; x=1709645601; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ew4Z8LeQFT3auV97++3nsulAkoTYVN/ntWXGduMaWl4=; b=K5ZPdwQPyJpGiIyY6asBdhawMlf0AVyj5G91/2I2QP5BNDG7JcrG9K8SN82VLbXuFy 0f7wHhYw1LGUIv0MCYL6i7ktOqgT7sCU4F4Yl14fTc4xzWnCNKz06taGmDQOWF6IdDzU +SO47cbqevLCbEfvC+Ir8pSlOTqyydAJbqBPxmMBy9m2lPDig5KK9HlkoEQmuEF++HNc dq+FstCjprZjWEMRYl3Dg959+/C64NF8VjZQyUAS30QZzepKjXYTHxMsyoRj3Z1nFyix v6yJeCZ9YK+m223puYiP++bWM7fauOeD6i8WKyQPCJ8PiGaf1ID6P4EbSE03Wj7iePgb sCbg== X-Gm-Message-State: AOJu0YxfX/siyOiCP0uqIposmbRrlP+MR+HYrnONXXxb56kRZcJjqpiw hCpzdUPhAnI2mOqH9qCT7MMHxwCppWPYMx2EI9D2bjPYW37IFy4ZaDzfTetAUl4WedCtkFXZBFy X X-Google-Smtp-Source: AGHT+IFHjd9RclPt9TH8MuEB0wZSQw7rp72vUFDOX0AsB0fb2uE8aZDe1CKQv5mIGzvkCyuj/4r7fg== X-Received: by 2002:a05:6000:71b:b0:33d:c652:7c41 with SMTP id bs27-20020a056000071b00b0033dc6527c41mr7279561wrb.71.1709040801284; Tue, 27 Feb 2024 05:33:21 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/45] arm: xlnx-versal-virt: Add machine property ospi-flash Date: Tue, 27 Feb 2024 13:32:40 +0000 Message-Id: <20240227133314.1721857-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240227133314.1721857-1-peter.maydell@linaro.org> References: <20240227133314.1721857-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709040890728100003 Content-Type: text/plain; charset="utf-8" From: Sai Pavan Boddu This property allows users to change flash model on command line as below. ex: "-M xlnx-versal-virt,ospi-flash=3Dmt35xu02gbba" Signed-off-by: Sai Pavan Boddu Message-id: 20240220091721.82954-3-sai.pavan.boddu@amd.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/xlnx-versal-virt.c | 44 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c index 94942c55dff..bfaed1aebfc 100644 --- a/hw/arm/xlnx-versal-virt.c +++ b/hw/arm/xlnx-versal-virt.c @@ -49,6 +49,7 @@ struct VersalVirt { struct { bool secure; } cfg; + char *ospi_model; }; =20 static void fdt_create(VersalVirt *s) @@ -638,6 +639,22 @@ static void sd_plugin_card(SDHCIState *sd, DriveInfo *= di) &error_fatal); } =20 +static char *versal_get_ospi_model(Object *obj, Error **errp) +{ + VersalVirt *s =3D XLNX_VERSAL_VIRT_MACHINE(obj); + + return g_strdup(s->ospi_model); +} + +static void versal_set_ospi_model(Object *obj, const char *value, Error **= errp) +{ + VersalVirt *s =3D XLNX_VERSAL_VIRT_MACHINE(obj); + + g_free(s->ospi_model); + s->ospi_model =3D g_strdup(value); +} + + static void versal_virt_init(MachineState *machine) { VersalVirt *s =3D XLNX_VERSAL_VIRT_MACHINE(machine); @@ -732,12 +749,25 @@ static void versal_virt_init(MachineState *machine) for (i =3D 0; i < XLNX_VERSAL_NUM_OSPI_FLASH; i++) { BusState *spi_bus; DeviceState *flash_dev; + ObjectClass *flash_klass; qemu_irq cs_line; DriveInfo *dinfo =3D drive_get(IF_MTD, 0, i); =20 spi_bus =3D qdev_get_child_bus(DEVICE(&s->soc.pmc.iou.ospi), "spi0= "); =20 - flash_dev =3D qdev_new("mt35xu01g"); + if (s->ospi_model) { + flash_klass =3D object_class_by_name(s->ospi_model); + if (!flash_klass || + object_class_is_abstract(flash_klass) || + !object_class_dynamic_cast(flash_klass, "m25p80-generic"))= { + error_setg(&error_fatal, "'%s' is either abstract or" + " not a subtype of m25p80", s->ospi_model); + return; + } + } + + flash_dev =3D qdev_new(s->ospi_model ? s->ospi_model : "mt35xu01g"= ); + if (dinfo) { qdev_prop_set_drive_err(flash_dev, "drive", blk_by_legacy_dinfo(dinfo), &error_fat= al); @@ -770,6 +800,13 @@ static void versal_virt_machine_instance_init(Object *= obj) 0); } =20 +static void versal_virt_machine_finalize(Object *obj) +{ + VersalVirt *s =3D XLNX_VERSAL_VIRT_MACHINE(obj); + + g_free(s->ospi_model); +} + static void versal_virt_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -781,6 +818,10 @@ static void versal_virt_machine_class_init(ObjectClass= *oc, void *data) mc->default_cpus =3D XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS; mc->no_cdrom =3D true; mc->default_ram_id =3D "ddr"; + object_class_property_add_str(oc, "ospi-flash", versal_get_ospi_model, + versal_set_ospi_model); + object_class_property_set_description(oc, "ospi-flash", + "Change the OSPI Flash model"); } =20 static const TypeInfo versal_virt_machine_init_typeinfo =3D { @@ -789,6 +830,7 @@ static const TypeInfo versal_virt_machine_init_typeinfo= =3D { .class_init =3D versal_virt_machine_class_init, .instance_init =3D versal_virt_machine_instance_init, .instance_size =3D sizeof(VersalVirt), + .instance_finalize =3D versal_virt_machine_finalize, }; =20 static void versal_virt_machine_init_register_types(void) --=20 2.34.1