Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8433C4338F for ; Tue, 27 Jul 2021 22:21:00 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 38BEB60F6E for ; Tue, 27 Jul 2021 22:21:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 38BEB60F6E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gateworks.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C2E178349C; Wed, 28 Jul 2021 00:20:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gateworks.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 762C783431; Wed, 28 Jul 2021 00:20:06 +0200 (CEST) Received: from finn.localdomain (finn.gateworks.com [108.161.129.64]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 19FE783343 for ; Wed, 28 Jul 2021 00:19:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gateworks.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=tharvey@gateworks.com Received: from 068-189-091-139.biz.spectrum.com ([68.189.91.139] helo=tharvey.pdc.gateworks.com) by finn.localdomain with esmtp (Exim 4.93) (envelope-from ) id 1m8VQS-005ENA-EP; Tue, 27 Jul 2021 22:19:48 +0000 From: Tim Harvey To: Stefano Babic , Fabio Estevam , "NXP i . MX U-Boot Team" , u-boot@lists.denx.de Cc: Tim Harvey Subject: [PATCH 6/9] board: gateworks: venice: use bus numbers vs names Date: Tue, 27 Jul 2021 15:19:38 -0700 Message-Id: <20210727221941.10420-6-tharvey@gateworks.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210727221941.10420-1-tharvey@gateworks.com> References: <20210727221941.10420-1-tharvey@gateworks.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean replace looking up i2c bus name by bus number and define bus numbers and eeprom address with #defines. Signed-off-by: Tim Harvey --- 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 static struct udevice *gsc_get_dev(int busno, int slave) { - static const char * const i2c[] = { "i2c@30a20000", "i2c@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@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@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