Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A762C38142 for ; Sat, 28 Jan 2023 22:01:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A916685755; Sat, 28 Jan 2023 23:01:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="dmUmRSGG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7BA9E85769; Sat, 28 Jan 2023 23:01:27 +0100 (CET) Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1EAB18574F for ; Sat, 28 Jan 2023 23:01:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x129.google.com with SMTP id g15so3762746ild.3 for ; Sat, 28 Jan 2023 14:01:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qd1gmPDjw06Dcs0/5wFiR8i7y4lsSN4iPaUMKkiGYLA=; b=dmUmRSGGSoQiUfrquMt2PXF+lRr7C25d0JUTki54V+hfxRUQyN13Hefb+cBUxJFugH cJv62u+rxLfLZ4efHSAiGsPX+zPc4iSfun48w9Tz4pEJWJ4ZaNsn9lyBD32wOV54tG46 ZbxvP/zm40SLDDiCpaG3dXHW29DgYQCEJp3so= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qd1gmPDjw06Dcs0/5wFiR8i7y4lsSN4iPaUMKkiGYLA=; b=kMpV0kISUgxuNunOMtPOYE1Z8i91Y1q3TIteAhvXn7KbIOIBsWz5gPkHAOBAC4BccP TiSCjzukUTPjp3671I/n031yJmuHLiJOzj0xU2dmSnQmA73gKgkDNV/Jse81BMEkm7wR Vx5Vw0ehvWDtp2bOdve7aB6/D4dYt/7wYsLY2a2sRX8JImw/sv6GfUi2BA8NR+sYTSdQ QjV3nvzjQN3ei0lo/gzqNO4RFKqOe9oDaIiJ6DAT/LEGxCNK0C4TOPN+G6Yfb84iQjS/ r/92+NxIaWN1DLhCt4sh7oTKNJxYAzhRzzzF2TnEZAuMbm7+PSG0OoFpl9voISfDyo4/ igvA== X-Gm-Message-State: AO0yUKUUDKB88nIsDLBKQ/T5woiN8Stp8DtU5t2Hm1szWB+MxEwioEkZ U2Ho1qpfEW9vSk2TkiL2CeOFsrIm6EkKqatb X-Google-Smtp-Source: AK7set+WknYn7qYtF4Bb4jkf1ZrjhbEVRBuovHOIXe1paO/tY5eMaBQS7BQCnaYsSs9L9BoQZycDmA== X-Received: by 2002:a05:6e02:1b81:b0:310:be09:7aa6 with SMTP id h1-20020a056e021b8100b00310be097aa6mr8035165ili.13.1674943273614; Sat, 28 Jan 2023 14:01:13 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id f15-20020a056e0212af00b0030f1be2e051sm2525521ilr.39.2023.01.28.14.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Jan 2023 14:01:13 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Albert Aribaud , Ilias Apalodimas , Simon Glass Subject: [PATCH 09/13] qemu: Add a bootdev for qfw Date: Sat, 28 Jan 2023 15:00:24 -0700 Message-Id: <20230128220028.53575-10-sjg@chromium.org> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog In-Reply-To: <20230128220028.53575-1-sjg@chromium.org> References: <20230128220028.53575-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Add a bootdev device for qfw so that it can be used with standard boot. This simply checks for the correct method and then does the read. Most of the other logic is handed in a new bootmeth driver. Signed-off-by: Simon Glass --- drivers/misc/qfw.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/drivers/misc/qfw.c b/drivers/misc/qfw.c index 1d54b7542b8..9ef95caa895 100644 --- a/drivers/misc/qfw.c +++ b/drivers/misc/qfw.c @@ -7,6 +7,9 @@ #define LOG_CATEGORY UCLASS_QFW #include +#include +#include +#include #include #include #include @@ -310,8 +313,92 @@ int qfw_register(struct udevice *dev) return 0; } +static int qfw_post_bind(struct udevice *dev) +{ + int ret; + + ret = bootdev_setup_for_dev(dev, "qfw_bootdev"); + if (ret) + return log_msg_ret("dev", ret); + + return 0; +} + +static int qfw_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, + struct bootflow *bflow) +{ + const struct udevice *media = dev_get_parent(dev); + int ret; + + if (!CONFIG_IS_ENABLED(BOOTSTD)) + return -ENOSYS; + + log_debug("media=%s\n", media->name); + ret = bootmeth_check(bflow->method, iter); + if (ret) + return log_msg_ret("check", ret); + + log_debug("iter->part=%d\n", iter->part); + + /* We only support the whole device, not partitions */ + if (iter->part) + return log_msg_ret("max", -ESHUTDOWN); + + log_debug("reading bootflow with method: %s\n", bflow->method->name); + ret = bootmeth_read_bootflow(bflow->method, bflow); + if (ret) + return log_msg_ret("method", ret); + + return 0; +} + +static int qfw_bootdev_bind(struct udevice *dev) +{ + struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); + + ucp->prio = BOOTDEVP_4_SCAN_FAST; + + return 0; +} + +static int qfw_bootdev_hunt(struct bootdev_hunter *info, bool show) +{ + int ret; + + ret = uclass_probe_all(UCLASS_QFW); + if (ret && ret != -ENOENT) + return log_msg_ret("vir", ret); + + return 0; +} + UCLASS_DRIVER(qfw) = { .id = UCLASS_QFW, .name = "qfw", + .post_bind = qfw_post_bind, .per_device_auto = sizeof(struct qfw_dev), }; + +struct bootdev_ops qfw_bootdev_ops = { + .get_bootflow = qfw_get_bootflow, +}; + +static const struct udevice_id qfw_bootdev_ids[] = { + { .compatible = "u-boot,bootdev-qfw" }, + { } +}; + +U_BOOT_DRIVER(qfw_bootdev) = { + .name = "qfw_bootdev", + .id = UCLASS_BOOTDEV, + .ops = &qfw_bootdev_ops, + .bind = qfw_bootdev_bind, + .of_match = qfw_bootdev_ids, +}; + +BOOTDEV_HUNTER(qfw_bootdev_hunter) = { + .prio = BOOTDEVP_4_SCAN_FAST, + .uclass = UCLASS_QFW, + .hunt = qfw_bootdev_hunt, + .drv = DM_DRIVER_REF(qfw_bootdev), +}; -- 2.39.1.456.gfc5497dd1b-goog