From d5f538dc02e53c7267fcd4a914104071fca889b5 Mon Sep 17 00:00:00 2001 From: Dingqiang Lin Date: Thu, 26 Apr 2018 14:09:07 +0800 Subject: [PATCH] cmd: rksfc: add sfc u-boot command rksfc driver with block interface Change-Id: I395cf78e939ce9ddbd07a9afad794474f0482542 Signed-off-by: Dingqiang Lin --- cmd/Kconfig | 7 +++++++ cmd/Makefile | 1 + cmd/rksfc.c | 41 +++++++++++++++++++++++++++++++++++++++++ doc/README.rksfc | 29 +++++++++++++++++++++++++++++ include/rksfc.h | 20 ++++++++++++++++++++ 5 files changed, 98 insertions(+) create mode 100644 cmd/rksfc.c create mode 100644 doc/README.rksfc create mode 100644 include/rksfc.h diff --git a/cmd/Kconfig b/cmd/Kconfig index 6afb4fd64f..f7f78c6361 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -898,6 +898,13 @@ config CMD_RKNAND help Rockchip NAND FLASH device support +config CMD_RKSFC + bool "rksfc" + depends on (RKSFC_NOR || RKSFC_NAND) + default y if (RKSFC_NOR || RKSFC_NAND) + help + Rockchip SFC device support + config CMD_SATA bool "sata - Access SATA subsystem" select SATA diff --git a/cmd/Makefile b/cmd/Makefile index 82817e2943..4f12f6fdbe 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -115,6 +115,7 @@ obj-$(CONFIG_CMD_SATA) += sata.o obj-$(CONFIG_CMD_NVME) += nvme.o obj-$(CONFIG_CMD_ROCKUSB) += rockusb.o obj-$(CONFIG_CMD_RKNAND) += rknand.o +obj-$(CONFIG_CMD_RKSFC) += rksfc.o obj-$(CONFIG_CMD_SF) += sf.o obj-$(CONFIG_CMD_SCSI) += scsi.o disk.o obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o diff --git a/cmd/rksfc.c b/cmd/rksfc.c new file mode 100644 index 0000000000..f4b4a317d7 --- /dev/null +++ b/cmd/rksfc.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018 Fuzhou Rockchip Electronics Co., Ltd + * + * SPDX-License-Identifier: (GPL-2.0+ OR MIT) + */ + +#include +#include +#include +#include + +static int rksfc_curr_dev; +static int do_rksfc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + int ret; + + if (argc == 2) { + if (strncmp(argv[1], "scan", 4) == 0) { + ret = rksfc_scan_namespace(); + if (ret) + return CMD_RET_FAILURE; + + return ret; + } + } + + return blk_common_cmd(argc, argv, IF_TYPE_RKSFC, &rksfc_curr_dev); +} + +U_BOOT_CMD( + rksfc, 8, 1, do_rksfc, + "rockchip sfc sub-system", + "scan - scan Sfc devices\n" + "rksfc info - show all available Sfc devices\n" + "rksfc device [dev] - show or set current Sfc device\n" + "rksfc part [dev] - print partition table of one or all Sfc devices\n" + "rksfc read addr blk# cnt - read `cnt' blocks starting at block\n" + " `blk#' to memory address `addr'\n" + "rksfc write addr blk# cnt - write `cnt' blocks starting at block\n" + " `blk#' from memory address `addr'" +); diff --git a/doc/README.rksfc b/doc/README.rksfc new file mode 100644 index 0000000000..447c8a6174 --- /dev/null +++ b/doc/README.rksfc @@ -0,0 +1,29 @@ +rksfc (Rockchip SPI FLASH SFC drivers) +===================================================== + +Overview +-------- + +The rksfc is used for Rockchip Soc sfc devices with +block interface. + +Status +------ +It supprot SFC SPI NOR. + +Usage in U-Boot +--------------- + +To list all of the rksfc hard disks, try: + + => rksfc info + Device 0: Vendor: 0x0308 Rev: V1.00 Prod: rksfc + Type: Hard Disk + Capacity: 32.0 MB = 0.0 GB (65600 x 512) + +To find and initialize sfc devices, try: + => rksfc dev 0 + Device 0: Vendor: 0x0308 Rev: V1.00 Prod: rksfc + Type: Hard Disk + Capacity: 32.0 MB = 0.0 GB (65600 x 512) +... is now current device diff --git a/include/rksfc.h b/include/rksfc.h new file mode 100644 index 0000000000..03a457b8bb --- /dev/null +++ b/include/rksfc.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2018 Rockchip Electronics Co., Ltd + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __RKSFC_H__ +#define __RKSFC_H__ +/** + * rksfc_scan_namespace - scan all namespaces attached to RK SFC + * controllers + * + * This probes all registered RK SFC uclass device drivers in the + * system,and tries to find all namespaces attached to the RK SFC + * controllers. + * + * @return: 0 on success, -ve on error + */ +int rksfc_scan_namespace(void); +#endif