Lines Matching +full:nvmem +full:- +full:layout

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2022 - 2023 Rafał Miłecki <rafal@milecki.pl>
10 #include <linux/nvmem-consumer.h>
11 #include <linux/nvmem-provider.h>
15 #include "u-boot-env.h"
40 if (bytes != 3 * ETH_ALEN - 1) in u_boot_env_read_post_process_ethaddr()
41 return -EINVAL; in u_boot_env_read_post_process_ethaddr()
44 return -EINVAL; in u_boot_env_read_post_process_ethaddr()
54 static int u_boot_env_parse_cells(struct device *dev, struct nvmem_device *nvmem, uint8_t *buf, in u_boot_env_parse_cells() argument
73 return -ENOMEM; in u_boot_env_parse_cells()
74 info.offset = data_offset + value - data; in u_boot_env_parse_cells()
76 info.np = of_get_child_by_name(dev->of_node, info.name); in u_boot_env_parse_cells()
83 nvmem_add_one_cell(nvmem, &info); in u_boot_env_parse_cells()
89 int u_boot_env_parse(struct device *dev, struct nvmem_device *nvmem, in u_boot_env_parse() argument
105 dev_size = nvmem_dev_size(nvmem); in u_boot_env_parse()
109 err = -ENOMEM; in u_boot_env_parse()
113 bytes = nvmem_device_read(nvmem, 0, dev_size, buf); in u_boot_env_parse()
118 err = -EIO; in u_boot_env_parse()
141 dev_err(dev, "Device too small for u-boot-env\n"); in u_boot_env_parse()
142 err = -EIO; in u_boot_env_parse()
148 crc32_data_len = dev_size - crc32_data_offset; in u_boot_env_parse()
149 data_len = dev_size - data_offset; in u_boot_env_parse()
154 err = -EINVAL; in u_boot_env_parse()
158 buf[dev_size - 1] = '\0'; in u_boot_env_parse()
159 err = u_boot_env_parse_cells(dev, nvmem, buf, data_offset, data_len); in u_boot_env_parse()
168 static int u_boot_env_add_cells(struct nvmem_layout *layout) in u_boot_env_add_cells() argument
170 struct device *dev = &layout->dev; in u_boot_env_add_cells()
175 return u_boot_env_parse(dev, layout->nvmem, format); in u_boot_env_add_cells()
178 static int u_boot_env_probe(struct nvmem_layout *layout) in u_boot_env_probe() argument
180 layout->add_cells = u_boot_env_add_cells; in u_boot_env_probe()
182 return nvmem_layout_register(layout); in u_boot_env_probe()
185 static void u_boot_env_remove(struct nvmem_layout *layout) in u_boot_env_remove() argument
187 nvmem_layout_unregister(layout); in u_boot_env_remove()
191 { .compatible = "u-boot,env", .data = (void *)U_BOOT_FORMAT_SINGLE, },
192 { .compatible = "u-boot,env-redundant-bool", .data = (void *)U_BOOT_FORMAT_REDUNDANT, },
193 { .compatible = "u-boot,env-redundant-count", .data = (void *)U_BOOT_FORMAT_REDUNDANT, },
200 .name = "u-boot-env-layout",
211 MODULE_DESCRIPTION("NVMEM layout driver for U-Boot environment variables");