]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: Add a simple EEPROM driver
authorSimon Glass <sjg@chromium.org>
Wed, 10 Dec 2014 15:55:54 +0000 (08:55 -0700)
committerSimon Glass <sjg@chromium.org>
Thu, 11 Dec 2014 20:18:43 +0000 (13:18 -0700)
There seem to be a few EEPROM drivers around - perhaps we should have a
single standard one? This simple driver is used for sandbox testing, but
could be pressed into more active service.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
drivers/misc/Makefile
drivers/misc/i2c_eeprom.c [new file with mode: 0644]
include/dm/uclass-id.h
include/i2c_eeprom.h [new file with mode: 0644]

index ff0218489a47f683b67b2006d5f5f5b6847dca89..6fa836f2063c257fb1e267170c7043138f9dbad3 100644 (file)
@@ -15,6 +15,7 @@ obj-$(CONFIG_CROS_EC_SANDBOX) += cros_ec_sandbox.o
 obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o
 obj-$(CONFIG_FSL_IIM) += fsl_iim.o
 obj-$(CONFIG_GPIO_LED) += gpio_led.o
+obj-$(CONFIG_I2C_EEPROM) += i2c_eeprom.o
 obj-$(CONFIG_FSL_MC9SDZ60) += mc9sdz60.o
 obj-$(CONFIG_MXC_OCOTP) += mxc_ocotp.o
 obj-$(CONFIG_MXS_OCOTP) += mxs_ocotp.o
diff --git a/drivers/misc/i2c_eeprom.c b/drivers/misc/i2c_eeprom.c
new file mode 100644 (file)
index 0000000..d0548ec
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <i2c.h>
+#include <i2c_eeprom.h>
+
+static int i2c_eeprom_read(struct udevice *dev, int offset, uint8_t *buf,
+                          int size)
+{
+       return -ENODEV;
+}
+
+static int i2c_eeprom_write(struct udevice *dev, int offset,
+                           const uint8_t *buf, int size)
+{
+       return -ENODEV;
+}
+
+struct i2c_eeprom_ops i2c_eeprom_std_ops = {
+       .read   = i2c_eeprom_read,
+       .write  = i2c_eeprom_write,
+};
+
+int i2c_eeprom_std_probe(struct udevice *dev)
+{
+       return 0;
+}
+
+static const struct udevice_id i2c_eeprom_std_ids[] = {
+       { .compatible = "i2c-eeprom" },
+       { }
+};
+
+U_BOOT_DRIVER(i2c_eeprom_std) = {
+       .name           = "i2c_eeprom",
+       .id             = UCLASS_I2C_EEPROM,
+       .of_match       = i2c_eeprom_std_ids,
+       .probe          = i2c_eeprom_std_probe,
+       .priv_auto_alloc_size = sizeof(struct i2c_eeprom),
+       .ops            = &i2c_eeprom_std_ops,
+};
+
+UCLASS_DRIVER(i2c_eeprom) = {
+       .id             = UCLASS_I2C_EEPROM,
+       .name           = "i2c_eeprom",
+};
index 16e4224c1641381570dab6ee43accb753e22f853..f17c3c2b384dfc8aa782583fa0734cb31a77d222 100644 (file)
@@ -32,6 +32,7 @@ enum uclass_id {
        UCLASS_THERMAL,         /* Thermal sensor */
        UCLASS_I2C,             /* I2C bus */
        UCLASS_I2C_GENERIC,     /* Generic I2C device */
+       UCLASS_I2C_EEPROM,      /* I2C EEPROM device */
 
        UCLASS_COUNT,
        UCLASS_INVALID = -1,
diff --git a/include/i2c_eeprom.h b/include/i2c_eeprom.h
new file mode 100644 (file)
index 0000000..ea6c962
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __I2C_EEPROM
+#define __I2C_EEPROM
+
+struct i2c_eeprom_ops {
+       int (*read)(struct udevice *dev, int offset, uint8_t *buf, int size);
+       int (*write)(struct udevice *dev, int offset, const uint8_t *buf,
+                    int size);
+};
+
+struct i2c_eeprom {
+};
+
+#endif