From patchwork Fri Feb 7 15:57:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1235060 X-Patchwork-Delegate: hs@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=VLxILFS6; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Dg251K7zz9sRK for ; Sat, 8 Feb 2020 02:58:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 926608181D; Fri, 7 Feb 2020 16:58:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1581091087; bh=f3rllGxov2ad2Z6sr7+iMkC8Qdb53FwFJ/BMsdWXSME=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=VLxILFS6u0cZgLk6ZhErS+JT5fa545UFbjw8/kzYygTTkrQ1rH4Z+7u8D9yFGxfU/ w5E4RI7McEyJAlEmSdiCwXv6kzNY7sjX+iij5y64cjlv4fCFEu+Hh2mdobsGUF2hvc v/QzDcG7QpzlO1jKkMOSW+VqlU0+rRV9ah0Q5z4YF+5LITcTMZC7qvKJO0SKCujpwF 4JabXFq13Lnk2ETjG/9lAsOvjbubMo8uQQCHyNIx7QpqWs9qc5LQObXmIn1mjSBi3U 8D8IrcUZl4LiV6lx9qPuJi7ad1HW4OzTnYui8WAs9qCoIOQQUPyARwjvJwvL/7GDDY WYmq9PRQx3p2A== Received: by phobos.denx.de (Postfix, from userid 109) id 23B4A81848; Fri, 7 Feb 2020 16:58:03 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F0BB2817EE for ; Fri, 7 Feb 2020 16:57:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=marex@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 48Dg1g5hzcz1qqkc; Fri, 7 Feb 2020 16:57:59 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 48Dg1g5V3cz1rVDq; Fri, 7 Feb 2020 16:57:59 +0100 (CET) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 5a_XTCfvBdiF; Fri, 7 Feb 2020 16:57:58 +0100 (CET) X-Auth-Info: aeQk5spPuOGEBo3349Ul9msg+rYj7wtzk8bIuJ1zx/o= Received: from desktop.lan (ip-86-49-35-8.net.upcbroadband.cz [86.49.35.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 7 Feb 2020 16:57:58 +0100 (CET) From: Marek Vasut To: u-boot@lists.denx.de Subject: [PATCH 2/4] i2c: Export i2c_deblock_gpio_loop() Date: Fri, 7 Feb 2020 16:57:50 +0100 Message-Id: <20200207155752.40930-2-marex@denx.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200207155752.40930-1-marex@denx.de> References: <20200207155752.40930-1-marex@denx.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean Export the i2c_deblock_gpio_loop() so it can be used in other places in U-Boot. In particular, this is useful in the GPIO I2C driver, which claims the SDA/SCL GPIOs and thus prevents the i2c_deblock() implementation from claiming the pins as GPIOs again. Signed-off-by: Marek Vasut Reviewed-by: Heiko Schocher --- drivers/i2c/i2c-uclass.c | 8 ++++---- include/i2c.h | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index 25af1fabdb..86f529241f 100644 --- a/drivers/i2c/i2c-uclass.c +++ b/drivers/i2c/i2c-uclass.c @@ -501,10 +501,10 @@ static int i2c_gpio_get_pin(struct gpio_desc *pin) return dm_gpio_get_value(pin); } -static int i2c_deblock_gpio_loop(struct gpio_desc *sda_pin, - struct gpio_desc *scl_pin, - unsigned int scl_count, - unsigned int delay) +int i2c_deblock_gpio_loop(struct gpio_desc *sda_pin, + struct gpio_desc *scl_pin, + unsigned int scl_count, + unsigned int delay) { int ret = 0; diff --git a/include/i2c.h b/include/i2c.h index 0faf8542e2..7c92042c58 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -330,6 +330,22 @@ uint i2c_get_chip_addr_offset_mask(struct udevice *dev); */ int i2c_deblock(struct udevice *bus); +/** + * i2c_deblock_gpio_loop() - recover a bus from an unknown state by toggling SDA/SCL + * + * This is the inner logic used for toggling I2C SDA/SCL lines as GPIOs + * for deblocking the I2C bus. + * + * @sda_pin: SDA GPIO + * @scl_pin: SCL GPIO + * @scl_count: Number of SCL clock cycles generated to deblock SDA + * @delay: Delay between SCL clock line changes + * @return 0 if OK, -ve on error + */ +struct gpio_desc; +int i2c_deblock_gpio_loop(struct gpio_desc *sda_pin, struct gpio_desc *scl_pin, + unsigned int scl_count, unsigned int delay); + /** * struct dm_i2c_ops - driver operations for I2C uclass *