NVMe: add NVMe driver support
RFC 1/2 NVMe: add NVMe driver support
Add Support of devices that follow the NVM Express standard
basic functions:
nvme init/scan
nvme info - show the basic information of device nvme Read/Write
driver model:
Use block device(CONFIG_BLK)'s structure to support nvme's DM. Use UCLASS_PCI as a parent uclass.
The driver code heavily copy from the NVMe driver code in Linux Kernel.
--- common/Makefile | 1 + common/board_r.c | 13 + common/nvme.c | 127 ++++++ doc/README.nvme | 17 + drivers/block/Kconfig | 16 + drivers/block/Makefile | 1 + drivers/block/blk-uclass.c | 2 + drivers/block/nvme.c | 1048 ++++++++++++++++++++++++++++++++++++++++++++ drivers/block/nvme.h | 114 +++++ drivers/block/nvme_uapi.h | 570 ++++++++++++++++++++++++ include/blk.h | 1 + include/nvme.h | 50 +++ 12 files changed, 1960 insertions(+) create mode 100644 common/nvme.c create mode 100644 doc/README.nvme create mode 100644 drivers/block/nvme.c create mode 100644 drivers/block/nvme.h create mode 100644 drivers/block/nvme_uapi.h create mode 100644 include/nvme.h
common/Makefile +1 -0
@@ -81,6 +81,7 @@ obj-$(CONFIG_LCD_DT_SIMPLEFB) += lcd_simplefb.o obj-$(CONFIG_LYNXKDI) += lynxkdi.o obj-$(CONFIG_MENU) += menu.o obj-$(CONFIG_CMD_SATA) += sata.o +obj-$(CONFIG_NVME) += nvme.o obj-$(CONFIG_SCSI) += scsi.o obj-$(CONFIG_UPDATE_TFTP) += update.o obj-$(CONFIG_DFU_TFTP) += update.o
common/board_r.c +13 -0
@@ -49,6 +49,7 @@#include <timer.h> #include <trace.h> #include <watchdog.h> +#include <nvme.h> #ifdef CONFIG_CMD_AMBAPP #include <ambapp.h> #endif
@@ -458,6 +459,15 @@ static int initr_dataflash(void) }#endif +#ifdef CONFIG_NVME +static int initr_nvme (void ) +{ +puts ("NVMe: " ); +nvme_initialize (); +return 0 ; +} +#endif +/* * Tell if it's OK to load the environment early in boot. *
@@ -942,6 +952,9 @@ init_fnc_t init_sequence_r[] = {#if defined(CONFIG_SPARC ) prom_init,#endif +#ifdef CONFIG_NVME + initr_nvme, +#endif run_main_loop, };
common/nvme.c new file +127 -0
127 lines not on this page · raw message
doc/README.nvme new file +17 -0
@@ -0,0 +1,17 @@ +/* + * Copyright (C) 2017 NXP Semiconductors + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +1. NVMe Config Switches: + +CONFIG_NVME enables basic NVMe device support + NVMe is a basic device which mounted on PCIe bus, + so is depends on CONFIG_PCI. +CONFIG_SYS_NVME_MAX_DEVICE configs the max num of NVMe devices + +2. Driver Model Support: + +Use block device(CONFIG_BLK)'s structure to support nvme's DM. +Use UCLASS_PCI as a parent uclass.
drivers/block/Kconfig +16 -0
@@ -49,3 +49,19 @@ config SATA_CEVA AHCI 1.3 specifications with hot-plug detect feature. endmenu + +config NVME + bool "Support NVMe devices" + depends on PCI + help + This option enables supporting for all NVMe devices. + It supports the basic functions before using NVMe devices + such as "nvme init" "nvme scan" and R/W. + It also contains other functions to use the devices. + +config SYS_NVME_MAX_DEVICE + int "Config the Max Num of NVMe Devices" + depends on NVME + default 1 + help + Set the max num of NVMe Devices.
drivers/block/Makefile +1 -0
@@ -31,3 +31,4 @@ obj-$(CONFIG_SANDBOX) += sandbox.o sandbox_scsi.o sata_sandbox.o obj-$(CONFIG_SCSI_SYM53C8XX) += sym53c8xx.o obj-$(CONFIG_SYSTEMACE) += systemace.o obj-$(CONFIG_BLOCK_CACHE) += blkcache.o +obj-$(CONFIG_NVME) += nvme.o
drivers/block/blk-uclass.c +2 -0
@@ -22,6 +22,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = { [IF_TYPE_SATA] = "sata", [IF_TYPE_HOST] = "host", [IF_TYPE_SYSTEMACE] = "ace", + [IF_TYPE_NVME] = "nvme", };static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT ] = {
@@ -34,6 +35,7 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = { [IF_TYPE_SD] = UCLASS_INVALID, [IF_TYPE_SATA] = UCLASS_AHCI, [IF_TYPE_HOST] = UCLASS_ROOT, + [IF_TYPE_NVME] = UCLASS_PCI, [IF_TYPE_SYSTEMACE] = UCLASS_INVALID, };
drivers/block/nvme.c new file +1048 -0
1,048 lines not on this page · raw message
drivers/block/nvme.h new file +114 -0
114 lines not on this page · raw message
drivers/block/nvme_uapi.h new file +570 -0
570 lines not on this page · raw message
include/blk.h +1 -0
@@ -31,6 +31,7 @@ enum if_type {IF_TYPE_SATA ,IF_TYPE_HOST ,IF_TYPE_SYSTEMACE , +IF_TYPE_NVME , IF_TYPE_COUNT, /* Number of interface types */ };
include/nvme.h new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
2.1.0.27.g96db324
RFC 2/2 NVMe: add nvme commands
Add nvme commands in U-Boot command line.
1. "nvme list" - show all available NVMe blk devices
2. "nvme info" - show current or a specific NVMe blk device
3. "nvme device" - show or set current device
4. "nvme part" - print partition table
5. "nvme read" - read data from NVMe blk device
6. "nvme write" - write data to NVMe blk device
--- cmd/Kconfig | 9 +++ cmd/Makefile | 1 + cmd/nvme.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ disk/part.c | 6 ++ doc/README.nvme | 52 +++++++++++++++++ 5 files changed, 242 insertions(+) create mode 100644 cmd/nvme.c
cmd/Kconfig +9 -0
@@ -430,6 +430,15 @@ config CMD_USB help USB support. +config CMD_NVME + bool "NVMe" + depends on NVME + help + NVMe support. + This enables nvme commands in command line + You can use comamnd "nvme" to show what commands it supports + such as "nvme info" "nvme list". + config CMD_DFU bool "dfu" select USB_FUNCTION_DFU
cmd/Makefile +1 -0
@@ -114,6 +114,7 @@ obj-$(CONFIG_CMD_REISER) += reiser.o obj-$(CONFIG_CMD_REMOTEPROC) += remoteproc.o obj-$(CONFIG_SANDBOX) += host.o obj-$(CONFIG_CMD_SATA) += sata.o +obj-$(CONFIG_CMD_NVME) += nvme.o obj-$(CONFIG_CMD_SF) += sf.o obj-$(CONFIG_SCSI) += scsi.o disk.o obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o
cmd/nvme.c new file +174 -0
174 lines not on this page · raw message
disk/part.c +6 -0
@@ -140,6 +140,12 @@ void dev_print (struct blk_desc *dev_desc)case IF_TYPE_DOC :puts ("device type DOC\n" );return ; +case IF_TYPE_NVME : +printf ("Vendor: %s Rev: %s Prod: %s\n" , + dev_desc->vendor, + dev_desc->revision, + dev_desc->product); +break ;case IF_TYPE_UNKNOWN :puts ("device type unknown\n" );return ;
doc/README.nvme +52 -0
60 lines not on this page · raw message
Signature · 1 line
2.1.0.27.g96db324
RFC 1/2 NVMe: add NVMe driver support
In reply to Zhikang ZhangQuoted 7 lines · Zhikang Zhang
Add Support of devices that follow the NVM Express standard
basic functions:
nvme init/scan
nvme info - show the basic information of device nvme Read/Write
Quoted 8 lines
driver model:
Use block device(CONFIG_BLK)'s structure to support nvme's DM. UseUCLASS_PCIas a parent uclass.The driver code heavily copy from the NVMe driver code in Linux Kernel.
Signed-off-by Zhikang Zhang <[email protected]>Signed-off-by Wenbin Song <[email protected]>
Why support for both with and without BLK? Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170410/f655978c/attachment.sig>
RFC 1/2 NVMe: add NVMe driver support
Hi Tom,
As I know, the CONFIG_BLK is not supported on some platforms' defconfig (# CONFIG_BLK is not set), such as the fsl-qoriq platform. I find when 'CONFIG_BLK=y', then 'fsl-esdhc-mmc' device can't work normally.
So, in order to make sure the NVMe driver is available on all the platforms, I support for both with and without BLK.
Thank you!
Best regards,
Zhikang Zhang
-----Original Message-----
From: Tom Rini [mailto:trini at konsulko.com]
Sent: Tuesday, April 11, 2017 5:49 AM
To: Z.K. Zhang <[email protected]>
Cc: york sun <[email protected]>; u-boot at lists.denx.de; Wenbin Song <[email protected]>
Subject: Re: [U-Boot] [RFC, 1/2] NVMe: add NVMe driver support
Quoted 7 lines · Zhikang Zhang
Add Support of devices that follow the NVM Express standard
basic functions:
nvme init/scan
nvme info - show the basic information of device nvme Read/Write
Quoted 8 lines
driver model:
Use block device(CONFIG_BLK)'s structure to support nvme's DM. UseUCLASS_PCIas a parent uclass.The driver code heavily copy from the NVMe driver code in Linux Kernel.
Signed-off-by Zhikang Zhang <[email protected]>Signed-off-by Wenbin Song <[email protected]>
Why support for both with and without BLK? Thanks!
Signature · 1 line
Tom
RFC 1/2 NVMe: add NVMe driver support
Quoted 8 lines · Z.K. Zhang
Hi Tom,
As I know, the
CONFIG_BLKis not supported on some platforms' defconfig (#CONFIG_BLKis not set), such as the fsl-qoriq platform. I find when 'CONFIG_BLK=y', then 'fsl-esdhc-mmc' device can't work normally.So, in order to make sure the NVMe driver is available on all the platforms, I support for both with and without BLK.
But shouldn't the other platforms be updated as well?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170411/79d576d9/attachment.sig>
RFC 1/2 NVMe: add NVMe driver support
Hi Tom,
Do you mean I should only support BLK?
Thank you!
Best regards,
Zhikang Zhang
-----Original Message-----
From: Tom Rini [mailto:trini at konsulko.com]
Sent: Tuesday, April 11, 2017 9:18 PM
To: Z.K. Zhang <[email protected]>
Cc: york sun <[email protected]>; u-boot at lists.denx.de; Wenbin Song <[email protected]>
Subject: Re: [U-Boot] [RFC, 1/2] NVMe: add NVMe driver support
Quoted 8 lines · Z.K. Zhang
Hi Tom,
As I know, the
CONFIG_BLKis not supported on some platforms' defconfig (#CONFIG_BLKis not set), such as the fsl-qoriq platform. I find when 'CONFIG_BLK=y', then 'fsl-esdhc-mmc' device can't work normally.So, in order to make sure the NVMe driver is available on all the platforms, I support for both with and without BLK.
But shouldn't the other platforms be updated as well?
--
Tom
RFC 1/2 NVMe: add NVMe driver support
Quoted 3 lines · Z.K. Zhang
Hi Tom,
Do you mean I should only support BLK?
Yes, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170413/5286a376/attachment.sig>