From patchwork Wed Dec 7 08:51:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713130 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=GXI0OJL3; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NRrsD1mRDz23pB for ; Wed, 7 Dec 2022 20:02:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9FAF4856BC; Wed, 7 Dec 2022 09:56:20 +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="GXI0OJL3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E093185674; Wed, 7 Dec 2022 09:56:10 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (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 EA240855E1 for ; Wed, 7 Dec 2022 09:56:05 +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-pj1-x1035.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so833500pjs.4 for ; Wed, 07 Dec 2022 00:56:05 -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=bOwEydbBVxuKzteltpntbUC9xf1QUA9tM3t19ck5/64=; b=GXI0OJL3E1I+KU15QQ/eL2ygNag+rOKgPzWJ+JcDxuk8QaDdr2novK6IBEX0C5VlPe kTKJvjl/+SxOqBtllDyDqeZS6S6ldtX6pscRSXEGoa5wo9pFhymoDgBqCItr7pNjWG28 qYIQiq1dbYj/ijWjO+zjcKfYNxviCAoWzk3k4= 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=bOwEydbBVxuKzteltpntbUC9xf1QUA9tM3t19ck5/64=; b=uoVRI9WiILaOb2qpJCfkb9cs6KC/XH9+IPZG75Ifhay3zKov3ufEXhLQG/+Hd+AFaH btn/vD4qPNn43fO4y50X8ZkBoh7cRT4/KbuzX4R8HAme4EP9Om3zBj89XpA1yOE3CVcw S9b/9pfCXUthh8QaE87CJGGoxLvKBm9wt9CsE3hUXyS6/cOTPhaJgdimUV8nrHkF2zZi 1s5kxbG5IehBFjBFR8WgMVpBbZnJUOsm+dG8PRqM3I7eK/xrUJv9AoZ/j9bKBdl1DrdA OFC9k4qSLqoNN5wWwKNbrfE6m7WUXLtHRP9UuBp/3gq+UOV2PnMgPhks9SzsqOPEWrfT yZmg== X-Gm-Message-State: ANoB5pmlek7dnzI4+V4DowJ2Aqmya68wkrPzvGSacwBh+OWmhqnPu8mi MdzmMj2/nN4M+QCY88YGUEznvXzYhrp/Vi55 X-Google-Smtp-Source: AA0mqf4wUCfBIqpA10AInuUOBtHnVPZOl7OepmDufpZcDKDSSIYCCtG3hNUG9c3jrbhS1eNt5ZHldw== X-Received: by 2002:a17:90a:5d08:b0:218:770c:9a40 with SMTP id s8-20020a17090a5d0800b00218770c9a40mr81944386pji.158.1670403364062; Wed, 07 Dec 2022 00:56:04 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:03 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , AKASHI Takahiro , Stefan Roese Subject: [PATCH 37/71] bootstd: Add an IDE bootdev Date: Wed, 7 Dec 2022 21:51:03 +1300 Message-Id: <20221207085137.445249-38-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-1-sjg@chromium.org> MIME-Version: 1.0 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 for IDE so that these devices can be used with standard boot. Signed-off-by: Simon Glass --- configs/sandbox_flattree_defconfig | 8 ++++++ drivers/block/ide.c | 44 ++++++++++++++++++++++++++++++ test/boot/bootdev.c | 16 +++++++---- 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index df41efbe9ac..ff4e6a46cc5 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -39,6 +39,7 @@ CONFIG_CMD_MEMTEST=y CONFIG_CMD_DEMO=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y +CONFIG_CMD_IDE=y CONFIG_CMD_I2C=y CONFIG_CMD_OSD=y CONFIG_CMD_PCI=y @@ -87,6 +88,13 @@ CONFIG_ADC=y CONFIG_ADC_SANDBOX=y CONFIG_AXI=y CONFIG_AXI_SANDBOX=y +CONFIG_SYS_IDE_MAXBUS=1 +CONFIG_SYS_ATA_BASE_ADDR=0x100 +CONFIG_SYS_ATA_STRIDE=4 +CONFIG_SYS_ATA_DATA_OFFSET=0 +CONFIG_SYS_ATA_REG_OFFSET=1 +CONFIG_SYS_ATA_ALT_OFFSET=2 +CONFIG_SYS_ATA_IDE0_OFFSET=0 CONFIG_CLK=y CONFIG_CLK_COMPOSITE_CCF=y CONFIG_CLK_K210=y diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 13a1cb4b9e4..80c8b64de2f 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -1055,6 +1056,45 @@ U_BOOT_DRIVER(ide_blk) = { .probe = ide_blk_probe, }; +static int ide_bootdev_bind(struct udevice *dev) +{ + struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); + + ucp->prio = BOOTDEVP_3_SCAN_SLOW; + + return 0; +} + +static int ide_bootdev_hunt(struct bootdev_hunter *info, bool show) +{ + ide_init(); + + return 0; +} + +struct bootdev_ops ide_bootdev_ops = { +}; + +static const struct udevice_id ide_bootdev_ids[] = { + { .compatible = "u-boot,bootdev-ide" }, + { } +}; + +U_BOOT_DRIVER(ide_bootdev) = { + .name = "ide_bootdev", + .id = UCLASS_BOOTDEV, + .ops = &ide_bootdev_ops, + .bind = ide_bootdev_bind, + .of_match = ide_bootdev_ids, +}; + +BOOTDEV_HUNTER(ide_bootdev_hunter) = { + .prio = BOOTDEVP_3_SCAN_SLOW, + .uclass = UCLASS_IDE, + .hunt = ide_bootdev_hunt, + .drv = DM_DRIVER_REF(ide_bootdev), +}; + static int ide_probe(struct udevice *udev) { struct udevice *blk_dev; @@ -1086,6 +1126,10 @@ static int ide_probe(struct udevice *udev) ret = blk_probe_or_unbind(blk_dev); if (ret) return ret; + + ret = bootdev_setup_for_dev(udev, "ide_bootdev"); + if (ret) + return log_msg_ret("bootdev", ret); } } diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 5661a3c0009..a3acdcbdba3 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -239,10 +239,11 @@ static int bootdev_test_hunter(struct unit_test_state *uts) ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); ut_assert_nextline(" 50 ethernet eth_bootdev"); + ut_assert_nextline(" 40 ide ide_bootdev"); ut_assert_nextline(" 10 mmc mmc_bootdev"); ut_assert_nextline(" 30 scsi scsi_bootdev"); ut_assert_nextline(" 40 usb usb_bootdev"); - ut_assert_nextline("(total hunters: 4)"); + ut_assert_nextline("(total hunters: 5)"); ut_assert_console_end(); ut_assertok(bootdev_hunt("usb1", false)); @@ -250,8 +251,8 @@ static int bootdev_test_hunter(struct unit_test_state *uts) "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); ut_assert_console_end(); - /* USB is fourth in the list, so bit 3 */ - ut_asserteq(BIT(3), std->hunters_used); + /* USB is fifth in the list, so bit 4 */ + ut_asserteq(BIT(4), std->hunters_used); return 0; } @@ -271,7 +272,7 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); - ut_assert_skip_to_line("(total hunters: 4)"); + ut_assert_skip_to_line("(total hunters: 5)"); ut_assert_console_end(); /* Scan all hunters */ @@ -279,6 +280,8 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt", 0)); ut_assert_nextline("Hunting with: ethernet"); + ut_assert_nextline("Hunting with: ide"); + ut_assert_nextline("Bus 0: not available "); ut_assert_nextline("Hunting with: mmc"); ut_assert_nextline("Hunting with: scsi"); ut_assert_nextline("scanning bus for devices..."); @@ -292,14 +295,15 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assert_nextlinen("Prio"); ut_assert_nextlinen("----"); ut_assert_nextline(" 50 * ethernet eth_bootdev"); + ut_assert_nextline(" 40 * ide ide_bootdev"); ut_assert_nextline(" 10 * mmc mmc_bootdev"); ut_assert_nextline(" 30 * scsi scsi_bootdev"); ut_assert_nextline(" 40 * usb usb_bootdev"); - ut_assert_nextline("(total hunters: 4)"); + ut_assert_nextline("(total hunters: 5)"); ut_assert_console_end(); - ut_asserteq(GENMASK(3, 0), std->hunters_used); + ut_asserteq(GENMASK(4, 0), std->hunters_used); return 0; }