From patchwork Wed Oct 18 21:08:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 155171 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b78e:0:b0:402:e146:ef86 with SMTP id t14csp5106289vqh; Wed, 18 Oct 2023 14:08:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHnz8tjI8rN/RAXJXoWrfxcULi0g8T+mO523HTs0Jn3W+VyN5SXAuIFtTi5GhJo3jT0zhjD X-Received: by 2002:a05:6870:1394:b0:1ea:14eb:b741 with SMTP id 20-20020a056870139400b001ea14ebb741mr561774oas.54.1697663333046; Wed, 18 Oct 2023 14:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697663333; cv=none; d=google.com; s=arc-20160816; b=J1qGwxmid5xEmJgUpFSP6BCT25j+4ZTaiGaq+46pHzBbt8CxJDTAABZ+rV5xSJX822 ubmxCSJXXRCmOZksTy3JTKWWWjpOlt/h5EyeUad7Mq5CjxpLINWCe9mnNG6FSFPuyMNp qkDZJp5ccJ8/y/b/0yrNWaN33YwO60fkGuT9UGFFDzCUA7NGO25qm00ctQPVmA0tbQTm NeE3RRi+vcj6IdTv6adU+JG7mvx1Xy+sD2J/tnbDaDgi8d9FoBoBlFY5FZqBJjvIeDgv vDIpjevCYmUaFr9dyFW2CIRAqK62qKuWg262LMBWFnHhdjgM013O7tKs06QHUFUmjhem ESaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gqjjlKTu73EKTbIjc+Nes5NFC/xjbovCV1p0fBg4XUQ=; fh=3tQj0XukzIaVVOd6lLPEALhtzKzMAG+0/N98Vq3ytYw=; b=bCy9VKNF64hgATM4pCTzjlMLroW+mmUdgRRBJzpfF53ZmbOA4oniaP5BWcGgku/g7S 7gWD/dMBxZcFzi3mWUfukrX7IH+rBBTOu8sIem3+b8GA88ag6QvXUhgIRxL3wx4X17as ZQg/bW2OSyJUSKxVCNyCaCPAzY63Nnqa4qCW/DijvvxAVx3HTeHY7hdQciiy0FGWfAHG 7kEbhVxrzwewWdMou/GUmqYtfZjILef4P7DraXfQTYS8OVG5BFRri2R3SEjjKAYFCmZq KKkHycjheh13kLajIy3v6z2zuuH+/y2XGZzM6VOekhgsVCEvP9HgkojimcRCdEFhWnvI 3ZIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=LaC81BLF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ch5-20020a056a0208c500b005b81f21a261si3092594pgb.747.2023.10.18.14.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 14:08:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=LaC81BLF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id D0E468112A86; Wed, 18 Oct 2023 14:08:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232281AbjJRVIY (ORCPT + 24 others); Wed, 18 Oct 2023 17:08:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231913AbjJRVIR (ORCPT ); Wed, 18 Oct 2023 17:08:17 -0400 Received: from gate2.alliedtelesis.co.nz (gate2.alliedtelesis.co.nz [202.36.163.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5B7E18C for ; Wed, 18 Oct 2023 14:08:13 -0700 (PDT) Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 165192C027A; Thu, 19 Oct 2023 10:08:10 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1697663290; bh=gqjjlKTu73EKTbIjc+Nes5NFC/xjbovCV1p0fBg4XUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LaC81BLFbzLPwF2FE5Iw5P808xj561SjJ+odwE9ZXjlJpFNLGEXO2NOF/5vRve0sf 2fsbkxGlWP3hZNfEVVjZBDpCtVn9pa0vMES5Xtl/WBozwryyl55+Bst28gk2MtpRCO wCj6mUasup5vBtstzR9mfEbQVUIzklIsvykaLA3H7cetGspRj0lObiJQZqdyTsNdoF E3VHQ4SOlYSf8hiSWcrNWO60zCpbm3ALN06x2BYeJG1VYJZfhAY3I8nJcptKeHRXqG O+zYke7J3TZH5PdpV71rOlauzJHbZwAmhC/eLpXRB4rllp8Z0ZG8jn08gbzMPSTdu+ 2luiEBnDSWSQA== Received: from pat.atlnz.lc (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id ; Thu, 19 Oct 2023 10:08:09 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by pat.atlnz.lc (Postfix) with ESMTP id 5BB9213EE85; Thu, 19 Oct 2023 10:08:09 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 5A95C280450; Thu, 19 Oct 2023 10:08:09 +1300 (NZDT) From: Chris Packham To: gregory.clement@bootlin.com, andi.shyti@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH v3 2/2] i2c: mv64xxx: add an optional reset-gpios property Date: Thu, 19 Oct 2023 10:08:05 +1300 Message-ID: <20231018210805.1569987-3-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231018210805.1569987-1-chris.packham@alliedtelesis.co.nz> References: <20231018210805.1569987-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.3 cv=L6ZjvNb8 c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=bhdUkHdE2iEA:10 a=VsZq4EHS3crWG1I_hwYA:9 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 18 Oct 2023 14:08:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780129026961839900 X-GMAIL-MSGID: 1780129026961839900 Some hardware designs have a GPIO used to control the reset of all the devices on and I2C bus. It's not possible for every child node to declare a reset-gpios property as only the first device probed would be able to successfully request it (the others will get -EBUSY). Represent this kind of hardware design by associating the reset-gpios with the parent I2C bus. The reset line will be released prior to the child I2C devices being probed. Signed-off-by: Chris Packham --- Notes: Changes in v3: - Rename reset-delay to reset-duration - Use reset-duration-us property to control the reset pulse rather than delaying after the reset Changes in v2: - Add a property to cover the length of delay after releasing the reset GPIO - Use dev_err_probe() when requesing the GPIO fails drivers/i2c/busses/i2c-mv64xxx.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index efd28bbecf61..28f11d2e800b 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c @@ -160,6 +160,7 @@ struct mv64xxx_i2c_data { bool clk_n_base_0; struct i2c_bus_recovery_info rinfo; bool atomic; + struct gpio_desc *reset_gpio; }; static struct mv64xxx_i2c_regs mv64xxx_i2c_regs_mv64xxx = { @@ -1036,6 +1037,7 @@ mv64xxx_i2c_probe(struct platform_device *pd) struct mv64xxx_i2c_data *drv_data; struct mv64xxx_i2c_pdata *pdata = dev_get_platdata(&pd->dev); struct resource *res; + u32 reset_duration; int rc; if ((!pdata && !pd->dev.of_node)) @@ -1083,6 +1085,14 @@ mv64xxx_i2c_probe(struct platform_device *pd) if (drv_data->irq < 0) return drv_data->irq; + drv_data->reset_gpio = devm_gpiod_get_optional(&pd->dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(drv_data->reset_gpio)) + return dev_err_probe(&pd->dev, PTR_ERR(drv_data->reset_gpio), + "Cannot get reset gpio\n"); + rc = device_property_read_u32(&pd->dev, "reset-duration-us", &reset_duration); + if (rc) + reset_duration = 1; + if (pdata) { drv_data->freq_m = pdata->freq_m; drv_data->freq_n = pdata->freq_n; @@ -1121,6 +1131,11 @@ mv64xxx_i2c_probe(struct platform_device *pd) goto exit_disable_pm; } + if (drv_data->reset_gpio) { + usleep_range(reset_duration, reset_duration + 10); + gpiod_set_value_cansleep(drv_data->reset_gpio, 0); + } + rc = request_irq(drv_data->irq, mv64xxx_i2c_intr, 0, MV64XXX_I2C_CTLR_NAME, drv_data); if (rc) {