blob: 5f60fb884fb634db4a77d7a7c37f9bd7f212b87c [file] [log] [blame]
Mark Kettenisf8463d62022-01-22 20:38:11 +01001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2017 NXP Semiconductors
4 * Copyright (C) 2017 Bin Meng <bmeng.cn@gmail.com>
5 */
6
7#include <common.h>
8#include <dm.h>
9#include <pci.h>
10#include "nvme.h"
11
12static int nvme_bind(struct udevice *udev)
13{
14 static int ndev_num;
15 char name[20];
16
17 sprintf(name, "nvme#%d", ndev_num++);
18
19 return device_set_name(udev, name);
20}
21
22static int nvme_probe(struct udevice *udev)
23{
24 struct nvme_dev *ndev = dev_get_priv(udev);
25 struct pci_child_plat *pplat;
26
27 pplat = dev_get_parent_plat(udev);
28 sprintf(ndev->vendor, "0x%.4x", pplat->vendor);
29
30 ndev->instance = trailing_strtol(udev->name);
31 ndev->bar = dm_pci_map_bar(udev, PCI_BASE_ADDRESS_0,
32 PCI_REGION_MEM);
33 return nvme_init(udev);
34}
35
36U_BOOT_DRIVER(nvme) = {
37 .name = "nvme",
38 .id = UCLASS_NVME,
39 .bind = nvme_bind,
40 .probe = nvme_probe,
41 .priv_auto = sizeof(struct nvme_dev),
42};
43
44struct pci_device_id nvme_supported[] = {
45 { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, ~0) },
46 {}
47};
48
49U_BOOT_PCI_DEVICE(nvme, nvme_supported);