u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Joel Stanley <joel@jms.id.au>
To: Ryan Chen <ryan_chen@aspeedtech.com>,
	BMC-SW@aspeedtech.com, Heiko Schocher <hs@denx.de>
Cc: u-boot@lists.denx.de, "Cédric Le Goater" <clg@kaod.org>
Subject: [PATCH v2 08/11] i2c/aspeed: Fix reset control
Date: Thu, 23 Jun 2022 14:40:38 +0930	[thread overview]
Message-ID: <20220623051041.3848714-9-joel@jms.id.au> (raw)
In-Reply-To: <20220623051041.3848714-1-joel@jms.id.au>

The reset control was written for the ast2500 and directly programs the
clocking register.

So we can share the code with other SoC generations use the reset device
to deassert the I2C reset line.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Ryan Chen <ryan_chen@aspeedtech.com>
---
 drivers/i2c/ast_i2c.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/ast_i2c.c b/drivers/i2c/ast_i2c.c
index 2d3fecaa14ea..0a93d7c82911 100644
--- a/drivers/i2c/ast_i2c.c
+++ b/drivers/i2c/ast_i2c.c
@@ -16,6 +16,7 @@
 #include <asm/arch/scu_ast2500.h>
 #include <linux/delay.h>
 #include <linux/err.h>
+#include <reset.h>
 
 #include "ast_i2c.h"
 
@@ -108,19 +109,26 @@ static int ast_i2c_of_to_plat(struct udevice *dev)
 
 static int ast_i2c_probe(struct udevice *dev)
 {
-	struct ast2500_scu *scu;
+	struct reset_ctl reset_ctl;
+	int rc;
 
 	debug("Enabling I2C%u\n", dev_seq(dev));
 
 	/*
 	 * Get all I2C devices out of Reset.
-	 * Only needs to be done once, but doing it for every
-	 * device does not hurt.
+	 *
+	 * Only needs to be done once so test before performing reset.
 	 */
-	scu = ast_get_scu();
-	ast_scu_unlock(scu);
-	clrbits_le32(&scu->sysreset_ctrl1, SCU_SYSRESET_I2C);
-	ast_scu_lock(scu);
+	rc = reset_get_by_index(dev, 0, &reset_ctl);
+	if (rc) {
+		printf("%s: Failed to get reset signal\n", __func__);
+		return rc;
+	}
+
+	if (reset_status(&reset_ctl) > 0) {
+		reset_assert(&reset_ctl);
+		reset_deassert(&reset_ctl);
+	}
 
 	ast_i2c_init_bus(dev);
 
-- 
2.35.1


  parent reply	other threads:[~2022-06-23  5:12 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23  5:10 [PATCH v2 00/11] i2c: Improvements for aspeed boards Joel Stanley
2022-06-23  5:10 ` [PATCH v2 01/11] ARM: dts: ast2600: Add I2C pinctrl Joel Stanley
2022-07-07  1:56   ` Tom Rini
2022-06-23  5:10 ` [PATCH v2 02/11] ARM: dts: ast2600: Add I2C reset properties Joel Stanley
2022-07-07  1:56   ` Tom Rini
2022-06-23  5:10 ` [PATCH v2 03/11] ARM: dts: ast2600: Disable I2C nodes by default Joel Stanley
2022-07-07  1:56   ` Tom Rini
2022-06-23  5:10 ` [PATCH v2 04/11] ARM: dts: ast2600-evb: Remove redundant pinctrl Joel Stanley
2022-07-07  1:57   ` Tom Rini
2022-06-23  5:10 ` [PATCH v2 05/11] ARM: dts: ast2500-evb: Add I2C devices Joel Stanley
2022-07-07  1:57   ` Tom Rini
2022-06-23  5:10 ` [PATCH v2 06/11] ARM: dts: ast2600-evb: " Joel Stanley
2022-07-07  1:57   ` Tom Rini
2022-06-23  5:10 ` [PATCH v2 07/11] reset/aspeed: Implement status callback Joel Stanley
2022-07-07  1:57   ` Tom Rini
2022-06-23  5:10 ` Joel Stanley [this message]
2022-07-07  1:57   ` [PATCH v2 08/11] i2c/aspeed: Fix reset control Tom Rini
2022-06-23  5:10 ` [PATCH v2 09/11] i2c/aspeed: Add AST2600 compatible Joel Stanley
2022-07-07  1:57   ` Tom Rini
2022-06-23  5:10 ` [PATCH v2 10/11] config/ast2600: Enable I2C driver Joel Stanley
2022-07-07  1:57   ` Tom Rini
2022-06-23  5:10 ` [PATCH v2 11/11] config/aspeed: Enable EEPROM options Joel Stanley
2022-07-07  1:57   ` Tom Rini

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=20220623051041.3848714-9-joel@jms.id.au \
    --to=joel@jms.id.au \
    --cc=BMC-SW@aspeedtech.com \
    --cc=clg@kaod.org \
    --cc=hs@denx.de \
    --cc=ryan_chen@aspeedtech.com \
    --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;
as well as URLs for NNTP newsgroup(s).