u-boot/doc/api
Sean Anderson c8ce7ba87d misc: Add support for nvmem cells
This adds support for "nvmem cells" as seen in Linux. The nvmem device
class in Linux is used for various assorted ROMs and EEPROMs. In this
sense, it is similar to UCLASS_MISC, but also includes
UCLASS_I2C_EEPROM, UCLASS_RTC, and UCLASS_MTD. New drivers corresponding
to a Linux-style nvmem device should be implemented as one of the
previously-mentioned uclasses. The nvmem API acts as a compatibility
layer to adapt the (slightly different) APIs of these uclasses. It also
handles the lookup of nvmem cells.

While nvmem devices can be accessed directly, they are most often used
by reading/writing contiguous values called "cells". Cells typically
hold information like calibration, versions, or configuration (such as
mac addresses).

nvmem devices can specify "cells" in their device tree:

	qfprom: eeprom@700000 {
		#address-cells = <1>;
		#size-cells = <1>;
		reg = <0x00700000 0x100000>;

		/* ... */

		tsens_calibration: calib@404 {
			reg = <0x404 0x10>;
		};
	};

which can then be referenced like:

	tsens {
		/* ... */
		nvmem-cells = <&tsens_calibration>;
		nvmem-cell-names = "calibration";
	};

The tsens driver could then read the calibration value like:

	struct nvmem_cell cal_cell;
	u8 cal[16];
	nvmem_cell_get_by_name(dev, "calibration", &cal_cell);
	nvmem_cell_read(&cal_cell, cal, sizeof(cal));

Because nvmem devices are not all of the same uclass, supported uclasses
must register a nvmem_interface struct. This allows CONFIG_NVMEM to be
enabled without depending on specific uclasses. At the moment,
nvmem_interface is very bare-bones, and assumes that no initialization
is necessary. However, this could be amended in the future.

Although I2C_EEPROM and MISC are quite similar (and could likely be
unified), they present different read/write function signatures. To
abstract over this, NVMEM uses the same read/write signature as Linux.
In particular, short read/writes are not allowed, which is allowed by
MISC.

The functionality implemented by nvmem cells is very similar to that
provided by i2c_eeprom_partition. "fixed-partition"s for eeproms does
not seem to have made its way into Linux or into any device tree other
than sandbox. It is possible that with the introduction of this API it
would be possible to remove it.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2022-06-08 14:00:22 -04:00
..
clk.rst clk: Add driver API to HTML docs 2022-02-25 01:41:04 -05:00
dfu.rst doc: dfu: add DFU to HTML documentation 2020-05-25 11:54:53 -04:00
dm.rst doc: add include/dm/fdtaddr.h to the HTML documentation 2022-01-15 10:57:21 +01:00
efi.rst doc/efi: add firmware management protocol to the documentation 2022-05-28 10:59:27 +02:00
getopt.rst lib: Add getopt 2020-10-30 10:56:11 -04:00
index.rst misc: Add support for nvmem cells 2022-06-08 14:00:22 -04:00
linker_lists.rst linker_lists: Fix alignment issue 2020-12-18 20:32:21 -07:00
lmb.rst doc: add include/lmb.h to the HTML documentation 2021-11-20 10:53:00 +01:00
logging.rst doc: fix doc/develop/logging.rst 2021-01-27 12:52:57 +01:00
nvmem.rst misc: Add support for nvmem cells 2022-06-08 14:00:22 -04:00
pinctrl.rst pinctrl: Reformat documentation in dm/pinctrl.h 2020-10-08 11:42:36 -04:00
rng.rst doc: random number generation 2020-06-14 21:07:20 +02:00
sandbox.rst doc: add sandbox API 2020-11-05 09:11:31 -07:00
serial.rst doc: Move existing rst files into api sub-directory 2019-07-24 10:07:24 -04:00
sysreset.rst doc: add system reset to API documentation 2021-10-21 03:46:03 +02:00
timer.rst doc: Document timer API 2020-10-22 09:54:53 -04:00
unicode.rst doc: add Unicode functions to API description 2020-05-09 09:30:28 +02:00