[PATCH 09/14] misc: i2c_eeprom: Implement nvmem interface

Sean Anderson sean.anderson at seco.com
Tue Feb 8 00:42:07 CET 2022


This adds nvmem support for i2c eeproms.

Signed-off-by: Sean Anderson <sean.anderson at seco.com>
---

 drivers/misc/i2c_eeprom.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/misc/i2c_eeprom.c b/drivers/misc/i2c_eeprom.c
index 4302e180ac..ae18dca1bf 100644
--- a/drivers/misc/i2c_eeprom.c
+++ b/drivers/misc/i2c_eeprom.c
@@ -14,6 +14,7 @@
 #include <dm/device-internal.h>
 #include <i2c.h>
 #include <i2c_eeprom.h>
+#include <nvmem.h>
 
 struct i2c_eeprom_drv_data {
 	u32 size; /* size in bytes */
@@ -378,3 +379,21 @@ UCLASS_DRIVER(i2c_eeprom) = {
 	.id		= UCLASS_I2C_EEPROM,
 	.name		= "i2c_eeprom",
 };
+
+static int i2c_eeprom_nvmem_read(struct udevice *dev, unsigned int offset,
+				 void *buf, size_t size)
+{
+	return i2c_eeprom_read(dev, offset, buf, size);
+}
+
+static int i2c_eeprom_nvmem_write(struct udevice *dev, unsigned int offset,
+				  const void *buf, size_t size)
+{
+	return i2c_eeprom_write(dev, offset, buf, size);
+}
+
+NVMEM_INTERFACE(i2c_eeprom) = {
+	.id = UCLASS_I2C_EEPROM,
+	.read = i2c_eeprom_nvmem_read,
+	.write = i2c_eeprom_nvmem_write,
+};
-- 
2.25.1



More information about the U-Boot mailing list