From patchwork Wed Apr 27 19:23:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 567615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B494CC4321E for ; Wed, 27 Apr 2022 19:27:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232516AbiD0TaV (ORCPT ); Wed, 27 Apr 2022 15:30:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233876AbiD0T3A (ORCPT ); Wed, 27 Apr 2022 15:29:00 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F046C4ECF2; Wed, 27 Apr 2022 12:25:18 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id d5so3859990wrb.6; Wed, 27 Apr 2022 12:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=0W3gP71n1MpZQMJz0XuN2Q/9yyGOAs5p7ZQydj5TXzM=; b=IopDI538q2NMk/iwKb7awj5KfPdKiaM1XdpuM9nkHAkyvoji6a83CyYMnOnB68MYpN Ut50K3HFUOgy3rCVTGq+yZGRUMUzPY/HHa8GAThXKVnFdQU82ZT9NtHh2LOVHPZs8dP+ yxLEeillobzoDqW/KJkhTOEQV52p7QcqN+/xXZz+ekIC+u7RNOAcwL9kQV3WEg3+vHPR WhOwr/NlYCOyrCY6LXssKZsIA4T/DwUUJEx80UiuIFoja5EMNP2XrEhAdNOOyS8BFrSG 0/qT20j3hA6TizkAgAUwc9SjWi5gr9jcqA5kEL+bznCRKIkEKdf8TUXbFvOAoO5w2Zu5 eZaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=0W3gP71n1MpZQMJz0XuN2Q/9yyGOAs5p7ZQydj5TXzM=; b=Fi3Oj5/iQzn43cINgBPf0Jcc+n8HOsEHriAskmHqynk+JSpiN4U19ldXKcJh7l2Vgp Vslakm/WbHEwvNfYbbfk2Ki68D86OLMM+wYZf9jSu/DcalTkHMhf4iEpxzLT6deOZCFT D6xpFsoLkUFsTCE7ar+qCsQaHNX0Pjb3+7QftIyIjmn1uNSEgkvJXdfaHxMxydb2WezP H/WgfxLf7Xax3ccW33j4d1KbSyrkTRjFv+88+r5QRqLyKSUtLSkWH780xdvwX1C0bEu8 HnLdCsjCrh5JslOUWN0VcTziNQwXKNOntiZH3W7tR+xVo19XJLf0DjVHbBBEWn3f+dQx +Sog== X-Gm-Message-State: AOAM5316jojx9vn8JsRa8hFGTbcANXMegwDc8xmYEbfuVHq0ttqTVbPm FY6eLmjwhdNc8asqQziQTW9tqK1wjG8= X-Google-Smtp-Source: ABdhPJxlQSR42melvpN8JuJWA3iGQzH2dKFKRtRFwARgPNEKySFm88SLBQBfG2iWXu5+dJel1mP9wg== X-Received: by 2002:a5d:6e87:0:b0:20a:c40a:cda4 with SMTP id k7-20020a5d6e87000000b0020ac40acda4mr23215366wrz.370.1651087516222; Wed, 27 Apr 2022 12:25:16 -0700 (PDT) Received: from ?IPV6:2a01:c23:c002:fc00:393a:1fdf:a518:6420? (dynamic-2a01-0c23-c002-fc00-393a-1fdf-a518-6420.c23.pool.telefonica.de. [2a01:c23:c002:fc00:393a:1fdf:a518:6420]) by smtp.googlemail.com with ESMTPSA id p3-20020adfaa03000000b00207a1db96cfsm15067055wrd.71.2022.04.27.12.25.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Apr 2022 12:25:15 -0700 (PDT) Message-ID: Date: Wed, 27 Apr 2022 21:23:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: [PATCH v2 1/3] dt-bindings: i2c-gpio: Add property i2c-gpio,sda-output-only Content-Language: en-US From: Heiner Kallweit To: Rob Herring , Krzysztof Kozlowski , Wolfram Sang , Wolfram Sang Cc: "linux-i2c@vger.kernel.org" , "devicetree@vger.kernel.org" References: <3e6c934e-5298-42c5-c346-31b1acaa06ba@gmail.com> In-Reply-To: <3e6c934e-5298-42c5-c346-31b1acaa06ba@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org There are slave devices that understand I2C but have read-only SDA and SCL. Examples are FD650 7-segment LED controller and its derivatives. Typical board designs don't even have a pull-up for both pins. Therefore don't enforce open-drain if SDA and SCL both are unidirectional. This patch makes i2c-gpio usable with such devices, based on new DT property i2c-gpio,sda-output-only. Signed-off-by: Heiner Kallweit Reviewed-by: Rob Herring --- v2: - improve commit message --- Documentation/devicetree/bindings/i2c/i2c-gpio.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/i2c-gpio.yaml b/Documentation/devicetree/bindings/i2c/i2c-gpio.yaml index fd0402845..25cd1b260 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-gpio.yaml +++ b/Documentation/devicetree/bindings/i2c/i2c-gpio.yaml @@ -33,6 +33,10 @@ properties: open drain. maxItems: 1 + i2c-gpio,sda-output-only: + description: sda as output only + type: boolean + i2c-gpio,scl-output-only: description: scl as output only type: boolean From patchwork Wed Apr 27 19:24:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 566893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 858B0C433FE for ; Wed, 27 Apr 2022 19:27:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229934AbiD0TaR (ORCPT ); Wed, 27 Apr 2022 15:30:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234429AbiD0T3F (ORCPT ); Wed, 27 Apr 2022 15:29:05 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EC654ECFB; Wed, 27 Apr 2022 12:25:19 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id r11-20020a05600c35cb00b0039409c1111bso839729wmq.3; Wed, 27 Apr 2022 12:25:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=A4+ktht6E+aZpM5+3dwvgdmbjTzQMA5x6Q4uDTO6/dw=; b=Ts7hF3rKgmukVAejVVk7L8VPHbHIuc9A6DqCKdgKSc3Fwo+88AVI6hNwpeBCD2Sgdi /1J7ky+vQco4b6ZD7dd3iXpo2C6c1yVfq4Y6ZV7ykvw9ygYEFY4WYRm3959cUuyF6NCs Xsw4M8gEH7abLMQeTTvPGhnRDhtQBrS6xBoi+pEag50n6zCsSS5Pe35vYC7MtwO4E5an jKFBHhYwFDGboDztwk3tltvA2kAfb5Ls7859dVlyxwR70gmvnUjNUrOi6JcMh4C784zH owProFItXxeV9qec2Fo+zs08D9h/IkDU+vgVsCoMDMksjNkyrcVz83Xsd+G/HWoG0itj qALw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=A4+ktht6E+aZpM5+3dwvgdmbjTzQMA5x6Q4uDTO6/dw=; b=NFwU1Jf9pOTVDZ3hSfYel5FScqJsylC1129D5qQT5goD8bWLMcvO+84BqFuQV+WUK3 aB6G4J9uK+yAj3xbz2fp2RY4/3Z1LnufSwhs8AQUEgtLLBYcir+JnCgi0oo/zkZ6V3G5 psB7tOj+deDkW1yMrfXfu0nsEbCjyHZRVudRhDUnaS3D35vMr3GQR1fXJ8eoo7UwbanC bkVnx0iRIYDablqe2yiWrUKrhx+Prb5Y82mAAHOlpEpjMi4bL7SQ4RPF7h6Yq1UsFbbg UQDd6jeot5T1KUncOQlKfSGok/0RN1Nncrrg9d0SvfukEbRHn4LJpDkYxVLqKw2XcpQo CaOA== X-Gm-Message-State: AOAM5300AglvII22gu7IInrnFz2uvP8uLCnXxl3xs0ljGV6vJujDsI8v upmmsrKzbMOAaQ7037zQHhc= X-Google-Smtp-Source: ABdhPJzwlOsDaCrxLchO9nzKgl3u/idPkB0oV8Ywq2FDcHml+QiL0sX8p/2zJvX4OnlQ1n0UH3SP/Q== X-Received: by 2002:a05:600c:1e86:b0:391:62c4:fb72 with SMTP id be6-20020a05600c1e8600b0039162c4fb72mr36001695wmb.119.1651087517384; Wed, 27 Apr 2022 12:25:17 -0700 (PDT) Received: from ?IPV6:2a01:c23:c002:fc00:393a:1fdf:a518:6420? (dynamic-2a01-0c23-c002-fc00-393a-1fdf-a518-6420.c23.pool.telefonica.de. [2a01:c23:c002:fc00:393a:1fdf:a518:6420]) by smtp.googlemail.com with ESMTPSA id y6-20020a056000168600b0020a96d2cf8fsm17103951wrd.60.2022.04.27.12.25.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Apr 2022 12:25:17 -0700 (PDT) Message-ID: <2adcd797-f3cc-c8c7-c18c-d3726b2db4c0@gmail.com> Date: Wed, 27 Apr 2022 21:24:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: [PATCH v2 2/3] i2c: algo: bit: allow getsda to be NULL Content-Language: en-US From: Heiner Kallweit To: Rob Herring , Krzysztof Kozlowski , Wolfram Sang , Wolfram Sang Cc: "linux-i2c@vger.kernel.org" , "devicetree@vger.kernel.org" References: <3e6c934e-5298-42c5-c346-31b1acaa06ba@gmail.com> In-Reply-To: <3e6c934e-5298-42c5-c346-31b1acaa06ba@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org This is in preparation of supporting write-only SDA in i2c-gpio. Signed-off-by: Heiner Kallweit --- drivers/i2c/algos/i2c-algo-bit.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index fc90293af..ab5a73e90 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c @@ -184,8 +184,9 @@ static int i2c_outb(struct i2c_adapter *i2c_adap, unsigned char c) /* read ack: SDA should be pulled down by slave, or it may * NAK (usually to report problems with the data we wrote). + * Report ACK if SDA is write-only. */ - ack = !getsda(adap); /* ack: sda is pulled low -> success */ + ack = !adap->getsda || !getsda(adap); /* ack: sda is pulled low -> success */ bit_dbg(2, &i2c_adap->dev, "i2c_outb: 0x%02x %s\n", (int)c, ack ? "A" : "NA"); @@ -203,6 +204,9 @@ static int i2c_inb(struct i2c_adapter *i2c_adap) unsigned char indata = 0; struct i2c_algo_bit_data *adap = i2c_adap->algo_data; + if (!adap->getsda) + return -EOPNOTSUPP; + /* assert: scl is low */ sdahi(adap); for (i = 0; i < 8; i++) { @@ -232,6 +236,10 @@ static int test_bus(struct i2c_adapter *i2c_adap) const char *name = i2c_adap->name; int scl, sda, ret; + /* Testing not possible if both pins are write-only. */ + if (adap->getscl == NULL && adap->getsda == NULL) + return 0; + if (adap->pre_xfer) { ret = adap->pre_xfer(i2c_adap); if (ret < 0) @@ -670,8 +678,10 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap, if (ret < 0) return ret; - /* Complain if SCL can't be read */ - if (bit_adap->getscl == NULL) { + if (bit_adap->getscl == NULL && bit_adap->getsda == NULL) + dev_info(&adap->dev, "I2C-like interface, SDA and SCL are write-only\n"); + else if (bit_adap->getscl == NULL) { + /* Complain if SCL can't be read */ dev_warn(&adap->dev, "Not I2C compliant: can't read SCL\n"); dev_warn(&adap->dev, "Bus may be unreliable\n"); } From patchwork Wed Apr 27 19:25:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 566892 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF809C43219 for ; Wed, 27 Apr 2022 19:27:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232689AbiD0TaW (ORCPT ); Wed, 27 Apr 2022 15:30:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234680AbiD0T3K (ORCPT ); Wed, 27 Apr 2022 15:29:10 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4C21E0C5; Wed, 27 Apr 2022 12:25:20 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id b19so3829131wrh.11; Wed, 27 Apr 2022 12:25:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=2dA0epvc5N7hFjokHdhzA9rWHZSUiHXiHzxOnGfMxpU=; b=IGFFKUt7JQIsHNdySLM1ofR3Imr0P2JT/oyz+z95E03Lk4Nx2J9T5o4wsyuQv3KvQ/ +SR0lQT8IrVAQmiuB+3NGzlx5SpeYk9ysPpi96Mda3KDC95UOJkQBLOBSfztNm2VzqQc M1V88lpRiLDtT/SjaYC0LN7MvZnTNLbTg1oNmjGH+C1f2qD7fB95xMFJxBRamN+Yc/Yj HQxqcBJ0jbYi9QazFvDDvtGhia4pqDX313BMcrly/FnDPa8o3Zq6L4vI9np93XouNR3+ NxDiKnR4KGI8803tqXEen0Hm4O04TJDDGK+WYKbd9Fm0+WFpTdx8FmRrLGAOk5go1xHr +fTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=2dA0epvc5N7hFjokHdhzA9rWHZSUiHXiHzxOnGfMxpU=; b=u4I9COGfG3VuffKWM9IcOIPB31IXCd8vbnc6rk/mtmC7CED8xw0pUGnebhUParY+m/ HKxI/fVz7JFr3O6Bcw1owlRLQipxT2P1NiE+SAq9CKwi80Uzz1zUfOrMjIasZAtQqDIx bzO0gU0Nl373xqkettgnOMu0cHJgyclIrlpzi1084NSNpbNadJfeNGICYZSvlQSRuqfk iRmcbaq6uS1AS4xE7d4kSE08mWkYRsBHz9hHiSC0JVogCudvzYmjkrL1CKnr3Ec2yobo 71ssHQEkSTv7RKti2GWjDU4yxwFJJfOtxFX6fV5mSEoumQ0U0zbzZ04/y31qqGwKH1nU a44Q== X-Gm-Message-State: AOAM533OSyhDPuxiJnTrLMwya8Z24xu4HSqc3OPynBoGy604SAt8yZNt 6Kh4zo/GQ/aXzq2iP99FzhI= X-Google-Smtp-Source: ABdhPJyUgdwqrY0LJ60zNceNP7pBaKZhGApLpuyuV47K1MZjJHyZWBfCsy243tfP2WkjfLepXUbKVg== X-Received: by 2002:adf:f6c4:0:b0:20a:cd34:9f68 with SMTP id y4-20020adff6c4000000b0020acd349f68mr20552551wrp.122.1651087518650; Wed, 27 Apr 2022 12:25:18 -0700 (PDT) Received: from ?IPV6:2a01:c23:c002:fc00:393a:1fdf:a518:6420? (dynamic-2a01-0c23-c002-fc00-393a-1fdf-a518-6420.c23.pool.telefonica.de. [2a01:c23:c002:fc00:393a:1fdf:a518:6420]) by smtp.googlemail.com with ESMTPSA id m41-20020a05600c3b2900b00393e6f6c130sm2245143wms.42.2022.04.27.12.25.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Apr 2022 12:25:18 -0700 (PDT) Message-ID: Date: Wed, 27 Apr 2022 21:25:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: [PATCH v2 3/3] i2c: gpio: support write-only sda Content-Language: en-US From: Heiner Kallweit To: Rob Herring , Krzysztof Kozlowski , Wolfram Sang , Wolfram Sang Cc: "linux-i2c@vger.kernel.org" , "devicetree@vger.kernel.org" References: <3e6c934e-5298-42c5-c346-31b1acaa06ba@gmail.com> In-Reply-To: <3e6c934e-5298-42c5-c346-31b1acaa06ba@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org There are slave devices that understand I2C but have read-only SDA and SCL. Examples are FD650 7-segment LED controller and its derivatives. Typical board designs don't even have a pull-up for both pins. Therefore don't enforce open-drain if SDA and SCL both are unidirectional. This patch makes i2c-gpio usable with such devices, based on new DT property i2c-gpio,sda-output-only. Signed-off-by: Heiner Kallweit --- drivers/i2c/busses/i2c-gpio.c | 14 +++++++++++--- include/linux/platform_data/i2c-gpio.h | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index 7a048abbf..0a87af4a7 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c @@ -316,6 +316,8 @@ static void of_i2c_gpio_get_props(struct device_node *np, of_property_read_bool(np, "i2c-gpio,scl-open-drain"); pdata->scl_is_output_only = of_property_read_bool(np, "i2c-gpio,scl-output-only"); + pdata->sda_is_output_only = + of_property_read_bool(np, "i2c-gpio,sda-output-only"); } static struct gpio_desc *i2c_gpio_get_desc(struct device *dev, @@ -363,6 +365,7 @@ static int i2c_gpio_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; enum gpiod_flags gflags; + bool sda_scl_output_only; int ret; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); @@ -391,8 +394,12 @@ static int i2c_gpio_probe(struct platform_device *pdev) * marking these lines to be handled as open drain, and we should just * handle them as we handle any other output. Else we enforce open * drain as this is required for an I2C bus. + * If SCL/SDA both are write-only, then this indicates I2C-like slaves + * with read-only SCL/SDA. Such slaves don't need open-drain, and partially + * don't even work with open-drain. */ - if (pdata->sda_is_open_drain) + sda_scl_output_only = pdata->sda_is_output_only && pdata->scl_is_output_only; + if (pdata->sda_is_open_drain || sda_scl_output_only) gflags = GPIOD_OUT_HIGH; else gflags = GPIOD_OUT_HIGH_OPEN_DRAIN; @@ -400,7 +407,7 @@ static int i2c_gpio_probe(struct platform_device *pdev) if (IS_ERR(priv->sda)) return PTR_ERR(priv->sda); - if (pdata->scl_is_open_drain) + if (pdata->scl_is_open_drain || sda_scl_output_only) gflags = GPIOD_OUT_HIGH; else gflags = GPIOD_OUT_HIGH_OPEN_DRAIN; @@ -418,7 +425,8 @@ static int i2c_gpio_probe(struct platform_device *pdev) if (!pdata->scl_is_output_only) bit_data->getscl = i2c_gpio_getscl; - bit_data->getsda = i2c_gpio_getsda; + if (!pdata->sda_is_output_only) + bit_data->getsda = i2c_gpio_getsda; if (pdata->udelay) bit_data->udelay = pdata->udelay; diff --git a/include/linux/platform_data/i2c-gpio.h b/include/linux/platform_data/i2c-gpio.h index a907774fd..928c87b00 100644 --- a/include/linux/platform_data/i2c-gpio.h +++ b/include/linux/platform_data/i2c-gpio.h @@ -16,6 +16,7 @@ * isn't actively driven high when setting the output value high. * gpio_get_value() must return the actual pin state even if the * pin is configured as an output. + * @sda_is_output_only: I2C-like interface, SDA is write-only. * @scl_is_open_drain: SCL is set up as open drain. Same requirements * as for sda_is_open_drain apply. * @scl_is_output_only: SCL output drivers cannot be turned off. @@ -24,6 +25,7 @@ struct i2c_gpio_platform_data { int udelay; int timeout; unsigned int sda_is_open_drain:1; + unsigned int sda_is_output_only:1; unsigned int scl_is_open_drain:1; unsigned int scl_is_output_only:1; };