]> git.ipfire.org Git - people/ms/u-boot.git/blob - drivers/nvme/nvme-uclass.c
Merge git://git.denx.de/u-boot-marvell
[people/ms/u-boot.git] / drivers / nvme / nvme-uclass.c
1 /*
2 * Copyright (C) 2017 NXP Semiconductors
3 * Copyright (C) 2017 Bin Meng <bmeng.cn@gmail.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8 #include <common.h>
9 #include <errno.h>
10 #include <dm.h>
11 #include <dm/device.h>
12 #include "nvme.h"
13
14 static int nvme_uclass_post_probe(struct udevice *udev)
15 {
16 char name[20];
17 struct udevice *ns_udev;
18 int i, ret;
19 struct nvme_dev *ndev = dev_get_priv(udev);
20
21 /* Create a blk device for each namespace */
22 for (i = 0; i < ndev->nn; i++) {
23 /*
24 * Encode the namespace id to the device name so that
25 * we can extract it when doing the probe.
26 */
27 sprintf(name, "blk#%d", i);
28
29 /* The real blksz and size will be set by nvme_blk_probe() */
30 ret = blk_create_devicef(udev, "nvme-blk", name, IF_TYPE_NVME,
31 -1, 512, 0, &ns_udev);
32 if (ret)
33 return ret;
34 }
35
36 return 0;
37 }
38
39 UCLASS_DRIVER(nvme) = {
40 .name = "nvme",
41 .id = UCLASS_NVME,
42 .post_probe = nvme_uclass_post_probe,
43 };