forked from torvalds/linux
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nvmem: layouts: add fixed cells layout
This adds a driver for the "fixed-layout" NVMEM layout binding. It allows defining NVMEM cells in a layout DT node named "nvmem-layout". Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
- Loading branch information
1 parent
70d21b7
commit 7ffae9a
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
|
||
#include <linux/module.h> | ||
#include <linux/nvmem-consumer.h> | ||
#include <linux/nvmem-provider.h> | ||
#include <linux/of.h> | ||
|
||
static int fixed_add_cells(struct device *dev, struct nvmem_device *nvmem, | ||
struct nvmem_layout *layout) | ||
{ | ||
struct device_node *layout_np; | ||
int err; | ||
|
||
layout_np = of_nvmem_layout_get_container(nvmem); | ||
if (!layout_np) | ||
return -ENOENT; | ||
|
||
err = nvmem_add_cells_from_of(nvmem, layout_np); | ||
|
||
of_node_put(layout_np); | ||
|
||
return err; | ||
} | ||
|
||
static const struct of_device_id fixed_of_match_table[] = { | ||
{ .compatible = "fixed-layout" }, | ||
{}, | ||
}; | ||
MODULE_DEVICE_TABLE(of, fixed_of_match_table); | ||
|
||
struct nvmem_layout fixed_nvmem_layout = { | ||
.name = "fixed-layout", | ||
.of_match_table = fixed_of_match_table, | ||
.add_cells = fixed_add_cells, | ||
}; | ||
|
||
module_nvmem_layout_driver(fixed_nvmem_layout); | ||
|
||
MODULE_AUTHOR("Rafał Miłecki"); | ||
MODULE_LICENSE("GPL"); | ||
MODULE_DEVICE_TABLE(of, fixed_of_match_table); |