xref: /rk3399_rockchip-uboot/cmd/mtd.c (revision 28386b6dc69ba6ece0345798f08ef0aed9fb0691)
1 /*
2  * Copyright (C) (C) Copyright 2016-2019 Rockchip Electronics Co., Ltd
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <command.h>
9 #include <dm.h>
10 
11 static int mtd_curr_dev = -1;
12 
13 static int do_mtd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
14 {
15 	if (argc == 2) {
16 		return CMD_RET_FAILURE;
17 	}
18 
19 	return blk_common_cmd(argc, argv, IF_TYPE_MTD, &mtd_curr_dev);
20 }
21 
22 U_BOOT_CMD(
23 	mtd, 8, 1, do_mtd,
24 	"MTD device sub-system",
25 	"mtd dev [dev] - show or set current MTD device\n"
26 	"mtd part [dev] - print partition table of one or all MTD devices\n"
27 	"mtd read addr blk# cnt - read `cnt' blocks starting at block\n"
28 	"     `blk#' to memory address `addr'\n"
29 	"mtd write addr blk# cnt - write `cnt' blocks starting at block\n"
30 	"     `blk#' from memory address `addr'"
31 );
32