| 1 | |
| 2 | |
| 3 | * Copyright 2026 Bootlin
|
| 4 | *
|
| 5 | * Authors: Mathieu Dubois-Briand <[email protected]>
|
| 6 |
|
| 7 |
|
| 8 | #include <linux/nvmem-provider.h>
|
| 9 | #include <linux/of.h>
|
| 10 |
|
| 11 | #include "../internals.h"
|
| 12 |
|
| 13 | static int fixed_layout_add_cells(struct nvmem_layout *layout)
|
| 14 | {
|
| 15 | struct device_node *np;
|
| 16 | int ret;
|
| 17 |
|
| 18 | np = of_nvmem_layout_get_container(layout->nvmem);
|
| 19 | if (!np)
|
| 20 | return -ENOENT;
|
| 21 |
|
| 22 | ret = nvmem_add_cells_from_dt(layout->nvmem, np);
|
| 23 | of_node_put(np);
|
| 24 |
|
| 25 | return ret;
|
| 26 | }
|
| 27 |
|
| 28 | static int fixed_layout_probe(struct nvmem_layout *layout)
|
| 29 | {
|
| 30 | layout->add_cells = fixed_layout_add_cells;
|
| 31 |
|
| 32 | return nvmem_layout_register(layout);
|
| 33 | }
|
| 34 |
|
| 35 | static void fixed_layout_remove(struct nvmem_layout *layout)
|
| 36 | {
|
| 37 | nvmem_layout_unregister(layout);
|
| 38 | }
|
| 39 |
|
| 40 | static const struct of_device_id fixed_layout_of_match_table[] = {
|
| 41 | { .compatible = "fixed-layout", },
|
| 42 | {},
|
| 43 | };
|
| 44 |
|
| 45 | static struct nvmem_layout_driver fixed_layout_layout = {
|
| 46 | .driver = {
|
| 47 | .name = "fixed-layout",
|
| 48 | .of_match_table = fixed_layout_of_match_table,
|
| 49 | },
|
| 50 | .probe = fixed_layout_probe,
|
| 51 | .remove = fixed_layout_remove,
|
| 52 | };
|
| 53 | module_nvmem_layout_driver(fixed_layout_layout);
|
| 54 |
|
| 55 | MODULE_AUTHOR("Mathieu Dubois-Briand");
|
| 56 | MODULE_LICENSE("GPL");
|
| 57 | MODULE_DEVICE_TABLE(of, fixed_layout_of_match_table);
|
| 58 | MODULE_DESCRIPTION("NVMEM fixed-layout driver");
|