blob: 3dace5344f7ee604db9bbc782ff915cfcb69a515 [file] [log] [blame]
Tuomas Tynkkynen78e12902018-10-15 02:21:12 -07001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2018, Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
4 * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
5 */
6
7#include <common.h>
Simon Glasse6f6f9e2020-05-10 11:39:58 -06008#include <blk.h>
Tuomas Tynkkynen78e12902018-10-15 02:21:12 -07009#include <command.h>
10#include <dm.h>
11#include <virtio_types.h>
12#include <virtio.h>
13
14static int virtio_curr_dev;
15
Simon Glass09140112020-05-10 11:40:03 -060016static int do_virtio(struct cmd_tbl *cmdtp, int flag, int argc,
17 char *const argv[])
Tuomas Tynkkynen78e12902018-10-15 02:21:12 -070018{
19 if (argc == 2 && !strcmp(argv[1], "scan")) {
20 /* make sure all virtio devices are enumerated */
21 virtio_init();
22
23 return CMD_RET_SUCCESS;
24 }
25
26 return blk_common_cmd(argc, argv, IF_TYPE_VIRTIO, &virtio_curr_dev);
27}
28
29U_BOOT_CMD(
30 virtio, 8, 1, do_virtio,
31 "virtio block devices sub-system",
32 "scan - initialize virtio bus\n"
33 "virtio info - show all available virtio block devices\n"
34 "virtio device [dev] - show or set current virtio block device\n"
35 "virtio part [dev] - print partition table of one or all virtio block devices\n"
36 "virtio read addr blk# cnt - read `cnt' blocks starting at block\n"
37 " `blk#' to memory address `addr'\n"
38 "virtio write addr blk# cnt - write `cnt' blocks starting at block\n"
39 " `blk#' from memory address `addr'"
40);