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 AD0D9C46467 for ; Sun, 8 Jan 2023 03:05:41 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 98A6C8567A; Sun, 8 Jan 2023 04:04:28 +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="BWTMRaqD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8D37685662; Sun, 8 Jan 2023 04:04:11 +0100 (CET) Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) (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 B148085659 for ; Sun, 8 Jan 2023 03:51:23 +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-x135.google.com with SMTP id o13so3286720ilc.7 for ; Sat, 07 Jan 2023 18:51:23 -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=GEPcGWoGvnlU7JwpxrPlMd7ADOIcdRutDRhP40QXji0=; b=BWTMRaqDpwhKE8e+FXO0AuoAMoVNuMDTGOt/QY8Oq9Io4rOAswpdHpHaxJsEA8xPAC 8wlswKR/dCdee+fE03oyuI6ac00ZZt0msnOzQCX54sOsVbGVy6glK/aWjCahMqgCYcnB PLlwJu5O8KdBwaxnNnFNeiX5ByUJju9pLvDV4= 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=GEPcGWoGvnlU7JwpxrPlMd7ADOIcdRutDRhP40QXji0=; b=QveOMZ/xVPEdfqb+Mi7VSC0tdNWz//yH3kyaRjuz1eKu0kwMsKBzV8OKHm+VDf+JUL fWIFtdi8x929LI4ROR6s2XTazIA2tCXs6h3tE1zYKlrnP3d9oTKkpCHFMAhnyG4+RD8m WanTMFkrC4XUZnVYrlEVtKFlUTsjVZW6bI9U/H3FDiRRZ+wFTnb4bKLRB+whABLDZl4t BRq3PO8W1WYb9wxhRgTZ8QwMT2PNegYIzUQn2X4PPam9HtM2LhUHix8ef5tCSQIDc1ba qbaofPie8GveOIWtE4TT/TSdWTBhAeO67xkl8czyim21MfKPsFl+CMHDgm32xoU8UlBn Fp4w== X-Gm-Message-State: AFqh2krctVdgul/vM70ULvBtLIAx1bgaPcFDMGd1TneEsztW48Mbu3Dc 575BkEBhshC+ysIic7Yz3PZwXLbop0YMRfnR X-Google-Smtp-Source: AMrXdXuv6pR4MTleoARd4uHDlVsEBX7sE7b8mTysyoqSICdZkcrEfpQloh2XFuAjDkZJgtOtSCiSng== X-Received: by 2002:a92:364f:0:b0:30d:6ea8:4f27 with SMTP id d15-20020a92364f000000b0030d6ea84f27mr10069460ilf.15.1673146283148; Sat, 07 Jan 2023 18:51:23 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-71-56-217-229.hsd1.co.comcast.net. [71.56.217.229]) by smtp.gmail.com with ESMTPSA id c17-20020a92bd11000000b00302a00aaefasm1622174ile.26.2023.01.07.18.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jan 2023 18:51:22 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH v2 37/71] bootstd: Add an IDE bootdev Date: Sat, 7 Jan 2023 19:50:13 -0700 Message-Id: <20230108025047.522240-38-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230108025047.522240-1-sjg@chromium.org> References: <20230108025047.522240-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 for IDE so that these devices can be used with standard boot. Signed-off-by: Simon Glass --- (no changes since v1) 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 eaaec42b1fe..6e8faf56797 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -40,6 +40,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_MMC=y CONFIG_CMD_OSD=y @@ -90,6 +91,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; } -- 2.39.0.314.g84b9a713c41-goog