[U-Boot] [PATCH V2 3/5] dm9000: Add struct eth_device * to SROM functions

Andrew Ruder andrew.ruder at elecsyscorp.com
Wed Aug 12 19:24:04 CEST 2015


Currently this argument is not used.  To eventually support multiple
DM9000's these public-facing functions will need a new argument - the
ethernet device.  Fix-up the one board using this part of the DM9000
API.  Compile-tested only.

Signed-off-by: Andrew Ruder <andrew.ruder at elecsyscorp.com>
Cc: Joe Hershberger <joe.hershberger at gmail.com>
---
 board/trizepsiv/eeprom.c | 5 +++--
 drivers/net/dm9000x.c    | 6 +++---
 include/dm9000.h         | 6 ++++--
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/board/trizepsiv/eeprom.c b/board/trizepsiv/eeprom.c
index 1318edc..d9045dd 100644
--- a/board/trizepsiv/eeprom.c
+++ b/board/trizepsiv/eeprom.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <command.h>
 #include <dm9000.h>
+#include <net.h>
 
 static int do_read_dm9000_eeprom ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
 	unsigned int i;
@@ -16,7 +17,7 @@ static int do_read_dm9000_eeprom ( cmd_tbl_t *cmdtp, int flag, int argc, char *
 	for (i=0; i < 0x40; i++) {
 		if (!(i % 0x10))
 			printf("\n%08x:", i);
-		dm9000_read_srom_word(i, data);
+		dm9000_read_srom_word(eth_get_dev_by_index(0), i, data);
 		printf(" %02x%02x", data[1], data[0]);
 	}
 	printf ("\n");
@@ -35,7 +36,7 @@ static int do_write_dm9000_eeprom ( cmd_tbl_t *cmdtp, int flag, int argc, char *
 		printf("Wrong offset : 0x%x\n",offset);
 		return cmd_usage(cmdtp);
 	}
-	dm9000_write_srom_word(offset, value);
+	dm9000_write_srom_word(eth_get_dev_by_index(0), offset, value);
 	return (0);
 }
 
diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index 258c8a3..e1a10b5 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -528,7 +528,7 @@ static int dm9000_rx(struct eth_device *netdev)
   Read a word data from SROM
 */
 #if !defined(CONFIG_DM9000_NO_SROM)
-void dm9000_read_srom_word(int offset, u8 *to)
+void dm9000_read_srom_word(struct eth_device *dev, int offset, u8 *to)
 {
 	DM9000_iow(DM9000_EPAR, offset);
 	DM9000_iow(DM9000_EPCR, 0x4);
@@ -538,7 +538,7 @@ void dm9000_read_srom_word(int offset, u8 *to)
 	to[1] = DM9000_ior(DM9000_EPDRH);
 }
 
-void dm9000_write_srom_word(int offset, u16 val)
+void dm9000_write_srom_word(struct eth_device *dev, int offset, u16 val)
 {
 	DM9000_iow(DM9000_EPAR, offset);
 	DM9000_iow(DM9000_EPDRH, ((val >> 8) & 0xff));
@@ -554,7 +554,7 @@ static void dm9000_get_enetaddr(struct eth_device *dev)
 #if !defined(CONFIG_DM9000_NO_SROM)
 	int i;
 	for (i = 0; i < 3; i++)
-		dm9000_read_srom_word(i, dev->enetaddr + (2 * i));
+		dm9000_read_srom_word(dev, i, dev->enetaddr + (2 * i));
 #endif
 }
 
diff --git a/include/dm9000.h b/include/dm9000.h
index 42b04fa..7a7e629 100644
--- a/include/dm9000.h
+++ b/include/dm9000.h
@@ -10,8 +10,10 @@
 
 /******************  function prototypes **********************/
 #if !defined(CONFIG_DM9000_NO_SROM)
-void dm9000_write_srom_word(int offset, u16 val);
-void dm9000_read_srom_word(int offset, u8 *to);
+struct eth_device;
+
+void dm9000_write_srom_word(struct eth_device *dev, int offset, u16 val);
+void dm9000_read_srom_word(struct eth_device *dev, int offset, u8 *to);
 #endif
 
 #endif /* __DM9000_H__ */
-- 
2.1.4



More information about the U-Boot mailing list