public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH 5/9] arm: mvebu: theadorable: Switch to using DM I2C API
Date: Thu, 18 Nov 2021 09:19:35 +0100	[thread overview]
Message-ID: <20211118081939.861407-5-sr@denx.de> (raw)
In-Reply-To: <20211118081939.861407-1-sr@denx.de>

No functional change intended. This patch switches from the legacy I2C
API to the DM I2C API, so that this code can be used with DM I2C
enabled.

Signed-off-by: Stefan Roese <sr@denx.de>
---
 board/theadorable/theadorable.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/board/theadorable/theadorable.c b/board/theadorable/theadorable.c
index bb2d51495638..6e41ca239919 100644
--- a/board/theadorable/theadorable.c
+++ b/board/theadorable/theadorable.c
@@ -298,10 +298,19 @@ int board_late_init(void)
 		bootcount_inc();
 
 		if (bootcount > PEX_SWITCH_NOT_FOUNT_LIMIT) {
-			printf("Issuing power-switch via uC!\n");
+			struct udevice *dev;
 
 			printf("Issuing power-switch via uC!\n");
-			i2c_set_bus_num(STM_I2C_BUS);
+			ret = i2c_get_chip_for_busnum(STM_I2C_BUS, STM_I2C_ADDR,
+						      1, &dev);
+			if (ret) {
+				printf("Error selecting STM on I2C bus (ret=%d)\n",
+				       ret);
+				printf("Issuing soft-reset...\n");
+				/* default handling: SOFT reset */
+				do_reset(NULL, 0, 0, NULL);
+			}
+
 			i2c_buf[0] = STM_I2C_ADDR << 1;
 			i2c_buf[1] = 0xc5;	/* cmd */
 			i2c_buf[2] = 0x01;	/* enable */
@@ -313,7 +322,7 @@ int board_late_init(void)
 			i2c_buf[6] = 0x00;
 			i2c_buf[7] = crc8(0x72, &i2c_buf[0], 7);
 
-			ret = i2c_write(STM_I2C_ADDR, 0, 0, &i2c_buf[1], 7);
+			ret = dm_i2c_write(dev, 0, &i2c_buf[1], 7);
 			if (ret) {
 				printf("I2C write error (ret=%d)\n", ret);
 				printf("Issuing soft-reset...\n");
-- 
2.34.0


  parent reply	other threads:[~2021-11-18  8:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18  8:19 [PATCH 1/9] arm: mvebu: theadorable_debug_defconfig: Enable DM_I2C Stefan Roese
2021-11-18  8:19 ` [PATCH 2/9] arm: mvebu: db-mv784mp-gp_defconfig: " Stefan Roese
2021-12-18 13:43   ` Stefan Roese
2021-11-18  8:19 ` [PATCH 3/9] arm: mvebu: ds414_defconfig: " Stefan Roese
2021-12-18 13:43   ` Stefan Roese
2021-11-18  8:19 ` [PATCH 4/9] arm: mvebu: maxbcm_defconfig: " Stefan Roese
2021-12-18 13:43   ` Stefan Roese
2021-11-18  8:19 ` Stefan Roese [this message]
2021-12-18 13:44   ` [PATCH 5/9] arm: mvebu: theadorable: Switch to using DM I2C API Stefan Roese
2021-11-18  8:19 ` [PATCH 6/9] arm: mvebu: axp/high_speed_env_lib: Switch to DM_I2C API Stefan Roese
2021-12-18 13:44   ` Stefan Roese
2021-11-18  8:19 ` [PATCH 7/9] arm: mvebu: axp: Remove unreferenced ddr3_get_eprom_fabric() function Stefan Roese
2021-12-18 13:44   ` Stefan Roese
2021-11-18  8:19 ` [PATCH 8/9] arm: mvebu: axp: ddr: Switch to using DM I2C API Stefan Roese
2021-12-18 13:44   ` Stefan Roese
2021-11-18  8:19 ` [PATCH 9/9] arm: mvebu: armada-xp-theadorable.dts: Add I2C DT nodes Stefan Roese
2021-12-18 13:45   ` Stefan Roese
2021-12-18 13:43 ` [PATCH 1/9] arm: mvebu: theadorable_debug_defconfig: Enable DM_I2C Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211118081939.861407-5-sr@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox