From patchwork Fri Aug 9 08:17:52 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: 1970849 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=nokia.com header.i=@nokia.com header.a=rsa-sha256 header.s=selector2 header.b=FQOmlE+p; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=linux-i2c+bounces-5245-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WgGxl5vGjz1ybT for ; Fri, 9 Aug 2024 18:18:03 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4E8901C21822 for ; Fri, 9 Aug 2024 08:18:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B8D3818CC08; Fri, 9 Aug 2024 08:17:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b="FQOmlE+p" X-Original-To: linux-i2c@vger.kernel.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2069.outbound.protection.outlook.com [40.107.22.69]) (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 54D0016D4D4 for ; Fri, 9 Aug 2024 08:17:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723191477; cv=fail; b=BSBZOy45iC44RDpgGOweCFk92ckGe0xQ49S2WaMxr8w1P1g4SDQB8PuWy7I+6lwx2O2bkcSwPHtZn+uyef/zQRIxX5ztpe6TNocFLhaqN8U5QcwLqQaI+jKRGjl5PnEL6DBRG3x7HYMYR8rVGqWXg8IZtizt7Vn4uC6nFGSCcnE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723191477; c=relaxed/simple; bh=lU7NJIZ4L8V5J8bPMls3Ddxoq8bGw7rx5bGV79FXxw8=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=X9HWL88/pc3BPGWkqVJ8Q+8jfdIXAXIM4KrPHVVhVVAxUU6OChEmOI2t52ulZV0h8T2rhHNrya/avKT9jIiwDeWll/pKLbVzOXEbhhdw1i+KCJBctOIawuhU37MGQttEw4pIGvUqoUbkfNlChPngl5IO0sW9eMnWtUR5W2UvUjQ= 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=FQOmlE+p; arc=fail smtp.client-ip=40.107.22.69 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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eq7GEsf2ksLJ9rky9yeMR814zNfDkIXWrQ9DtgE4PbpurIEOM/YuB8FjbSLhIraJUD7RyE6P3ykDZq1XhmdKBjEMEBLY2hp+0Y3b/XTKQ1DwcJIRcDNMTOTNK3adg7USItQWJjpYRxkEfArsYpRBjSDTxyGYFXaD3KpYuzrabtxkFMFtJmOQ/fnqTPRzghwm74Mi31lJjlOspCRXU7SVuTBKl03gJlxCdleclk84J2mFqP3qYlJuSVboOiGy+lMZ35EOxn5vThwD9VNxl/C5m3XiZWPMJA6atHrvkbDZNvx9uZ0ZoRGQpj51pz83ct2sOB64gkt/5tbMq3ZWwZa0Bg== 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=vm7TtEQ3aUiMZI+g72VNpCAEQ6bQ235UnsW6mSZiQC8=; b=g66oUOWG/FOcqrlS78CeiIrmSCiCHzR9zmUloKoA5dw9l3MHvVgudcXjCw1Pak9587Rx2XijIfh0dMVa5TApUzt5u3VNHysxZ9ycCZtcqqumnulns/Jg3CDeA9UwSoWuXFjF+quZSpC937rJ6dmoVCW985HWnaSdyIu0S8hwl7AXE8mN0Olskgc4SX0wZ36PfKYkQU8o2j73j1qJscv6cDsrzTQo2Axs0S67zS4qStxGwcjEbRlsLnkT2mazXGtLd/M7L+c2ruTtY/XT6spMDd/YVPruZ+JEC4yy7CZr9LYn4xnXfeeiXNiCGDrGa7cVkcSN9N3QTS8AzJ4Mbq1lDQ== 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=vm7TtEQ3aUiMZI+g72VNpCAEQ6bQ235UnsW6mSZiQC8=; b=FQOmlE+peVk9scIatkc8Q5s0tVWuVDL2PpQYf1mU9braX/B6MfvcSp5oQ11AbtxU3xhcrxBTf78aoClGy2QvyCFUjQHl3oud7ft5Y0cGDBYiViL0LtCjVh4UzsdbMsPBelfCGkFVQ9G3No2Qn+M920wVMP8F0/ISi0fJ9t9Tck6ux4cfA3zOdMifS5IQY2nnxjiZBSemSGKJ7eivQSF/c7y0wjlgs2HIzAWTgYMA/edHzA+rudD4SRTIDgQ8yeGkCuIoGPn6eGhaUmmLsbQvI6zajvUNGcyiso/WHigBBA4f/PXKZj8iEkcVvh3Okm9hSr7guHx0Cum10MHofPijRw== Received: from DB6PR07MB3509.eurprd07.prod.outlook.com (2603:10a6:6:21::16) by AM7PR07MB6948.eurprd07.prod.outlook.com (2603:10a6:20b:1bd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Fri, 9 Aug 2024 08:17:52 +0000 Received: from DB6PR07MB3509.eurprd07.prod.outlook.com ([fe80::5484:a966:1322:f78b]) by DB6PR07MB3509.eurprd07.prod.outlook.com ([fe80::5484:a966:1322:f78b%5]) with mapi id 15.20.7849.013; Fri, 9 Aug 2024 08:17:52 +0000 From: "Wojciech Siudy (Nokia)" To: "linux-i2c@vger.kernel.org" Subject: [PATCH] pca954x: Reset if channel select fails Thread-Topic: [PATCH] pca954x: Reset if channel select fails Thread-Index: AQHa6jQddQPwTX4+5E2Bd0WqFVKNFw== Date: Fri, 9 Aug 2024 08:17:52 +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_|AM7PR07MB6948:EE_ x-ms-office365-filtering-correlation-id: a998a918-69e1-4427-d596-08dcb84bc37e x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|376014|366016|38070700018; x-microsoft-antispam-message-info: =?iso-8859-2?q?60q37G2jqfVhzik7RRHJfyv5Pn?= =?iso-8859-2?q?j/z/6yrfWapTIbY6AwJu5eHJZBFNEgsjtfR5529LI+A/7tfkghyNfuEkA6ES?= =?iso-8859-2?q?5ylBJhB0v1ZHB/ZEcL0nZgTvZgmTkbqd+NOJT+QfxtsfY7RrmGmjtAqjR/+6?= =?iso-8859-2?q?BfyQk3FtMl/7PNnkEltUeTYN/5FZssXXZidY216f7hdqAq6efkW4uDwb/kQM?= =?iso-8859-2?q?O6hHKr6Y3YtvQk8eKkJ4OQGsQBJNoCY8LW32GN2uRRPNkkEt++xwPbmie4U8?= =?iso-8859-2?q?llPXIFsiRPj5x6+u78UUr0RUEHS/RqCBD5smJiYwmnKlsG0wAvDtGd1nKQ+F?= =?iso-8859-2?q?N++2b/BR43ZIalaZP196jllabOkByP6MnaVmxxltLsUAIBqoCVn1D9TTeR29?= =?iso-8859-2?q?5D/LZCW+EG2fEN2eXxMHpMYXYGmDNJcTa/EG8teGr4D+Rsysi4lu0mR8BC3f?= =?iso-8859-2?q?aM+gkFQ9HVPacabcPjFQHP5j1pE6SD1bOBwct9Bz+zg/0YDnyOaSItep4Ye0?= =?iso-8859-2?q?dV5NO7miPMs8NU2OQarcHIBCX9OOm4EIQgEtkqDCVbFzaeWoFL33+porkF8X?= =?iso-8859-2?q?RVYTkVgULoBhD8btZL5Ucf5r5H5KY+3+hI8TwHF0dTC5CSuWsd0/yRwAy7n/?= =?iso-8859-2?q?U5tG11SDsWzg/m+aGruuiGXbkZVtUQUWaauhuNUut5aTp1U+mnC/D3zvUbyw?= =?iso-8859-2?q?ljUcKpWI65VPsK3p+ke0IrvY7y6miRIUyfzobTuSaC2T3zYngO9myouBmhSa?= =?iso-8859-2?q?KnTpCyyfS+aVFW7QxNX5dAN9D6rPj4lIa2nJYHQM2AhkD8SHehIJL4eGo+ee?= =?iso-8859-2?q?ShVbD9UhWT6LhUHrAO+TtYbWzWwPVaU2afL4zepcSMYSh+GyBZHjeDhSaxlW?= =?iso-8859-2?q?1IbPznOvIWrUh43x2YcDtwCw5MTaxxnpSlIkrTiTehb+M47uTr6SxfZ0J2L0?= =?iso-8859-2?q?hXqTjbwGEwe5fi2wSv3BjRsWeMvpSw4rdGuSjj6VCnLYG6l9JAh040wGQBR+?= =?iso-8859-2?q?Ekg8wsVWezEm0ujxHu9EffwMrjMrVEd2naEUWvfYxWCKnAEoVRKPu2B5/yNC?= =?iso-8859-2?q?6YuGPCWtqMsBk7SjfTNu6FgrA6R5eOR4DHsOy+6fzCrAwt0s9gVQG6Pb+6xJ?= =?iso-8859-2?q?c0VTNqmjtYtV4GQTmLo1Ngrz1ZtR9Qn+5Z2SiB+skIxzZC5IDckB+vmN1IA4?= =?iso-8859-2?q?aFnC7ayHnfTffQ4QUI0ibtEqyfZgH7HC5cvouQKur5GcQsXExVvlGeEaX1fW?= =?iso-8859-2?q?NocvHyvaA4stFpYlUhKczw68jssHUq2F9xSBH4BM9NpFJrzh9QuYO8Y5FZ+C?= =?iso-8859-2?q?GkiOLecztKCq151QynPUaJHqlShWfUKxTG5sc82MNh2ypqzfLwdTm8PVpBLh?= =?iso-8859-2?q?dxU5aQdOeylRp3OTD+SnayNk2pLabbWTCzCI5GoHs=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)(1800799024)(376014)(366016)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-2?q?BMimMm51uy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q?2wDbZtZCvucPeSFoYSk4Tl0DdhRYc3wex/GdsHA1Cenlv+U/7zX8OznF4xkd?= =?iso-8859-2?q?+/uf1IrSsIqKF+CpHilnL8j3afxRF5d3+3eI5xRtGc3cMMKi7N+gCg+vtup/?= =?iso-8859-2?q?VL8B3CPLX0QAZbKrHND1n+9D1WeuJSc0hxgS/tiEbvc66dDszw8pYQuM8M+h?= =?iso-8859-2?q?ID0FwtTJsiIfLlBp8fCAMvglSUX3+QK9LFBdAPf5u6s7eCUhGxhdKDIxQDkD?= =?iso-8859-2?q?1ocMeZwhZ1xMdngZ8NJA3ZBNdwjq7fGaFaoOetMV81tcetHKlenWJXwgQT21?= =?iso-8859-2?q?hDrckrsqoJFQU5nALVoKAbIf76DG/8ASmI6GfDrBk/wZqqUVhx1zdgjkr/Y5?= =?iso-8859-2?q?hPBnNLhokoua9du0OiyK3d99govphlsFdRwPHtirTrh1NCGrU9ZE8ZCWxDdM?= =?iso-8859-2?q?eEegynmFzgav14ugN9ikNVScLdGn06/2srP9Cm/qG/jMckzurT+T7nSrBd2n?= =?iso-8859-2?q?XhyI2F1wkUsmKyFdp3tB9Fb4+WnJodAJL9j7IcrsTI9MhQjXb9YGhmNSlCMn?= =?iso-8859-2?q?eFQE+MrnFb1JpoNayW4WMsBQlAM5nXq+g8RjmC/dXBaTPrNuve1rM/y1akcY?= =?iso-8859-2?q?fDwOdYoc2nPAUlntnk8DeVNgIrNl57ZXJ6IUokvQF/ZjX3S+o0ZyZwwlZ27T?= =?iso-8859-2?q?TR9BeZQ6cqyWduT0K8fcdFbXCKiu77GSGh6djqE4vOqoKE58t4YZjahRfyNg?= =?iso-8859-2?q?0LHu+niC27SbuWo7d?= 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: a998a918-69e1-4427-d596-08dcb84bc37e X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Aug 2024 08:17:52.1558 (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: vngLiCfxkLiFbcxc22S5Icio/U8OOrE78OqOz8e+/6S/hK4yUQkALrPeRpwHz9bvZBrDJbP5csZD279OmIIp1S1Gnr8nBJn11nxSJnWGH+Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR07MB6948 From da1630ee3ed664df8fbd74c4063ab130c4e98c5d Mon Sep 17 00:00:00 2001 From: Wojciech Siudy Date: Fri, 9 Aug 2024 09:59:27 +0200 Subject: [PATCH] pca954x: Reset if channel select fails Channel selection that has timed out is a symptom of mux'es I2C subsystem failure. Without sending reset pulse the POR of entire system would be needed to restore the communication. Signed-off-by: siudy --- 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..0034e663b 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(10); + 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 */