From patchwork Thu Jun 23 05:10:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 1646890 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=hdhJ18B0; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LT7fp1rMnz9sGT for ; Thu, 23 Jun 2022 15:12:34 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9F9E184334; Thu, 23 Jun 2022 07:11:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hdhJ18B0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8B352842F1; Thu, 23 Jun 2022 07:11:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AF68684392 for ; Thu, 23 Jun 2022 07:11:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=joel.stan@gmail.com Received: by mail-pl1-x62a.google.com with SMTP id jb13so3595877plb.9 for ; Wed, 22 Jun 2022 22:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7HGvQF7onTrkTgrGUvbFAhxXxpE2F7Lkwfo+qXgwJOw=; b=hdhJ18B0KZEWOikER1h3utbWllioXJ4l9fQvUhuOwFQ4viUCy1EyBS6lwX+xHluXTP zCSKYVA+ijM3bJ4VNsOgme//KWOT8ZkS4ij8s0KCHiFIAqKEJ5Hz9dZ22oOigRVXDO65 vIM7OgkeHqAOEJuyXkMnLqPOzSEcBiJtfcLoXaZ4w63EF3dzADEK4B3WbE/ciDQThd3P hpZf/bCO4fxOsjUFCVMoANsaGOb4WRhgCAN3w9nqADwnFTk3ucZ5wFWoU6gv9VpTd5xl 5AcUxhoursjUbuUR6cju4fQHgiU6Yt0m/ymSQ3DNP01488bp92Y6SE89U7D3C+iaDQC0 PHqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=7HGvQF7onTrkTgrGUvbFAhxXxpE2F7Lkwfo+qXgwJOw=; b=4Mm+9hA8gox43AREND43p2ch5MJA9bwSAm+mtaia1Q7k5OKqkL9AXr7cHgnBpeOy8z XZ6DxxXIEQvJ7wn7UsNLUbECa/KLAod3FtAhzlUkstOWRYwV3PezbLNLXm420ZrCgNSP UA7y2vy5HIjDcjPlAfsA6phl82sMm9KoVSBjtxlnRAri+ob75M45xS/x9wTD9wrdogNt z6CnJ0FaqfcvHNZkzk68Wkp1tCk7NjykjNr8mhI/xKnkKqp+cBieGIvfc7tawnRDZ7hc e9MZ9+8nIAmT60dsaQKjQY8eN5lKueGef84ixL7GnVf7k8vn4do4DOqwd9j76Poz72qj 6Iug== X-Gm-Message-State: AJIora+QoWLPdZm9nY0WkRk8hsxJnCaVONVlz6f8MJ41oEZbtXI+VZSd ZuZkDhsEoZ1rc8MxJvJkl7Q= X-Google-Smtp-Source: AGRyM1tP4zHGkaWV5WRGsWXE60Yk07MdWFcNx76JBr1RCy/0uf3CAQydaoLbasS5mLNt4TwICpzoPA== X-Received: by 2002:a17:90b:1c86:b0:1ea:4ceb:2788 with SMTP id oo6-20020a17090b1c8600b001ea4ceb2788mr2153382pjb.16.1655961079840; Wed, 22 Jun 2022 22:11:19 -0700 (PDT) Received: from localhost.localdomain ([45.124.203.18]) by smtp.gmail.com with ESMTPSA id jf20-20020a170903269400b0016a10e0ce17sm9723820plb.151.2022.06.22.22.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 22:11:19 -0700 (PDT) From: Joel Stanley To: Ryan Chen , BMC-SW@aspeedtech.com, Heiko Schocher Cc: u-boot@lists.denx.de, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v2 08/11] i2c/aspeed: Fix reset control Date: Thu, 23 Jun 2022 14:40:38 +0930 Message-Id: <20220623051041.3848714-9-joel@jms.id.au> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220623051041.3848714-1-joel@jms.id.au> References: <20220623051041.3848714-1-joel@jms.id.au> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean 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 Reviewed-by: Ryan Chen --- 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 #include #include +#include #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);