[PATCH 6/9] board: gateworks: venice: use bus numbers vs names
Tim Harvey
tharvey at gateworks.com
Wed Jul 28 00:19:38 CEST 2021
replace looking up i2c bus name by bus number and define bus numbers and
eeprom address with #defines.
Signed-off-by: Tim Harvey <tharvey at gateworks.com>
---
board/gateworks/venice/gsc.c | 19 ++++++++++---------
board/gateworks/venice/gsc.h | 5 +++++
board/gateworks/venice/spl.c | 4 ++--
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/board/gateworks/venice/gsc.c b/board/gateworks/venice/gsc.c
index c75bc6f855..c1278e636d 100644
--- a/board/gateworks/venice/gsc.c
+++ b/board/gateworks/venice/gsc.c
@@ -123,13 +123,13 @@ enum {
GSC_SC_RST_CAUSE_MAX = 10,
};
+#include <dm/device.h>
static struct udevice *gsc_get_dev(int busno, int slave)
{
- static const char * const i2c[] = { "i2c at 30a20000", "i2c at 30a30000" };
struct udevice *dev, *bus;
int ret;
- ret = uclass_get_device_by_name(UCLASS_I2C, i2c[busno - 1], &bus);
+ ret = uclass_get_device_by_seq(UCLASS_I2C, busno, &bus);
if (ret) {
printf("GSC : failed I2C%d probe: %d\n", busno, ret);
return NULL;
@@ -246,7 +246,7 @@ int gsc_hwmon(void)
return node;
/* probe device */
- dev = gsc_get_dev(1, GSC_HWMON_ADDR);
+ dev = gsc_get_dev(GSC_BUSNO, GSC_HWMON_ADDR);
if (!dev) {
puts("ERROR: Failed to probe GSC HWMON\n");
return -ENODEV;
@@ -453,14 +453,15 @@ static int gsc_read(void)
{
int ret;
- ret = gsc_read_eeprom(1, GSC_EEPROM_ADDR, 1, &som_info);
+ ret = gsc_read_eeprom(GSC_BUSNO, GSC_EEPROM_ADDR, 1, &som_info);
if (ret) {
memset(&som_info, 0, sizeof(som_info));
return ret;
}
/* read optional baseboard EEPROM */
- return gsc_read_eeprom(2, 0x52, 2, &base_info);
+ return gsc_read_eeprom(BASEBOARD_EEPROM_BUSNO, BASEBOARD_EEPROM_ADDR,
+ 2, &base_info);
}
static int gsc_info(int verbose)
@@ -518,7 +519,7 @@ static int gsc_info(int verbose)
/* Display RTC */
puts("RTC : ");
- dev = gsc_get_dev(1, GSC_RTC_ADDR);
+ dev = gsc_get_dev(GSC_BUSNO, GSC_RTC_ADDR);
if (!dev) {
puts("Failed to probe GSC RTC\n");
} else {
@@ -542,7 +543,7 @@ int gsc_init(int quiet)
*/
while (1) {
/* probe device */
- dev = gsc_get_dev(1, GSC_SC_ADDR);
+ dev = gsc_get_dev(GSC_BUSNO, GSC_SC_ADDR);
if (dev)
break;
mdelay(1);
@@ -583,7 +584,7 @@ static int gsc_sleep(unsigned long secs)
int ret;
/* probe device */
- dev = gsc_get_dev(1, GSC_SC_ADDR);
+ dev = gsc_get_dev(GSC_BUSNO, GSC_SC_ADDR);
if (!dev)
return -ENODEV;
@@ -631,7 +632,7 @@ static int gsc_boot_wd_disable(void)
int ret;
/* probe device */
- dev = gsc_get_dev(1, GSC_SC_ADDR);
+ dev = gsc_get_dev(GSC_BUSNO, GSC_SC_ADDR);
if (!dev)
return -ENODEV;
diff --git a/board/gateworks/venice/gsc.h b/board/gateworks/venice/gsc.h
index 27b02117bb..e0d0332a82 100644
--- a/board/gateworks/venice/gsc.h
+++ b/board/gateworks/venice/gsc.h
@@ -6,11 +6,16 @@
#ifndef _GSC_H_
#define _GSC_H_
+/* I2C bus numbers */
+#define GSC_BUSNO 0
+#define BASEBOARD_EEPROM_BUSNO 1
+
/* I2C slave addresses */
#define GSC_SC_ADDR 0x20
#define GSC_RTC_ADDR 0x68
#define GSC_HWMON_ADDR 0x29
#define GSC_EEPROM_ADDR 0x51
+#define BASEBOARD_EEPROM_ADDR 0x52
struct venice_board_info {
u8 mac[6]; /* 0x00: MAC base */
diff --git a/board/gateworks/venice/spl.c b/board/gateworks/venice/spl.c
index 8c357757c1..aada55ee27 100644
--- a/board/gateworks/venice/spl.c
+++ b/board/gateworks/venice/spl.c
@@ -116,7 +116,7 @@ static int power_init_board(void)
if ((!strncmp(model, "GW71", 4)) ||
(!strncmp(model, "GW72", 4)) ||
(!strncmp(model, "GW73", 4))) {
- ret = uclass_get_device_by_name(UCLASS_I2C, "i2c at 30a20000", &bus);
+ ret = uclass_get_device_by_seq(UCLASS_I2C, 0, &bus);
if (ret) {
printf("PMIC : failed I2C1 probe: %d\n", ret);
return ret;
@@ -134,7 +134,7 @@ static int power_init_board(void)
}
else if (!strncmp(model, "GW7901", 6)) {
- ret = uclass_get_device_by_name(UCLASS_I2C, "i2c at 30a30000", &bus);
+ ret = uclass_get_device_by_seq(UCLASS_I2C, 1, &bus);
if (ret) {
printf("PMIC : failed I2C2 probe: %d\n", ret);
return ret;
--
2.17.1
More information about the U-Boot
mailing list