1 /* 2 * Copyright (c) 2018 Fuzhou Rockchip Electronics Co., Ltd 3 * 4 * SPDX-License-Identifier: (GPL-2.0+ OR MIT) 5 */ 6 7 #include <common.h> 8 #include <command.h> 9 #include <dm.h> 10 #include <rksfc.h> 11 12 static int rksfc_curr_dev; 13 static int do_rksfc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 14 { 15 int ret; 16 u32 dev_type = IF_TYPE_UNKNOWN; 17 18 if (rksfc_curr_dev == 0) 19 dev_type = IF_TYPE_SPINAND; 20 else if (rksfc_curr_dev == 1) 21 dev_type = IF_TYPE_SPINOR; 22 23 if (argc == 2) { 24 if (strncmp(argv[1], "scan", 4) == 0) { 25 ret = rksfc_scan_namespace(); 26 if (ret) 27 return CMD_RET_FAILURE; 28 29 return ret; 30 } 31 } 32 33 if (argc == 3) { 34 if (strncmp(argv[1], "dev", 3) == 0) { 35 if ((int)simple_strtoul(argv[2], NULL, 10) == 0) 36 dev_type = IF_TYPE_SPINAND; 37 else 38 dev_type = IF_TYPE_SPINOR; 39 } 40 } 41 42 return blk_common_cmd(argc, argv, dev_type, &rksfc_curr_dev); 43 } 44 45 U_BOOT_CMD( 46 rksfc, 8, 1, do_rksfc, 47 "rockchip sfc sub-system", 48 "scan - scan Sfc devices\n" 49 "rksfc info - show all available Sfc devices\n" 50 "rksfc device [dev] - show or set current Sfc device\n" 51 " dev 0 - spinand\n" 52 " dev 1 - spinor\n" 53 "rksfc part [dev] - print partition table of one or all Sfc devices\n" 54 "rksfc read addr blk# cnt - read `cnt' blocks starting at block\n" 55 " `blk#' to memory address `addr'\n" 56 "rksfc write addr blk# cnt - write `cnt' blocks starting at block\n" 57 " `blk#' from memory address `addr'" 58 ); 59