From patchwork Tue Jul 27 16:03:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 488142 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB23CC4338F for ; Tue, 27 Jul 2021 16:03:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9899D61B7B for ; Tue, 27 Jul 2021 16:03:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229532AbhG0QD3 (ORCPT ); Tue, 27 Jul 2021 12:03:29 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38968 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229441AbhG0QD3 (ORCPT ); Tue, 27 Jul 2021 12:03:29 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16RFgWEH103302; Tue, 27 Jul 2021 12:03:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=tzEgKGyj8W0dnaCzQaQnjISWyFObQwE3HIBtnrO+VzQ=; b=apDqCTUHa4DBmwxrJYhghtEQs+sYiPjUMqUt2QSX8rde87Tg1FJBY5Ysu08GMALCcFEg UzAz2BIUzhnt1+Kb9isfBIIewKBNBofUcMM4OfQ2Pkp+1XDv0wPXwi0DFos6iyklRTuz BIS8yW3f2E2EU1Mgo2dE9emXHLDeLI78D9TeGK6/7KtNlcxVQkfpOLgh4wu22Cg0GaOj vb4F0bBWdzO5DECULETjzlLPNQm0szJVYbgpNmo0Q48q1gl8FACtfE+J9Qm62+nesSlN O6a2A5VotfiyVAnY9+6dlnCN/2fJrWG1C4tmpSI9IZgC+duM3YPh1u9dulu0W98Flaog Uw== Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0b-001b2d01.pphosted.com with ESMTP id 3a2mhb9wq6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Jul 2021 12:03:23 -0400 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16RG2IAn006929; Tue, 27 Jul 2021 16:03:22 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma01wdc.us.ibm.com with ESMTP id 3a236128bf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Jul 2021 16:03:22 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16RG3LBE25755996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Jul 2021 16:03:21 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C6E58BE063; Tue, 27 Jul 2021 16:03:21 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 78218BE04F; Tue, 27 Jul 2021 16:03:21 +0000 (GMT) Received: from v0005c16.aus.stglabs.ibm.com (unknown [9.211.139.59]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 27 Jul 2021 16:03:21 +0000 (GMT) From: Eddie James To: linux-i2c@vger.kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, peda@axentia.se, robh+dt@kernel.org, Eddie James Subject: [PATCH v2 1/2] dt-bindings: i2c: i2c-mux-pca954x: Define the reset-shared-hogged gpio Date: Tue, 27 Jul 2021 11:03:14 -0500 Message-Id: <20210727160315.15575-2-eajames@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210727160315.15575-1-eajames@linux.ibm.com> References: <20210727160315.15575-1-eajames@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Vyf720QxfoeiT0OonjgbZUU4fAMmIVgO X-Proofpoint-ORIG-GUID: Vyf720QxfoeiT0OonjgbZUU4fAMmIVgO X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-27_10:2021-07-27,2021-07-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 malwarescore=0 phishscore=0 adultscore=0 suspectscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2107270093 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add a property to describe a reset input that is shared between multiple PCA953x muxes. Signed-off-by: Eddie James --- Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml index 9f1726d0356b..06b9f8385bd7 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml +++ b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml @@ -49,6 +49,11 @@ properties: reset-gpios: maxItems: 1 + reset-shared-hogged-gpios: + maxItems: 1 + description: Reference to a shared, hogged GPIO connected to the reset + input of several PCA954x muxes. + i2c-mux-idle-disconnect: type: boolean description: Forces mux to disconnect all children in idle state. This is From patchwork Tue Jul 27 16:03:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 486911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04786C4338F for ; Tue, 27 Jul 2021 16:09:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D916761B73 for ; Tue, 27 Jul 2021 16:09:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229636AbhG0QJp (ORCPT ); Tue, 27 Jul 2021 12:09:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:27279 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229658AbhG0QJo (ORCPT ); Tue, 27 Jul 2021 12:09:44 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16RG4ctn129513; Tue, 27 Jul 2021 12:09:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=tHitE0CZyHx+5CmS/wzGU1uVXS4acUw969HBGjcmvCs=; b=DCqrVLjmDC/bxHUGYEcT4lVFX33tr5A93B8BMBC+WzdKixo0Rqy82C6eJFdz8XAdYy8q xuQHycIVtJi+QowzXry25yyBETSivZDSZeMIXLlyvvPof9nsf3b0tAmTbqv224J2GmGK tB5IwfSDtzHheo9TPMp00se0TOAo/FdPvXIYburSE/mnXwsWJ/ZC3WR3xrLYTE8aCPf9 cQZO/mqlJRYodTEg5bzR0JT+IUJK7ha3NW2s6ydMeDc8GFUn4rxEJdOd2RLlm76H/Vnw Ik2YMq5Jw/wf0JScX8PyGQqdJGGtuAvtKzob70YXV9mUn4e8RWXh0OagoXPyjsWTpK1B SA== Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0b-001b2d01.pphosted.com with ESMTP id 3a2kbd5qe7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Jul 2021 12:09:39 -0400 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16RG49tq019697; Tue, 27 Jul 2021 16:04:38 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma02dal.us.ibm.com with ESMTP id 3a2362j0qt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Jul 2021 16:04:38 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16RG3M1o46924260 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Jul 2021 16:03:22 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B597BE063; Tue, 27 Jul 2021 16:03:22 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E23DBBE04F; Tue, 27 Jul 2021 16:03:21 +0000 (GMT) Received: from v0005c16.aus.stglabs.ibm.com (unknown [9.211.139.59]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 27 Jul 2021 16:03:21 +0000 (GMT) From: Eddie James To: linux-i2c@vger.kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, peda@axentia.se, robh+dt@kernel.org, Eddie James Subject: [PATCH v2 2/2] i2c: mux: pca954x: Support multiple devices on a single reset line Date: Tue, 27 Jul 2021 11:03:15 -0500 Message-Id: <20210727160315.15575-3-eajames@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210727160315.15575-1-eajames@linux.ibm.com> References: <20210727160315.15575-1-eajames@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: y39omJr1lIcXvIhVYrA1oL_7PyHTQ8jo X-Proofpoint-GUID: y39omJr1lIcXvIhVYrA1oL_7PyHTQ8jo X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-27_10:2021-07-27,2021-07-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 suspectscore=0 malwarescore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2107270097 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Some systems connect several PCA954x devices to a single reset GPIO. For these devices to get out of reset and probe successfully, each device must defer the probe until the GPIO has been hogged. Accomplish this by attempting to grab a new "reset-shared-hogged" devicetree property, but expect it to fail with EPROBE_DEFER or EBUSY. Signed-off-by: Eddie James --- drivers/i2c/muxes/i2c-mux-pca954x.c | 46 +++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 4ad665757dd8..376b54ffb590 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -434,15 +434,43 @@ static int pca954x_probe(struct i2c_client *client, i2c_set_clientdata(client, muxc); data->client = client; - /* Reset the mux if a reset GPIO is specified. */ - gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); - if (IS_ERR(gpio)) - return PTR_ERR(gpio); - if (gpio) { - udelay(1); - gpiod_set_value_cansleep(gpio, 0); - /* Give the chip some time to recover. */ - udelay(1); + /* + * Grab the shared, hogged gpio that controls the mux reset. We expect + * this to fail with either EPROBE_DEFER or EBUSY. The only purpose of + * trying to get it is to make sure the gpio controller has probed up + * and hogged the line to take the mux out of reset, meaning that the + * mux is ready to be probed up. Don't try and set the line any way; in + * the event we actually successfully get the line (if it wasn't + * hogged) then we immediately release it, since there is no way to + * sync up the line between muxes. + */ + gpio = gpiod_get_optional(dev, "reset-shared-hogged", 0); + if (IS_ERR(gpio)) { + ret = PTR_ERR(gpio); + if (ret != -EBUSY) + return ret; + } else { + if (gpio) { + /* This is really a problem since now we don't know the + * state of the gpio. Log a warning and keep trying to + * probe the mux just in case it works. + */ + dev_warn(dev, "got hogged reset line, expect error\n"); + gpiod_put(gpio); + } else { + /* Reset the mux if a reset GPIO is specified. */ + gpio = devm_gpiod_get_optional(dev, "reset", + GPIOD_OUT_HIGH); + if (IS_ERR(gpio)) + return PTR_ERR(gpio); + + if (gpio) { + udelay(1); + gpiod_set_value_cansleep(gpio, 0); + /* Give the chip some time to recover. */ + udelay(1); + } + } } data->chip = device_get_match_data(dev);