mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
libnvdimm, nfit: initial libnvdimm infrastructure and NFIT support
A struct nvdimm_bus is the anchor device for registering nvdimm resources and interfaces, for example, a character control device, nvdimm devices, and I/O region devices. The ACPI NFIT (NVDIMM Firmware Interface Table) is one possible platform description for such non-volatile memory resources in a system. The nfit.ko driver attaches to the "ACPI0012" device that indicates the presence of the NFIT and parses the table to register a struct nvdimm_bus instance. Cc: <[email protected]> Cc: Lv Zheng <[email protected]> Cc: Robert Moore <[email protected]> Cc: Rafael J. Wysocki <[email protected]> Acked-by: Jeff Moyer <[email protected]> Acked-by: Christoph Hellwig <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Tested-by: Toshi Kani <[email protected]> Signed-off-by: Dan Williams <[email protected]>
This commit is contained in:
parent
ad5fb870c4
commit
b94d5230d0
11 changed files with 733 additions and 0 deletions
15
drivers/nvdimm/Kconfig
Normal file
15
drivers/nvdimm/Kconfig
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
config LIBNVDIMM
|
||||
tristate "NVDIMM (Non-Volatile Memory Device) Support"
|
||||
depends on PHYS_ADDR_T_64BIT
|
||||
depends on BLK_DEV
|
||||
help
|
||||
Generic support for non-volatile memory devices including
|
||||
ACPI-6-NFIT defined resources. On platforms that define an
|
||||
NFIT, or otherwise can discover NVDIMM resources, a libnvdimm
|
||||
bus is registered to advertise PMEM (persistent memory)
|
||||
namespaces (/dev/pmemX) and BLK (sliding mmio window(s))
|
||||
namespaces (/dev/ndX). A PMEM namespace refers to a memory
|
||||
resource that may span multiple DIMMs and support DAX (see
|
||||
CONFIG_DAX). A BLK namespace refers to an NVDIMM control
|
||||
region which exposes an mmio register set for windowed
|
||||
access mode to non-volatile memory.
|
||||
3
drivers/nvdimm/Makefile
Normal file
3
drivers/nvdimm/Makefile
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
obj-$(CONFIG_LIBNVDIMM) += libnvdimm.o
|
||||
|
||||
libnvdimm-y := core.o
|
||||
69
drivers/nvdimm/core.c
Normal file
69
drivers/nvdimm/core.c
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*/
|
||||
#include <linux/libnvdimm.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/slab.h>
|
||||
#include "nd-core.h"
|
||||
|
||||
static DEFINE_IDA(nd_ida);
|
||||
|
||||
static void nvdimm_bus_release(struct device *dev)
|
||||
{
|
||||
struct nvdimm_bus *nvdimm_bus;
|
||||
|
||||
nvdimm_bus = container_of(dev, struct nvdimm_bus, dev);
|
||||
ida_simple_remove(&nd_ida, nvdimm_bus->id);
|
||||
kfree(nvdimm_bus);
|
||||
}
|
||||
|
||||
struct nvdimm_bus *nvdimm_bus_register(struct device *parent,
|
||||
struct nvdimm_bus_descriptor *nd_desc)
|
||||
{
|
||||
struct nvdimm_bus *nvdimm_bus;
|
||||
int rc;
|
||||
|
||||
nvdimm_bus = kzalloc(sizeof(*nvdimm_bus), GFP_KERNEL);
|
||||
if (!nvdimm_bus)
|
||||
return NULL;
|
||||
nvdimm_bus->id = ida_simple_get(&nd_ida, 0, 0, GFP_KERNEL);
|
||||
if (nvdimm_bus->id < 0) {
|
||||
kfree(nvdimm_bus);
|
||||
return NULL;
|
||||
}
|
||||
nvdimm_bus->nd_desc = nd_desc;
|
||||
nvdimm_bus->dev.parent = parent;
|
||||
nvdimm_bus->dev.release = nvdimm_bus_release;
|
||||
dev_set_name(&nvdimm_bus->dev, "ndbus%d", nvdimm_bus->id);
|
||||
rc = device_register(&nvdimm_bus->dev);
|
||||
if (rc) {
|
||||
dev_dbg(&nvdimm_bus->dev, "registration failed: %d\n", rc);
|
||||
put_device(&nvdimm_bus->dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return nvdimm_bus;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nvdimm_bus_register);
|
||||
|
||||
void nvdimm_bus_unregister(struct nvdimm_bus *nvdimm_bus)
|
||||
{
|
||||
if (!nvdimm_bus)
|
||||
return;
|
||||
device_unregister(&nvdimm_bus->dev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nvdimm_bus_unregister);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_AUTHOR("Intel Corporation");
|
||||
23
drivers/nvdimm/nd-core.h
Normal file
23
drivers/nvdimm/nd-core.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*/
|
||||
#ifndef __ND_CORE_H__
|
||||
#define __ND_CORE_H__
|
||||
#include <linux/libnvdimm.h>
|
||||
#include <linux/device.h>
|
||||
|
||||
struct nvdimm_bus {
|
||||
struct nvdimm_bus_descriptor *nd_desc;
|
||||
struct device dev;
|
||||
int id;
|
||||
};
|
||||
#endif /* __ND_CORE_H__ */
|
||||
Loading…
Reference in a new issue