mirror of
https://xff.cz/git/u-boot/
synced 2025-09-29 22:41:17 +02:00
bootstd: Add a USB hunter
Add a hunter for USB which enumerates the bus to find new bootdevs. Update the tests and speed up bootdev_test_prio() while we are here, by dropping the USB delays. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -20,6 +20,11 @@ static int usb_bootdev_bind(struct udevice *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int usb_bootdev_hunt(struct bootdev_hunter *info, bool show)
|
||||||
|
{
|
||||||
|
return usb_init();
|
||||||
|
}
|
||||||
|
|
||||||
struct bootdev_ops usb_bootdev_ops = {
|
struct bootdev_ops usb_bootdev_ops = {
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -35,3 +40,10 @@ U_BOOT_DRIVER(usb_bootdev) = {
|
|||||||
.bind = usb_bootdev_bind,
|
.bind = usb_bootdev_bind,
|
||||||
.of_match = usb_bootdev_ids,
|
.of_match = usb_bootdev_ids,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BOOTDEV_HUNTER(usb_bootdev_hunter) = {
|
||||||
|
.prio = BOOTDEVP_3_SCAN_SLOW,
|
||||||
|
.uclass = UCLASS_USB,
|
||||||
|
.hunt = usb_bootdev_hunt,
|
||||||
|
.drv = DM_DRIVER_REF(usb_bootdev),
|
||||||
|
};
|
||||||
|
@@ -190,6 +190,8 @@ static int bootdev_test_prio(struct unit_test_state *uts)
|
|||||||
struct bootflow bflow;
|
struct bootflow bflow;
|
||||||
struct udevice *blk;
|
struct udevice *blk;
|
||||||
|
|
||||||
|
test_set_skip_delays(true);
|
||||||
|
|
||||||
/* Start up USB which gives us three additional bootdevs */
|
/* Start up USB which gives us three additional bootdevs */
|
||||||
usb_started = false;
|
usb_started = false;
|
||||||
ut_assertok(run_command("usb start", 0));
|
ut_assertok(run_command("usb start", 0));
|
||||||
@@ -227,6 +229,8 @@ static int bootdev_test_hunter(struct unit_test_state *uts)
|
|||||||
{
|
{
|
||||||
struct bootstd_priv *std;
|
struct bootstd_priv *std;
|
||||||
|
|
||||||
|
test_set_skip_delays(true);
|
||||||
|
|
||||||
/* get access to the used hunters */
|
/* get access to the used hunters */
|
||||||
ut_assertok(bootstd_get_priv(&std));
|
ut_assertok(bootstd_get_priv(&std));
|
||||||
|
|
||||||
@@ -234,12 +238,17 @@ static int bootdev_test_hunter(struct unit_test_state *uts)
|
|||||||
bootdev_list_hunters(std);
|
bootdev_list_hunters(std);
|
||||||
ut_assert_nextline("Prio Used Uclass Hunter");
|
ut_assert_nextline("Prio Used Uclass Hunter");
|
||||||
ut_assert_nextlinen("----");
|
ut_assert_nextlinen("----");
|
||||||
ut_assert_nextline("(total hunters: 0)");
|
ut_assert_nextline(" 40 usb usb_bootdev");
|
||||||
|
ut_assert_nextline("(total hunters: 1)");
|
||||||
ut_assert_console_end();
|
ut_assert_console_end();
|
||||||
|
|
||||||
ut_assertok(bootdev_hunt("mmc1", false));
|
ut_assertok(bootdev_hunt("usb1", false));
|
||||||
|
ut_assert_nextline(
|
||||||
|
"Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found");
|
||||||
ut_assert_console_end();
|
ut_assert_console_end();
|
||||||
|
|
||||||
|
ut_asserteq(GENMASK(0, 0), std->hunters_used);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
BOOTSTD_TEST(bootdev_test_hunter, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
|
BOOTSTD_TEST(bootdev_test_hunter, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
|
||||||
@@ -249,6 +258,8 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts)
|
|||||||
{
|
{
|
||||||
struct bootstd_priv *std;
|
struct bootstd_priv *std;
|
||||||
|
|
||||||
|
test_set_skip_delays(true);
|
||||||
|
|
||||||
/* get access to the used hunters */
|
/* get access to the used hunters */
|
||||||
ut_assertok(bootstd_get_priv(&std));
|
ut_assertok(bootstd_get_priv(&std));
|
||||||
|
|
||||||
@@ -256,21 +267,26 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts)
|
|||||||
ut_assertok(run_command("bootdev hunt -l", 0));
|
ut_assertok(run_command("bootdev hunt -l", 0));
|
||||||
ut_assert_nextline("Prio Used Uclass Hunter");
|
ut_assert_nextline("Prio Used Uclass Hunter");
|
||||||
ut_assert_nextlinen("----");
|
ut_assert_nextlinen("----");
|
||||||
ut_assert_nextline("(total hunters: 0)");
|
ut_assert_nextline(" 40 usb usb_bootdev");
|
||||||
|
ut_assert_nextline("(total hunters: 1)");
|
||||||
ut_assert_console_end();
|
ut_assert_console_end();
|
||||||
|
|
||||||
/* Scan all hunters */
|
/* Scan all hunters */
|
||||||
ut_assertok(run_command("bootdev hunt", 0));
|
ut_assertok(run_command("bootdev hunt", 0));
|
||||||
|
ut_assert_nextline("Hunting with: usb");
|
||||||
|
ut_assert_nextline(
|
||||||
|
"Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found");
|
||||||
ut_assert_console_end();
|
ut_assert_console_end();
|
||||||
|
|
||||||
/* List available hunters */
|
/* List available hunters */
|
||||||
ut_assertok(run_command("bootdev hunt -l", 0));
|
ut_assertok(run_command("bootdev hunt -l", 0));
|
||||||
ut_assert_nextlinen("Prio");
|
ut_assert_nextlinen("Prio");
|
||||||
ut_assert_nextlinen("----");
|
ut_assert_nextlinen("----");
|
||||||
ut_assert_nextline("(total hunters: 0)");
|
ut_assert_nextline(" 40 * usb usb_bootdev");
|
||||||
|
ut_assert_nextline("(total hunters: 1)");
|
||||||
ut_assert_console_end();
|
ut_assert_console_end();
|
||||||
|
|
||||||
ut_asserteq(0, std->hunters_used);
|
ut_asserteq(GENMASK(0, 0), std->hunters_used);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user