[PATCH u-boot, v2019.04-aspeed-openbmc 05/12] common: Move old EEPROM functions into a new header

Tan Siewert tan.siewert at hetzner.com
Fri Jan 17 20:44:24 AEDT 2025


From: Simon Glass <sjg at chromium.org>

These functions do not use driver model but are still used. Move them to a
new eeprom.h header file.

Signed-off-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Tom Rini <trini at konsulko.com>
(cherry picked from commit cb3ef6810a27c8ddf5db8694bcef9337f27d12ce)
Signed-off-by: Tan Siewert <tan.siewert at hetzner.com>
---
 board/atmel/common/mac_eeprom.c               |  1 +
 board/compulab/common/eeprom.c                |  1 +
 board/corscience/tricorder/tricorder-eeprom.c |  1 +
 board/dhelectronics/dh_imx6/dh_imx6.c         |  1 +
 board/freescale/mpc8323erdb/mpc8323erdb.c     |  1 +
 board/kosagi/novena/novena.c                  |  1 +
 board/phytec/phycore_rk3288/phycore-rk3288.c  |  1 +
 board/rockchip/tinker_rk3288/tinker-rk3288.c  |  1 +
 board/samtec/vining_fpga/socfpga.c            |  1 +
 board/ti/am43xx/board.c                       |  1 +
 board/ti/ks2_evm/board_k2g.c                  |  1 +
 cmd/eeprom.c                                  |  1 +
 drivers/misc/i2c_eeprom.c                     |  1 +
 drivers/mtd/mw_eeprom.c                       |  1 +
 drivers/rtc/rv3029.c                          |  1 +
 env/eeprom.c                                  |  1 +
 include/common.h                              | 15 ------------
 include/eeprom.h                              | 24 +++++++++++++++++++
 18 files changed, 40 insertions(+), 15 deletions(-)
 create mode 100644 include/eeprom.h

diff --git a/board/atmel/common/mac_eeprom.c b/board/atmel/common/mac_eeprom.c
index 7ff1ec7462f..5a4e45793a0 100644
--- a/board/atmel/common/mac_eeprom.c
+++ b/board/atmel/common/mac_eeprom.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <eeprom.h>
 #include <environment.h>
 #include <i2c_eeprom.h>
 #include <netdev.h>
diff --git a/board/compulab/common/eeprom.c b/board/compulab/common/eeprom.c
index a2e386f67de..1e21edcd5a8 100644
--- a/board/compulab/common/eeprom.c
+++ b/board/compulab/common/eeprom.c
@@ -7,6 +7,7 @@
  */
 
 #include <common.h>
+#include <eeprom.h>
 #include <i2c.h>
 #include <eeprom_layout.h>
 #include <eeprom_field.h>
diff --git a/board/corscience/tricorder/tricorder-eeprom.c b/board/corscience/tricorder/tricorder-eeprom.c
index 16bceea7ba7..46e9119d66e 100644
--- a/board/corscience/tricorder/tricorder-eeprom.c
+++ b/board/corscience/tricorder/tricorder-eeprom.c
@@ -5,6 +5,7 @@
  * Andreas Bießmann <andreas.biessmann at corscience.de>
  */
 #include <common.h>
+#include <eeprom.h>
 #include <i2c.h>
 
 #include "tricorder-eeprom.h"
diff --git a/board/dhelectronics/dh_imx6/dh_imx6.c b/board/dhelectronics/dh_imx6/dh_imx6.c
index f9ac5c10e1d..2457b9b0e51 100644
--- a/board/dhelectronics/dh_imx6/dh_imx6.c
+++ b/board/dhelectronics/dh_imx6/dh_imx6.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <eeprom.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/imx-regs.h>
diff --git a/board/freescale/mpc8323erdb/mpc8323erdb.c b/board/freescale/mpc8323erdb/mpc8323erdb.c
index 772688186b5..276e8cb3ef9 100644
--- a/board/freescale/mpc8323erdb/mpc8323erdb.c
+++ b/board/freescale/mpc8323erdb/mpc8323erdb.c
@@ -10,6 +10,7 @@
  */
 
 #include <common.h>
+#include <eeprom.h>
 #include <ioports.h>
 #include <mpc83xx.h>
 #include <i2c.h>
diff --git a/board/kosagi/novena/novena.c b/board/kosagi/novena/novena.c
index 9f2586521d4..72337069f4a 100644
--- a/board/kosagi/novena/novena.c
+++ b/board/kosagi/novena/novena.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <eeprom.h>
 #include <linux/errno.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
diff --git a/board/phytec/phycore_rk3288/phycore-rk3288.c b/board/phytec/phycore_rk3288/phycore-rk3288.c
index ffe1833b06b..1d741533010 100644
--- a/board/phytec/phycore_rk3288/phycore-rk3288.c
+++ b/board/phytec/phycore_rk3288/phycore-rk3288.c
@@ -4,6 +4,7 @@
  * Author: Wadim Egorov <w.egorov at phytec.de>
  */
 
+#include <eeprom.h>
 #include <asm/io.h>
 #include <common.h>
 #include <dm.h>
diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c b/board/rockchip/tinker_rk3288/tinker-rk3288.c
index 44f13183a5b..6363bb9e7b8 100644
--- a/board/rockchip/tinker_rk3288/tinker-rk3288.c
+++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <eeprom.h>
 #include <environment.h>
 #include <i2c_eeprom.h>
 #include <netdev.h>
diff --git a/board/samtec/vining_fpga/socfpga.c b/board/samtec/vining_fpga/socfpga.c
index d99aac68287..c1d022c4470 100644
--- a/board/samtec/vining_fpga/socfpga.c
+++ b/board/samtec/vining_fpga/socfpga.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <eeprom.h>
 #include <environment.h>
 #include <asm/arch/reset_manager.h>
 #include <asm/io.h>
diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
index e0cf0ecde6f..42d3d8689fa 100644
--- a/board/ti/am43xx/board.c
+++ b/board/ti/am43xx/board.c
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <eeprom.h>
 #include <environment.h>
 #include <i2c.h>
 #include <linux/errno.h>
diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index 39a782e4796..6d2c5f2c35f 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -6,6 +6,7 @@
  *     Texas Instruments Incorporated, <www.ti.com>
  */
 #include <common.h>
+#include <eeprom.h>
 #include <asm/arch/clock.h>
 #include <asm/ti-common/keystone_net.h>
 #include <asm/arch/psc_defs.h>
diff --git a/cmd/eeprom.c b/cmd/eeprom.c
index 6c29b33ba34..0cc653db40c 100644
--- a/cmd/eeprom.c
+++ b/cmd/eeprom.c
@@ -22,6 +22,7 @@
 #include <common.h>
 #include <config.h>
 #include <command.h>
+#include <eeprom.h>
 #include <i2c.h>
 #include <eeprom_layout.h>
 
diff --git a/drivers/misc/i2c_eeprom.c b/drivers/misc/i2c_eeprom.c
index 8f2349ad5a7..3755dbf74bb 100644
--- a/drivers/misc/i2c_eeprom.c
+++ b/drivers/misc/i2c_eeprom.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <eeprom.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
 #include <dm.h>
diff --git a/drivers/mtd/mw_eeprom.c b/drivers/mtd/mw_eeprom.c
index f7791b51a04..6a3a6f67518 100644
--- a/drivers/mtd/mw_eeprom.c
+++ b/drivers/mtd/mw_eeprom.c
@@ -1,6 +1,7 @@
 /* Three-wire (MicroWire) serial eeprom driver (for 93C46 and compatibles) */
 
 #include <common.h>
+#include <eeprom.h>
 #include <asm/ic/ssi.h>
 
 /*
diff --git a/drivers/rtc/rv3029.c b/drivers/rtc/rv3029.c
index 38acb9c9924..23670627770 100644
--- a/drivers/rtc/rv3029.c
+++ b/drivers/rtc/rv3029.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <command.h>
 #include <dm.h>
+#include <eeprom.h>
 #include <i2c.h>
 #include <rtc.h>
 
diff --git a/env/eeprom.c b/env/eeprom.c
index ac2689cc148..593743b8b01 100644
--- a/env/eeprom.c
+++ b/env/eeprom.c
@@ -9,6 +9,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <eeprom.h>
 #include <environment.h>
 #include <linux/stddef.h>
 #if defined(CONFIG_I2C_ENV_EEPROM_BUS)
diff --git a/include/common.h b/include/common.h
index 2c21dee8505..eb453a50bd8 100644
--- a/include/common.h
+++ b/include/common.h
@@ -269,21 +269,6 @@ phys_size_t get_effective_memsize(void);
 void	reset_phy     (void);
 void	fdc_hw_init   (void);
 
-/* $(BOARD)/eeprom.c */
-#ifdef CONFIG_CMD_EEPROM
-void eeprom_init  (int bus);
-int  eeprom_read  (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
-int  eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
-#else
-/*
- * Some EEPROM code is depecated because it used the legacy I2C interface. Add
- * some macros here so we don't have to touch every one of those uses
- */
-#define eeprom_init(bus)
-#define eeprom_read(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
-#define eeprom_write(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
-#endif
-
 #if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
 # define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
 #endif
diff --git a/include/eeprom.h b/include/eeprom.h
new file mode 100644
index 00000000000..61eb826a734
--- /dev/null
+++ b/include/eeprom.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ */
+
+#ifndef __EEPROM_LEGACY_H
+#define __EEPROM_LEGACY_H
+
+#ifdef CONFIG_CMD_EEPROM
+void eeprom_init(int bus);
+int eeprom_read(uint dev_addr, uint offset, uchar *buffer, uint cnt);
+int eeprom_write(uint dev_addr, uint offset, uchar *buffer, uint cnt);
+#else
+/*
+ * Some EEPROM code is depecated because it used the legacy I2C interface. Add
+ * some macros here so we don't have to touch every one of those uses
+ */
+#define eeprom_init(bus)
+#define eeprom_read(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
+#define eeprom_write(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
+#endif
+
+#endif
-- 
2.47.0



More information about the openbmc mailing list