From patchwork Sat Aug 17 15:06:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wojciech Siudy \(Nokia\)" X-Patchwork-Id: 820101 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2086.outbound.protection.outlook.com [40.107.241.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FD188C13 for ; Sat, 17 Aug 2024 15:07:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723907224; cv=fail; b=itHfLo1hYeNUPew26y3Ods+uFXc/SplK71kv+WaS22l8k0gqbfLFyrVBnTe6pyAIjTN190dOCe8r1Zer9nGLLK8yzyzYo7jGSOnLtZvSuE3Q4kK+UmwwWZwaTC9zoWenxbfB5ajeOQDCcRoLiJxd+1rbj5PbtHkCtjDbKffglvA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723907224; c=relaxed/simple; bh=sDnd2sZpCD43Ixa00gUFc381Olwwqv6YNQk9upBaLjg=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=balJxCwfxST41ovyyTugERnYr9x+Ztex5tEn83nbRN7uXzMxP2coFNNJ3c3Eq7egV44SUuXtZ6nYsRYdKQrCaaRmlsr1rHDbhvFQig3CFruQjglz4VDitpBYxmm9pp/z4TWoa9rQNHFQyz44weuxFSKO4WHS5xPVvqAZdbGQo8A= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com; spf=fail smtp.mailfrom=nokia.com; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b=BAilZ8vQ; arc=fail smtp.client-ip=40.107.241.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b="BAilZ8vQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oIJb7NlJMotkeljZYycZZR7O+8Dm3UoeLRWdloSet2mNk2yeUfz3e9tkMHqHGTbNsIsdp2kEVUiUn7EffHPjIiAYZMq6r92XRxtcesX95Fs+C6iuHjP9pByO2TgFBk3zeJLxwiGa/2MYwfKM6BCB2T8K0qj6tvGs9Ran3kT1WCuODXqEJTszVajY+as+7IWhfA5V59WphrQpTAnsiwjjlDm3XQdf6ORf9uQp4GDtAqcHI35u7QSaMI90VW+lOBHor+ZjxX2euouGmOpeRiBp68HUtplsCOuYKwebe2diRHJmFsizpiVbOh/Sal731BwRPGUl1OrkxY715TcEAZGYOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ngTwvUoRxaNzyADWyiQ/071+0m/XZYMMMTQonn8x2z0=; b=gI2jBboNtpjjvR95VlHQkw85jsmUP/IZLAqyrHtare9P2ArsmvmE8Tx/bl7msPknTqR1Zju37JsaEfxKlMPjfqYQb3RahfTCSj9jb/xboggp/FsNkNuOK28JrPXdijgz9cY9afe0wvk2j88QJW12xewAB3R3SZSWfJC/RY0TI7idYQ47VSId4/DhwHxG685KQDUbBWB79MakwE2f3IthZFI0qa31MustjCtnhQhwSDVzI13iESEQuLWxeqd8MKcYlGBTLP2ScKJiqhFaLdw5+bHF2yT0SMBTB+Kaw3xsMzzO9Q+SFQH4RD34MIEk88DHlxo9y3CI0ksCDEFfQO5uKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ngTwvUoRxaNzyADWyiQ/071+0m/XZYMMMTQonn8x2z0=; b=BAilZ8vQ/m/z2vpRaGUEP6KGum4hzB7Pm7Zl+18PXjbkSN7qK1UHHxgOvE8pivSwzs36mDpK6u/xKHgbQww4NREObCPeilUfb93EtzAuGbj23UE3nbeKwAC6GrfY+F/BGfpqDhsTf/e25NHIOGtMzff4S1Qsb0KJcg3YmaHp+1q9s7f0WdPzpaTV7QoXRSXTcmLVNQYcqrOJgoV38Gf2jQNum3/bqZaOToPx5WLW6GJIScJaUaTkzBVumC7gwyVQUm5jslq0M11s+rwZtwGldmo0tWiqmImeh1nHDF2846gCIzrzzJUAVHS6Z7q7WdbIL2o7uQIUeFulxBOgcef9yA== Received: from DB6PR07MB3509.eurprd07.prod.outlook.com (2603:10a6:6:21::16) by DBBPR07MB7435.eurprd07.prod.outlook.com (2603:10a6:10:1e2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.20; Sat, 17 Aug 2024 15:07:00 +0000 Received: from DB6PR07MB3509.eurprd07.prod.outlook.com ([fe80::5484:a966:1322:f78b]) by DB6PR07MB3509.eurprd07.prod.outlook.com ([fe80::5484:a966:1322:f78b%6]) with mapi id 15.20.7875.016; Sat, 17 Aug 2024 15:06:59 +0000 From: "Wojciech Siudy (Nokia)" To: "linux-i2c@vger.kernel.org" CC: Andi Shyti Subject: [PATCH v2] pca954x: Reset if channel select fails Thread-Topic: [PATCH v2] pca954x: Reset if channel select fails Thread-Index: AQHa79MbyYnkGBOn7E2e85VmQT3fTw== Date: Sat, 17 Aug 2024 15:06:59 +0000 Message-ID: Accept-Language: pl-PL, en-US Content-Language: pl-PL X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DB6PR07MB3509:EE_|DBBPR07MB7435:EE_ x-ms-office365-filtering-correlation-id: bbb61bba-9464-471f-bcad-08dcbece3de4 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|376014|1800799024|366016|38070700018; x-microsoft-antispam-message-info: =?iso-8859-2?q?VZXiaKZGTPH61xC8HAW2fDmIR/?= =?iso-8859-2?q?G3P4URDMbJ5HrdqusXw9ruCL3Q2qtu5BmeiFNs82WLcbkmIZji0+f1pWRt61?= =?iso-8859-2?q?1XYHJCDpdH7kkucktHZ41t7Nmw1zViFlD1Hqcd6Id/+6A4exGB3I506ZKjdl?= =?iso-8859-2?q?GJCL+ofR/NVgTAHh3AVlEL/Id9QcNqStJwMrDE4URCSkF5PVx3EDRasIhFzk?= =?iso-8859-2?q?NrhYU56XU7tR766kUxUvgfTCO45Ol/1eJNlO8FNEAXWSWxzQdX9rP5Fha4FL?= =?iso-8859-2?q?30+fls5R5PJsd2BWEdfCHIgVsAwFknwd8ssun76yqUgCbm65kAapP3OlBOKf?= =?iso-8859-2?q?VwMiRaRJBk9Wgbt74pPrfEwXe+dJpwYoN2t0R80sTmGcPoN1XwSxYUBEy4uR?= =?iso-8859-2?q?4SN0naq56CmJMF+F/K2DrSU5EwjLnanze4k9MPMtqOiAXSrM/M2417PCcgW1?= =?iso-8859-2?q?mY6Ymh24UhuUXwdp/YcWMVYC+SF77e4PKhR8a2NnS8kMvw1RQA4BEib7NmlP?= =?iso-8859-2?q?I6Z9c2DlRi/bb9LLu9GbQu3AAbdq4x2Aw5ZIOONsk0dIeaTRRfQkB4CWnLXo?= =?iso-8859-2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93dw=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR07MB3509.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-2?q?2nIxOKtpbPnjDLD9zctZguD?= =?iso-8859-2?q?Vi/+wWh10oKSa4eiBggp24zqmGOlxZZuPUweJGGX1DL8oUPtqXoUxk3nLFd7?= =?iso-8859-2?q?aW2kBDyDeC+dz5S7gTD1yTqNRVH/vDkLvUKCJDxOlenQsOGgSn0FrVtpYMRg?= =?iso-8859-2?q?U+9E4Q+MwJYwexZoAc5Zmlhn03aFD1EPDzzjrvZO36HnI4lh5k9fQ10TPaZl?= =?iso-8859-2?q?3a7inTcOCIKJhrzCNwDdZC2yTvSChT4OhTsP5EsEhbXrpIShFUb5Gy5z01Va?= =?iso-8859-2?q?6Gv5V2COOWgV2g//Ql84sgQUbWxCSOjacRsCIxAf5Q2oCM15BthxvBhRXFtU?= =?iso-8859-2?q?zUm2viqBfItq996k+GHeHEzUKGg9GLV+kJbTvuiUyos1jdWoKvc6mzgDfMPq?= =?iso-8859-2?q?CZ4S6DZLLmgKHF0mpAkDfPrxmqMCRdVZ4Z7CoZBRPPZPduQbiOC9MFgGiwvF?= =?iso-8859-2?q?VIo3e7rbYeL906m2b7xHUM329jFSMxWp2sLKbbK3KU5oevU1Cl+Xf0cZZr4a?= =?iso-8859-2?q?6GUTy/B5f/mOYK+dMjHocyVF+p99fxkzc3DpA1DXY5H2qzVOjfuQMazyaI1n?= =?iso-8859-2?q?GcJG+i1nyP2tZebOwLf/DHE2g6+SPSetQrmy4SMc7C5Tjaj6aJD6cXKCakOs?= =?iso-8859-2?q?/gYZLN1mAyrC+nk1bqvU//PKXJ1Wu22siHiUsH64dpRM9qsk0mHWVvSbINNH?= =?iso-8859-2?q?6MdLknBRO+xP8vzBdUVf1xw5pJsw09iC0n+49iHYP83hwBtbhpxg1qdGkZfG?= =?iso-8859-2?q?naqhPuYTIN+77UhkG1p1+WUPLy1NOe8aZwlvU6pTbj6tNwI+pMRkrCI7Zr9F?= =?iso-8859-2?q?jWhcy89DzrRvVtjebMOvvliint0P5aoHtaEyBqRMvK9gXLKLj8X4my/4h+JQ?= =?iso-8859-2?q?erY53HgqZBL4ItJX+2tuwWQfAMXYaoDMc7NZRl0w4S3FRmsHJ/0j3bFyZT25?= =?iso-8859-2?q?x2P4kvikjnFaEqAT994ul/z7KWx/mqaAePtYSPPEdMZunkdvBKO88Ua/8bL+?= =?iso-8859-2?q?O+kRub3KiONDFMHeizEbLe9Oc8uhADPBWSRPk+eFti/HeoVWXCrdVbJ2UlCc?= =?iso-8859-2?q?m4yrl81a6Y0DEewLC57deB4IDWfsRykXYt2lZC24YrZx08BxMTtLmvgI7dyc?= =?iso-8859-2?q?1Lj/34eWjPg7rbxqoRD1ioi/naGNdxr31brRWZKR7XGqiutC6PI6emJ8a/Fv?= =?iso-8859-2?q?Qo4oqOMBFQZh4gWMMCRcuVxyxaWdeCvLAicj0HzzOL1OAk/Hl0SbrrbZFGNB?= =?iso-8859-2?q?/eBbs/UuhIs5QYYiQjus82EVTOQv9q8Se71Rn9+w2jiZAze4FZbapFnD2Ghf?= =?iso-8859-2?q?IZChnAXr3mhhg7vsWB+1R7qh1WFTDp8UTy66m1fWNw1AYjqmIPcO6VTx1e49?= =?iso-8859-2?q?GyvnhreTxXl1Ubw8jdieSvJQeShnPdoCkQ6oOxz8qEx/lqlUjXIdIg+NrSNh?= =?iso-8859-2?q?VfufS/c7XKxb73KuEgBHR8A5nJeVNSDX6pvC8HY7tu/sby4Py80vuinw6Cme?= =?iso-8859-2?q?L8TIFZ92JC4iIsz1xv0V0p63EYNEs7X3QoUddAsXJQ9JDMJKLcdnZy3qaKL5?= =?iso-8859-2?q?da0ULfCMgcQ0mmL86IGo7bft0gYTyBifqMw8VCisSiGX9IQswNC0OZEg1uOm?= =?iso-8859-2?q?tl9lnQg2rqF8dAADh?= Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DB6PR07MB3509.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bbb61bba-9464-471f-bcad-08dcbece3de4 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Aug 2024 15:06:59.0607 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 4cT3oSnwPAhB+arUyC3jdVd8fIcJdv/q1krAC/yreANzMlwVoLV1w2Jdxb8LHoD5p+DR8NcCJUd815YA5T7MtJ6WCP8EHronEzG5vRX45Sk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7435 From: Wojciech Siudy Channel selection that has timed out is a symptom of mux'es I2C subsystem failure. Without sending reset pulse the power-on-reset of entire device would be needed to restore the communication. The datasheet mentions 4 ns as a minimal hold time of reset pulse, but due to paths capacity and mux having its own clock it is better to have it about 1 us. Signed-off-by: Wojciech Siudy --- Changelog: v2: * Removed mail header from the commit log * Decreased reset pulse hold time from 10 to 1 us --- drivers/i2c/muxes/i2c-mux-pca954x.c | 30 +++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 6f8401825..e09d4d107 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -316,6 +316,22 @@ static u8 pca954x_regval(struct pca954x *data, u8 chan) return 1 << chan; } +static void pca954x_reset_deassert(struct pca954x *data) +{ + if (data->reset_cont) + reset_control_deassert(data->reset_cont); + else + gpiod_set_value_cansleep(data->reset_gpio, 0); +} + +static void pca954x_reset_assert(struct pca954x *data) +{ + if (data->reset_cont) + reset_control_assert(data->reset_cont); + else + gpiod_set_value_cansleep(data->reset_gpio, 1); +} + static int pca954x_select_chan(struct i2c_mux_core *muxc, u32 chan) { struct pca954x *data = i2c_mux_priv(muxc); @@ -329,6 +345,12 @@ static int pca954x_select_chan(struct i2c_mux_core *muxc, u32 chan) ret = pca954x_reg_write(muxc->parent, client, regval); data->last_chan = ret < 0 ? 0 : regval; } + if (ret == -ETIMEDOUT && (data->reset_cont || data->reset_gpio)) { + dev_warn(&client->dev, "channel select failed, resetting...\n"); + pca954x_reset_assert(data); + udelay(1); + pca954x_reset_deassert(data); + } return ret; } @@ -543,14 +565,6 @@ static int pca954x_get_reset(struct device *dev, struct pca954x *data) return 0; } -static void pca954x_reset_deassert(struct pca954x *data) -{ - if (data->reset_cont) - reset_control_deassert(data->reset_cont); - else - gpiod_set_value_cansleep(data->reset_gpio, 0); -} - /* * I2C init/probing/exit functions */