u-boot/drivers/misc
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
..
imx8 cmd: bind: Fix driver binding on a device 2021-10-12 14:19:52 +02:00
imx8ulp i.MX8ULP: add display_ele_fw_version api 2022-05-20 12:36:47 +02:00
ali512x.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
altera_sysid.c dm: Use access methods for dev/uclass private data 2021-01-05 12:24:40 -07:00
atsha204a-i2c.c misc: atsha204a: Add support for atsha204 chip 2022-05-10 06:48:05 +02:00
cbmem_console.c x86: Make coreboot sysinfo available to any x86 board 2021-03-27 13:59:37 +13:00
cros_ec.c doc: replace @return by Return: 2022-01-19 18:11:34 +01:00
cros_ec_i2c.c dm: treewide: Rename 'platdata' variables to just 'plat' 2020-12-13 16:51:08 -07:00
cros_ec_lpc.c doc: replace @return by Return: 2022-01-19 18:11:34 +01:00
cros_ec_sandbox.c doc: replace @return by Return: 2022-01-19 18:11:34 +01:00
cros_ec_spi.c doc: replace @return by Return: 2022-01-19 18:11:34 +01:00
ds4510.c global: Convert simple_strtoul() with hex to hextoul() 2021-08-02 13:32:14 -04:00
ds4510.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
esm_pmic.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
fs_loader.c misc: fs_loader: Fix compile warnings when CONFIG_CMD_UBIFS is enabled 2022-05-05 19:37:11 -04:00
fsl_devdis.c WS cleanup: remove trailing empty lines 2021-09-30 08:08:56 -04:00
fsl_ifc.c common: Drop part.h from common header 2020-05-18 17:33:33 -04:00
fsl_iim.c common: Drop linux/delay.h from common header 2020-05-18 21:19:23 -04:00
fsl_portals.c fdt_support: Add fdt_for_each_node_by_compatible() helper macro 2022-01-20 11:35:29 +01:00
fsl_sec_mon.c common: Drop linux/delay.h from common header 2020-05-18 21:19:23 -04:00
gdsys_ioep.c dm: treewide: Rename auto_alloc_size members to be shorter 2020-12-13 08:00:25 -07:00
gdsys_ioep.h common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
gdsys_rxaui_ctrl.c dm: treewide: Rename auto_alloc_size members to be shorter 2020-12-13 08:00:25 -07:00
gdsys_soc.c dm: treewide: Rename auto_alloc_size members to be shorter 2020-12-13 08:00:25 -07:00
gdsys_soc.h misc: Add gdsys_soc driver 2018-11-14 09:16:27 -08:00
gpio_led.c status_led: Kconfig migration 2017-01-21 15:12:33 -05:00
gsc.c drivers: misc: add Gateworks System Controller driver 2022-04-12 15:36:17 +02:00
i2c_eeprom.c misc: i2c_eeprom: Make i2c_eeprom_write use a const buf 2022-06-08 13:59:53 -04:00
i2c_eeprom_emul.c dm: treewide: Rename ofdata_to_platdata() to of_to_plat() 2020-12-13 16:51:09 -07:00
ihs_fpga.c dm: treewide: Rename auto_alloc_size members to be shorter 2020-12-13 08:00:25 -07:00
ihs_fpga.h misc: Add IHS FPGA driver 2018-11-14 09:16:27 -08:00
irq-uclass.c treewide: invaild -> invalid 2022-01-13 07:57:49 -05:00
irq_sandbox.c irq: Tidy up of-platdata irq support 2021-09-25 09:46:15 -06:00
irq_sandbox_test.c irq: Tidy up of-platdata irq support 2021-09-25 09:46:15 -06:00
jz4780_efuse.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
k3_avs.c dm: treewide: Rename auto_alloc_size members to be shorter 2020-12-13 08:00:25 -07:00
k3_esm.c misc: k3_esm: Add functionality to set and route error events within K3SoC 2022-04-04 19:02:04 -04:00
Kconfig misc: Add support for nvmem cells 2022-06-08 14:00:22 -04:00
Makefile misc: Add support for nvmem cells 2022-06-08 14:00:22 -04:00
mc9sdz60.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
microchip_flexcom.c dm: treewide: Rename ..._platdata variables to just ..._plat 2020-12-13 16:51:09 -07:00
misc-uclass.c misc: mark write buffer const 2022-01-24 10:35:10 -05:00
misc_sandbox.c dm: treewide: Rename auto_alloc_size members to be shorter 2020-12-13 08:00:25 -07:00
mpc83xx_serdes.c dm: treewide: Rename auto_alloc_size members to be shorter 2020-12-13 08:00:25 -07:00
mpc83xx_serdes.h common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
mxc_ocotp.c Fix URLs to old freescale git repos 2022-03-28 08:22:17 -04:00
mxs_ocotp.c common: Drop linux/delay.h from common header 2020-05-18 21:19:23 -04:00
nuvoton_nct6102d.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
nvmem.c misc: Add support for nvmem cells 2022-06-08 14:00:22 -04:00
p2sb-uclass.c treewide: Try to avoid the preprocessor with OF_REAL 2021-09-25 09:46:15 -06:00
p2sb_emul.c x86: p2sb: Drop LOG_DEBUG 2021-03-27 13:59:36 +13:00
p2sb_sandbox.c dm: treewide: Rename auto_alloc_size members to be shorter 2020-12-13 08:00:25 -07:00
pca9551_led.c common: Drop global inclusion of status_led.h 2019-12-02 18:23:06 -05:00
pwrseq-uclass.c dm: define LOG_CATEGORY for all uclass 2021-07-06 10:38:03 -06:00
qfw.c Remove duplication of table_compute_checksum function 2022-04-14 15:39:15 -04:00
qfw_mmio.c qemu: add MMIO driver for QFW 2021-04-12 17:45:40 -04:00
qfw_pio.c x86: qemu: move QFW to its own uclass 2021-04-12 17:44:55 -04:00
qfw_sandbox.c test: qemu: add qfw sandbox driver, dm tests, qemu tests 2021-04-12 17:45:39 -04:00
rockchip-efuse.c dm: Rename DM_GET_DRIVER() to DM_DRIVER_GET() 2021-01-05 12:26:35 -07:00
rockchip-otp.c dm: treewide: Rename ..._platdata variables to just ..._plat 2020-12-13 16:51:09 -07:00
sandbox_adder.c dm: treewide: Rename ..._platdata variables to just ..._plat 2020-12-13 16:51:09 -07:00
sifive-otp.c dm: treewide: Rename ..._platdata variables to just ..._plat 2020-12-13 16:51:09 -07:00
sl28cpld.c misc: add sl28cpld base driver 2022-02-28 11:59:35 +05:30
smsc_lpc47m.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
smsc_sio1007.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
spltest_sandbox.c sandbox: Add a compatible string for spltest 2021-01-05 12:24:41 -07:00
status_led.c status_led: Tidy up the code style 2019-12-02 18:23:06 -05:00
stm32_rcc.c misc: rcc: keep the rcc device name for subnode 2021-01-13 09:52:58 +01:00
stm32mp_fuse.c dm: Rename DM_GET_DRIVER() to DM_DRIVER_GET() 2021-01-05 12:26:35 -07:00
swap_case.c pci: swap_case: Allow compilation on 32-bit machines 2021-07-28 19:30:22 -04:00
syscon_sandbox.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
tegra186_bpmp.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
tegra_car.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
test_drv.c dtoc: Generate device instances 2021-03-22 19:23:27 +13:00
twl4030_led.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
vexpress_config.c dm: Use access methods for dev/uclass private data 2021-01-05 12:24:40 -07:00
winbond_w83627.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00