Received: by 10.223.164.202 with SMTP id h10csp1927777wrb; Thu, 16 Nov 2017 06:42:00 -0800 (PST) X-Google-Smtp-Source: AGs4zMa1zMqYGqbOUtTqvKV61XbCa1iLZ5lSJVKEjXuAv+sAlFtbqzyrqTQs5l6/VRB/9b7KrbIq X-Received: by 10.98.25.211 with SMTP id 202mr2089399pfz.46.1510843319836; Thu, 16 Nov 2017 06:41:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510843319; cv=none; d=google.com; s=arc-20160816; b=BvU2H97WeKMHmYsszzSAS+YQqa8xd+nNVGVNp5xOHShai26Q7okPJffdWgpVONKLSp FJzJ8f16a6Lt0OSIKcZGUfYMEA25jPLSqSNC31uwG+FWBdays/TUdczHDFdGQ2fmJoTd U2Y/jwvzTXbTSj1ix22HMZGUieJhEgxIEkgcVQApT+fwo+iF/EKSDpl5rl2NyFy2YEct +QscvDHRPRUm1DRkW7nUxjBYcrFSIz/3G8JtV34a1su7Sag0t1/lLRSQ1vnnIJomaLU3 zChR1GhzK3KDD3+2HovZT2ovRnMt5lsNNLnBV9V+v9Rwgq40IJhM6td/Kxdc+yeZDbSw Czyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=iLikAp9yrb6CWVk41cLxVlAl0sQna70OFWQcrp5oa5o=; b=qsmud+L5D3vPfrELs4x08tBoHXAAcmuhuWjQpA6oorq7hjOJnRXkEWqxperBVdGN3b SNIkZxJo2I8orjzuApGzHnNJ8gKaP74x84QonomxvKM/JVNaiBLK+Rb6d2pdNBe+5F2Q em5xXVfGp1onMPNY8ZPXA40yiHDcwRfC2lSJFLoKFiX2JReEBi2jrqF3MvBcarTlxgPN EBlo8hp0qPMhJimEs2iWM3gI8ewQFVR7pvCYgy6ctyWBhH2WCqJedBI3rSOQHSEn3tH7 0qFXCh9NobMVGPIIUguYeNqlEw3A1+iZ4LNvun2qQC9iFovR8yfEUPXiOhSnTjuHRn+u 2ttQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f19si959773plr.675.2017.11.16.06.41.46; Thu, 16 Nov 2017 06:41:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934563AbdKPMMy (ORCPT + 91 others); Thu, 16 Nov 2017 07:12:54 -0500 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:56079 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934437AbdKPMMq (ORCPT ); Thu, 16 Nov 2017 07:12:46 -0500 Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=bjornoya.blackshift.org) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eFJ28-0001nz-WE; Thu, 16 Nov 2017 13:12:41 +0100 Received: from [IPv6:2001:470:7eea:1122:6933:f3e:cb0f:ccfd] (unknown [IPv6:2001:470:7eea:1122:6933:f3e:cb0f:ccfd]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (Client CN "mkl@blackshift.org", Issuer "StartCom Class 1 Client CA" (not verified)) (Authenticated sender: mkl@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id 7BDE428CE36; Thu, 16 Nov 2017 12:12:39 +0000 (UTC) Subject: Re: MCP251x SPI CAN controller on Cavium ThunderX To: Tim Harvey , David Daney , Jan Glauber Cc: Mark Brown , linux-spi@vger.kernel.org, "linux-kernel@vger.kernel.org" , Wolfgang Grandegger References: <2771c4a8-ed85-86c1-a08c-5b62d177b107@caviumnetworks.com> From: Marc Kleine-Budde Message-ID: Date: Thu, 16 Nov 2017 13:12:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="9xI0x2jnMhx85a0x0J3oUGqPNlMb47T2a" X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --9xI0x2jnMhx85a0x0J3oUGqPNlMb47T2a Content-Type: multipart/mixed; boundary="J6ARjg9R1whsU6rlw3R9fBkLaLkawTuKX"; protected-headers="v1" From: Marc Kleine-Budde To: Tim Harvey , David Daney , Jan Glauber Cc: Mark Brown , linux-spi@vger.kernel.org, "linux-kernel@vger.kernel.org" , Wolfgang Grandegger Message-ID: Subject: Re: MCP251x SPI CAN controller on Cavium ThunderX References: <2771c4a8-ed85-86c1-a08c-5b62d177b107@caviumnetworks.com> In-Reply-To: --J6ARjg9R1whsU6rlw3R9fBkLaLkawTuKX Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: quoted-printable On 11/16/2017 12:18 AM, Tim Harvey wrote: > David / Jan, >=20 > For reference, the HM describes TXNUM/TOTNUM as: > TXNUM - Number of bytes to transmit > TOTNUM - Total number of bytes to shift (transmit and receive) >=20 > Here are some experiments that show somewhat inconsistent results: > - full duplex 3byte tx / 3byte rx to MCP251x > mpi_dat0 =3D> 0x03 // READ > mpi_dat1 =3D> 0x0e // CANSTAT > mip_dat2 =3D> 0xa5 // dummy (but making it 0xa5 instead of 0x00 to prov= e a point) > mpi_tx =3D> 0x100303 // TXNUM=3D3 TOTNUM=3D3; we see 24 clock cycles > // wait for completion > mpi_dat0 <=3D 0xff > mpi_dat1 <=3D 0xff Do you see 0xff 0xff on the MISO wire for byte 1 and 2? > mpi_dat2 <=3D0xa5 // this the dummy byte we sent out MOSI not what came= > in on MISO which the scope shows as 0x80 Oh, the device reads what you have shifed out? This is not good. > if I set TXNUM=3D3 TOTNUM=3D4: > mpi_dat0 =3D> 0x03 // READ > mpi_dat1 =3D> 0x0e // CANSTAT > mip_dat2 =3D> 0xa5 // dummy > mpi_tx =3D> 0x100304 // TXNUM=3D3 TOTNUM=3D4; we see 32 clock cycles What's on MOSI for byte 4? > // wait for completion > mpi_dat0 <=3D 0xff > mpi_dat1 <=3D 0xff > mpi_dat2 <=3D 0x80 // response for CANSTAT reg 0x0e > mpi_dat3 <=3D 0x87 // response for CANCTRL reg 0x0f (because we shifted= > 32 clock cycles) Looks correct. > if I set TXNUM=3D2 TOTNUM=3D3: > mpi_dat0 =3D> 0x03 // READ > mpi_dat1 =3D> 0x0e // CANSTAT > mpi_tx =3D> 0x100203 // TXNUM=3D2 TOTNUM=3D3; we see 24 clock cycles What's on MOSI for byte 3? > // wait for completion > mpi_dat0 <=3D 0xff > mpi_dat1 <=3D 0xff > mpi_dat2 <=3D 0x80 // response for CANSTAT reg 0x0e >=20 > if I set TXNUM=3D1 TOTNUM=3D1 to send a RESET command: > mpi_dat0 =3D> 0xc0 // RESET > mpi_tx =3D> 0x100101 // TXNUM=3D1 TOTNUM=3D1; we see 8 clock cycles > // wait for completion > mpi_dat0 <=3D 0xc0 >=20 > In all cases above what is seen on MISO in relation to CLK matches the > expectations of the mcp251x but the CN80xx MPI_DAT registers don't > return what I see on MISO. Am I missing a consistent pattern of > MPI_DAT vs TXNUM/TOTNUM here that would allow us to work-around this? > Is this a CN80xx chip errata? There is no known errata for the CN80XX > MPI engine. >=20 > I could re-write the mcp251x driver to not use full-duplex but I'm > assuming most SPI drivers use full-duplex transactions. ACK. You don't want to use the mcp251x chip anyways for CAN, the SPI is quite slow and the load of the CPU is relatively high. Don't expect to get many messages over CAN and prepare for dropped frames. Better use a USB-CAN dongle. Or a proper card with some sort of PCI interface. Marc --=20 Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de | --J6ARjg9R1whsU6rlw3R9fBkLaLkawTuKX-- --9xI0x2jnMhx85a0x0J3oUGqPNlMb47T2a Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEE4bay/IylYqM/npjQHv7KIOw4HPYFAloNgLQACgkQHv7KIOw4 HPYX7Af/cvGR1xEdTrGpPfukvDSKJcwBY6kOvqU/yCIkP/qTQH5VPMRz0ENlIJFX Nsu6ilk8B2wZjrXss0XVLLEZBX/GjFtu0z5ysJC6gxJcdk713/H1Vw30YZDWi2p3 vlfLwcJyz8Xpz5lr30vJPD9rzuwqKHYEvDSKpCF1Y6BIq+EZ9jc/BTZ4AaIJ7Mx6 5G/pSIJC16ParX+nLfGzZybHm07+FP1HfPIgzYlBaFCAXnK1P/EshpszZDcJzpp3 2ERFSBGFYDNjnY++LZs38mB3ANdOFz4Gm5OvMM7jEyj0DYANqb4DCrPASQM3yz1H rmrajYQFUuq4W0sdaax4jOVD8jKBcg== =0rNj -----END PGP SIGNATURE----- --9xI0x2jnMhx85a0x0J3oUGqPNlMb47T2a-- From 1584182145006357837@xxx Thu Nov 16 00:57:04 +0000 2017 X-GM-THRID: 1583987213767022680 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread