Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1199225lqh; Sun, 5 May 2024 23:01:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW3zgAZnf9ffjrdYWqkwYeQF+3JTprfM8TV3BwhbtPqs7IVLLa9SJ76d/Sq2c2NF81Ps8a401jvW9dduduK4+i5KTlE50Ki3+9q1pWvNA== X-Google-Smtp-Source: AGHT+IFBhzUeoSZBgGQRCpd/RqfMSQ6P7pHuq1irRK0SgJwzhr38gVKWLZ4UUHsk99qtIOA7sNDc X-Received: by 2002:a05:6870:f110:b0:23e:ec96:b62e with SMTP id k16-20020a056870f11000b0023eec96b62emr7021078oac.0.1714975297012; Sun, 05 May 2024 23:01:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714975296; cv=pass; d=google.com; s=arc-20160816; b=lZFnhITD+1El2arWNp9aUeH1Q1dwKqk8FXP2s96VVcu9bzk/8HBi9LcIQjXInML7qb Z6MUrfERvO1BnCripmCFPBfy+P6nnkYZpKThpQd6oAAL605zCEhMRpjVhnlJxsKuy+Kx 28xDSYsEk1rT/L6qiHCLN8VUKEfp5DuxxUZvzndKaXO87pU7d9r3mF4XbMbkF0qDQNyp Aaqe/gajAQpxxVP8QejjSPVJ8SeC8RlK5PY74TnjcUHw2SwOxq8a/+zZWowP+A96XWwv b/bCx6XgaMhNsKwG8a7Yn6FyX6gLmCsNLOha2c3q9HIzTDenwa6aUEdDxpg+5rKDEIuX JU2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature:dkim-signature; bh=SYaQjnkNSCI9zkCW8eSDRCydILiZmUATxYlt6TM0kmc=; fh=Ck0fOcHdhRzgBaHwp6SaSYBo0j21rhywV4MXv2yQ9aM=; b=Pu8itrcUz9EhsnSiVg+UHUJqotVyCFsiUrf+Q46MH+BiQD/MQX2KNNBpTXyEMoBqnl /KwESwGBGF9q4V0gGZ8acSlcDaHmtQ8d1qIFlE40Hvp9vri0Iv7DgSi0rozMxuOM5zRj iCXHKSUCAJuKYk5MIsAU+VUpy6+IL12UuEST8kYqxKicUMy4458OUFYD9jn4tfGAL/mM v7AtsJ1dOnu41WzX8muwnKCCrP36R45U59NIOMJesThZMz4Y8/8Qlz52QRz/Iggu/fZK Bllo6eH2OA4UgNBqiEbS1uZ9N/w/Ysrc//6OnuWzbtjdHemDxvHUFKE/x9YNwtvU805u RBmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tq-group.com header.s=key1 header.b=jfsTUgTg; dkim=temperror (no key for signature) header.i=@ew.tq-group.com header.s=dkim header.b=TDMTAPzw; arc=pass (i=1 spf=pass spfdomain=ew.tq-group.com dkim=pass dkdomain=tq-group.com dmarc=pass fromdomain=ew.tq-group.com); spf=pass (google.com: domain of linux-kernel+bounces-169340-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169340-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tq-group.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id l22-20020a37f516000000b00790f25ef343si8143698qkk.144.2024.05.05.23.01.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 May 2024 23:01:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169340-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tq-group.com header.s=key1 header.b=jfsTUgTg; dkim=temperror (no key for signature) header.i=@ew.tq-group.com header.s=dkim header.b=TDMTAPzw; arc=pass (i=1 spf=pass spfdomain=ew.tq-group.com dkim=pass dkdomain=tq-group.com dmarc=pass fromdomain=ew.tq-group.com); spf=pass (google.com: domain of linux-kernel+bounces-169340-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169340-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tq-group.com 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 B26F31C20433 for ; Mon, 6 May 2024 06:01:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A68B2487A5; Mon, 6 May 2024 06:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tq-group.com header.i=@tq-group.com header.b="jfsTUgTg"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b="TDMTAPzw" Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) (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 14246140399; Mon, 6 May 2024 06:00:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.104.207.81 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714975216; cv=none; b=ruKbrjPb307R8QpTu9HEsh+zB2tzpBNFlXeIv03JcotZCJaR3Sryhqd1FZp8N/KobXW5t6BTTZa1PexZ92xp/imYMR8qWS5BGuQpISQUS5ceAITPwJPx5HtdgZKo3yUguOfv1NNzbmr0eZZzopNcAZpPOCdu4cjqrTvY8+rMj+4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714975216; c=relaxed/simple; bh=P3Mk5PcWaUP6+Gg05tBidf+kKVuQMiV3cqlnF284O3Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WHaAu9Rv0Avvz0aDK/s3eZfIVXOy7EU1KF2t6iGT1CK3s04Z2q+O06D70x10ALnf0VOlfvjKq8r1Ad4b//gv2Y/oyIfZ4r6ZSNLJOHv65/xo4twj85Ve+014lMQM0l1PPMZDjBe5yi12C9WF+qgnTsbegRQ7rpFMPq2oRMFMpyQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ew.tq-group.com; spf=pass smtp.mailfrom=ew.tq-group.com; dkim=pass (2048-bit key) header.d=tq-group.com header.i=@tq-group.com header.b=jfsTUgTg; dkim=fail (0-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b=TDMTAPzw reason="key not found in DNS"; arc=none smtp.client-ip=93.104.207.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ew.tq-group.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1714975214; x=1746511214; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=SYaQjnkNSCI9zkCW8eSDRCydILiZmUATxYlt6TM0kmc=; b=jfsTUgTgpbpLo5441zbj0L0UQV6TqK0hLUid4O2EEJ2xz6luvhON3a/3 ENzVoUqEkeD2pS6NN9/1Ptsrl1pt+a6QoP7si2rU7xMKzZHUkvRKVyvyc Hk1Hejljeuk39lke/A0s6ubhqsXpi5trkO5ETzADOwQP8i9QFlS4M5bS5 UwbtPFyppsef4P1Ynpb1xARAjrwixpl3aIiW0FngO5l0kma4XSM4L2BZh 9o6z81bGNtildQCWQjEOPDg+buSOIhjJwdxQ32FQ5EQhXov3q2/OiQrQo qmz3/nSzI5S/upy/YrPowWfVF2h424Icrdef0x4kdnVUSoNMqg2dtUqu5 w==; X-CSE-ConnectionGUID: U0H5sdNPTtqyvWWgQfGZJw== X-CSE-MsgGUID: 0NHtdPBoS5ixY7usv3UEgw== X-IronPort-AV: E=Sophos;i="6.07,257,1708383600"; d="scan'208";a="36751433" Received: from vmailcow01.tq-net.de ([10.150.86.48]) by mx1.tq-group.com with ESMTP; 06 May 2024 08:00:13 +0200 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C32511760D9; Mon, 6 May 2024 08:00:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ew.tq-group.com; s=dkim; t=1714975209; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=SYaQjnkNSCI9zkCW8eSDRCydILiZmUATxYlt6TM0kmc=; b=TDMTAPzwXWqGh70t6UEY0kKIWbD4bUcAwXfgyblnhfi7QBnKWJj4feG27xWvB9l+ndvoSM QL57IZKc5bR4kYqLyfGvkCyBXVr2sforEzCBLlNEv/Y8xxnJIStjHiiIkF99/2jJ+xvl3I 9yqWIig1G5k2hPVTIPojkl6loQKFt/0er50B+pt27syNPxpmFAT/8jT7vrHbZttKgz99lL LQks9QleslPpuTjoYw3rS0o8tWWh46/DI6e0aSKjzi8JEO37fthsm234q3W3L+DHJDU+gN lrY1OCTImjMXTIFsup6MWLWsBxQ3l3rkWucafw6DWYQNiOoySfBjux7HqT8Pvw== From: Gregor Herburger Date: Mon, 06 May 2024 07:59:46 +0200 Subject: [PATCH v2 4/6] can: mcp251xfd: mcp251xfd_regmap_crc_write(): workaround for errata 5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240506-mcp251xfd-gpio-feature-v2-4-615b16fa8789@ew.tq-group.com> References: <20240506-mcp251xfd-gpio-feature-v2-0-615b16fa8789@ew.tq-group.com> In-Reply-To: <20240506-mcp251xfd-gpio-feature-v2-0-615b16fa8789@ew.tq-group.com> To: Marc Kleine-Budde , Manivannan Sadhasivam , Thomas Kopp , Vincent Mailhol , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux@ew.tq-group.com, gregor.herburger@ew.tq-group.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1714975188; l=2328; i=gregor.herburger@ew.tq-group.com; s=20230829; h=from:subject:message-id; bh=P3Mk5PcWaUP6+Gg05tBidf+kKVuQMiV3cqlnF284O3Q=; b=Vl2+Twm8j5RsvrhL+nbEqe4dNJvFb9F3+BQMZkmc/QN5cYeX3C1hsQNvpFTjs0koT7+On0BmO DvnZVX1JoZEAeI+Rv2Z1hadEFVlwYA6UDcCTOg1evnmQedPaSSFLtQk X-Developer-Key: i=gregor.herburger@ew.tq-group.com; a=ed25519; pk=+eRxwX7ikXwazcRjlOjj2/tbDmfVZdDLoW+xLZbQ4h4= X-Last-TLS-Session-Version: TLSv1.3 According to Errata DS80000789E 5 writing IOCON register using one SPI write command clears LAT0/LAT1. Errata Fix/Work Around suggests to write registers with single byte write instructions. However, it seems that every write to the second byte causes the overwrite of LAT0/LAT1. Never write byte 2 of IOCON register to avoid clearing of LAT0/LAT1. Signed-off-by: Gregor Herburger --- drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c | 29 +++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c index 65150e762007..43fcf7f50591 100644 --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c @@ -229,14 +229,41 @@ mcp251xfd_regmap_crc_gather_write(void *context, return spi_sync_transfer(spi, xfer, ARRAY_SIZE(xfer)); } +static int mcp251xfd_regmap_crc_write_iocon(void *context, const void *data) +{ + u16 reg = MCP251XFD_REG_IOCON; + + /* Never write to bits 16..23 of IOCON register to avoid clearing of LAT0/LAT1 + * + * According to Errata DS80000789E 5 writing IOCON register using one + * SPI write command clears LAT0/LAT1. + * + * Errata Fix/Work Around suggests to write registers with single byte + * write instructions. However, it seems that the byte at 0xe06(IOCON[23:16]) + * is for read-only access and writing to it causes the clearing of LAT0/LAT1. + */ + + /* Write IOCON[15:0] */ + mcp251xfd_regmap_crc_gather_write(context, ®, 1, data, 2); + reg += 3; + /* Write IOCON[31:24] */ + mcp251xfd_regmap_crc_gather_write(context, ®, 1, data + 3, 1); + + return 0; +} + static int mcp251xfd_regmap_crc_write(void *context, const void *data, size_t count) { const size_t data_offset = sizeof(__be16) + mcp251xfd_regmap_crc.pad_bits / BITS_PER_BYTE; + u16 reg = *(u16 *)data; - return mcp251xfd_regmap_crc_gather_write(context, + if (reg == MCP251XFD_REG_IOCON) + return mcp251xfd_regmap_crc_write_iocon(context, data + data_offset); + else + return mcp251xfd_regmap_crc_gather_write(context, data, data_offset, data + data_offset, count - data_offset); -- 2.34.1