Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1267975lqh; Mon, 6 May 2024 02:19:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3wHlTTN/jGMdFzdRyVcV0vmEGM6Ep6zgAM3twFNT8UWAUTpE7umr37Tgx3CCoYaotLMLIGMCmke0V7EYiZ1eDdMbdPcQLGaCtk+MZpQ== X-Google-Smtp-Source: AGHT+IHXusetedb4wnoBDfcsiq27+jz6VZEcVIjZqn8oFxpcksNUqotPxXSCT7WXq04d08CbCs8U X-Received: by 2002:a05:6214:2627:b0:6a0:d404:e964 with SMTP id gv7-20020a056214262700b006a0d404e964mr11649563qvb.40.1714987167494; Mon, 06 May 2024 02:19:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714987167; cv=pass; d=google.com; s=arc-20160816; b=NPhre5ES7XjuAv9QSc+oNSItXgUhe7N7zzQIQl5R8lxsjBsGv2WFMxmIHaRUhR9/tn 3elaWyqirWLxZ4pTOzdwqce520tM6Cq7cXJ1si/3bdo4Ntma8paRdv59BQ3caXRe53wQ s3fiOObLl2AZHhZJKVyGffwHSdsMytnCh2X/SOPJxuVimoHCHB7PT1Sx2FE2CnCWhNNk vXUAIaQO4AhSWEXxN8y+645WxwEVbk9W2nq0sBBpjGtgc5pAY2qbPqlEc9ZbOaIujc0e daVkhFNKnHZuP12nMQ35fTwM3GH0KyG+ix2xOxbzeVM7lIahjakq3WkwIZrjrc6WjNC2 RBnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=VQaX1jqU0785Tbs/63E3sdl2FulcQpbjRER2OWvx6Tw=; fh=NY5hY5vecEGk10bGcIJmsl3T7EyhPmY6EUt4vUA1Z4U=; b=B55cU06QRagRvGSHA3AhXSnCBgsbTxUJt3UOMzAC1jYgVmynYNbx6u9baMYzABYL95 AFFHEDtZQSNqXpudfbyNaUKjJhnh+lP5iA0bbW+YUH5aKu4WZRnfz/nOvRBnzYZlPZ5B toNcMkYKsybumT77IGcxwQfVuXtXSqIaA/FHkRA+0kIiDZ6WcfFpYFBxdfvFkcBj9M8K p9BPHyfCqD4aBslm63ywPEXAy1sdlwxSdmrxAmB3B8dbCc88WEO0c4mMTDD+L4z2uHwy Ar0SraSTu85cBlt79ZeFRGu/sWXWc2oTVddHH4MDwY6gWlvTaDptt+rojBHzGPnrG1yk 7Ofg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-169559-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169559-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r6-20020ad45766000000b006a0cd228d79si9053628qvx.393.2024.05.06.02.19.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 02:19:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169559-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; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-169559-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169559-linux.lists.archive=gmail.com@vger.kernel.org" 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 2D53F1C21DE3 for ; Mon, 6 May 2024 09:19:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ABB721422D7; Mon, 6 May 2024 09:19:22 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 6EBAD1422AC for ; Mon, 6 May 2024 09:19:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714987162; cv=none; b=R6UAUpNa5JUTVeIBxGpCOiQVK7CKsQETlzmWhGwF4X6kf8oxR4Uys08+iSq3VZL4eDBC/2QuRUjcsFOmjA+kPLVFWWmjKFA/LalwQ3URkKr4u4/3wP60Boqg21NuSVdXOmb0v3W2joWR/t32FmWwyB/ubwGRJCcg63Xwauuabjw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714987162; c=relaxed/simple; bh=4GJJvVcB67txL6x23xZi79tGkqfJu9ZkapJcsQpj8mc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lv2pqToh3PvG7zzMExuC++TdzTzd/Qgos4rry1UzZgSxqe4AJCQRmTCNPwLJXKTuBOMnmMlui5Bnep1ilxH80v5CXloJGW1oGD/i9D7GZqwU8hijEHLVel8MiG/p6dsrQvflTO1opwt6h2HUd3kleIHCxCDzwxWuocyvHNwGpmQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s3uUt-0007aJ-6R; Mon, 06 May 2024 11:18:59 +0200 Received: from [2a0a:edc0:0:b01:1d::7b] (helo=bjornoya.blackshift.org) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s3uUq-00GEqn-Vo; Mon, 06 May 2024 11:18:57 +0200 Received: from pengutronix.de (unknown [172.20.34.65]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mkl-all@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id 861EF2CB3C7; Mon, 06 May 2024 09:18:56 +0000 (UTC) Date: Mon, 6 May 2024 11:18:55 +0200 From: Marc Kleine-Budde To: Gregor Herburger Cc: Manivannan Sadhasivam , Thomas Kopp , Vincent Mailhol , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux@ew.tq-group.com Subject: Re: [PATCH v2 4/6] can: mcp251xfd: mcp251xfd_regmap_crc_write(): workaround for errata 5 Message-ID: <20240506-aromatic-dainty-orangutan-f8b57c-mkl@pengutronix.de> References: <20240506-mcp251xfd-gpio-feature-v2-0-615b16fa8789@ew.tq-group.com> <20240506-mcp251xfd-gpio-feature-v2-4-615b16fa8789@ew.tq-group.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ltjwktyxpf7yjkxq" Content-Disposition: inline In-Reply-To: <20240506-mcp251xfd-gpio-feature-v2-4-615b16fa8789@ew.tq-group.com> X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org --ltjwktyxpf7yjkxq Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 06.05.2024 07:59:46, Gregor Herburger wrote: > According to Errata DS80000789E 5 writing IOCON register using one SPI > write command clears LAT0/LAT1. >=20 > 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. >=20 > Never write byte 2 of IOCON register to avoid clearing of LAT0/LAT1. >=20 > Signed-off-by: Gregor Herburger > --- > drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c | 29 ++++++++++++++++++= +++++- > 1 file changed, 28 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c b/drivers/n= et/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)); > } > =20 > +static int mcp251xfd_regmap_crc_write_iocon(void *context, const void *d= ata) > +{ > + u16 reg =3D MCP251XFD_REG_IOCON; const > + > + /* Never write to bits 16..23 of IOCON register to avoid clearing of LA= T0/LAT1 > + * > + * According to Errata DS80000789E 5 writing IOCON register using one Just for completeness add "mcp2518fd" in front of Errata. > + * 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[2= 3:16]) > + * is for read-only access and writing to it causes the clearing of LAT= 0/LAT1. > + */ > + > + /* Write IOCON[15:0] */ > + mcp251xfd_regmap_crc_gather_write(context, ®, 1, data, 2); > + reg +=3D 3; > + /* Write IOCON[31:24] */ > + mcp251xfd_regmap_crc_gather_write(context, ®, 1, data + 3, 1); Please add error handling. > + > + return 0; > +} > + > static int > mcp251xfd_regmap_crc_write(void *context, > const void *data, size_t count) > { > const size_t data_offset =3D sizeof(__be16) + > mcp251xfd_regmap_crc.pad_bits / BITS_PER_BYTE; > + u16 reg =3D *(u16 *)data; > =20 > - return mcp251xfd_regmap_crc_gather_write(context, > + if (reg =3D=3D MCP251XFD_REG_IOCON) > + return mcp251xfd_regmap_crc_write_iocon(context, data + data_offset); Please also check that "count" is sizeof(__le32). > + else > + return mcp251xfd_regmap_crc_gather_write(context, > data, data_offset, > data + data_offset, > count - data_offset); >=20 Also add the workaround for the nocrc regmap. regards, Marc --=20 Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung N=C3=BCrnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 | --ltjwktyxpf7yjkxq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEUEC6huC2BN0pvD5fKDiiPnotvG8FAmY4oHwACgkQKDiiPnot vG/7lQf9Gfl2kI2VZm5ZoPgK5CZ2Qq1vPDA1Z+z3fSaaONgwCW2gyer3aMONMZmP R/DMZNdouH6I3GvqCwSS+gxKTlZdciS4Kw3tIeS00EGeV7uquD6VHec5lXgDQ/hA CMZxZKu35QCqmos1uzPYkzJcleR5Kyq5zM9z9NP7Mykfa0UwmHoe8BqKZT50VrFx enu7bj5ABjai1ZJ7bFh0CebJNa2XZHD2VpUUZXQ8KllW+xgkm6HUNHPFGj3wLYbI 1hBowLc2WoQkuZGO2WniYLNpg5UTOM4QnHCiznLwRWd8PwtsI7vKXOSHJxk94q42 IOdRFpzeyJYyQ2x7c7CBK+z4rAnAkA== =4dqj -----END PGP SIGNATURE----- --ltjwktyxpf7yjkxq--