Received: by 10.223.164.202 with SMTP id h10csp577863wrb; Wed, 15 Nov 2017 04:46:41 -0800 (PST) X-Google-Smtp-Source: AGs4zMatJCoa12dsGx1fM6d6rZRlg0q2EXrZJweNMC2V0LGmwI1eekGkGhJMQJdMflO3/n58Csb3 X-Received: by 10.84.132.65 with SMTP id 59mr13925298ple.146.1510750001253; Wed, 15 Nov 2017 04:46:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510750001; cv=none; d=google.com; s=arc-20160816; b=XJybJTYfLjxZb9v/k+1MxAztOHF8nR6GcbSSPTHtbsPrvAexyzhjlzfviGc7Gy+1X6 1G2JxBPzkwKOXJXoVWKlSeBSv9tS79wcGkurkQRgHhLcsCQouwl/18jeqYdo9Yt0DWyK AuCaBvuD7dAor2nkfChdmv5ChYmg8OaDtP+qR0hLMnIoahQmHgRu28nN1A/MqhHW5XgS ocl5RE3mNihtqC8vrOLn/r9MVOee3wCIOVhjdsU7YgxnznKakmh6dVImhKpUtH5kMR11 CzF3p9CC5yLDph/QnQaDlij23wLiXxXoeq/DcsUznxq88vIM++dqpIj9AY/kOeMdBuMt HnOg== 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=UFAsRPvIg6qgXBK/IB52tAmYdcxVREQaok+hZmPbo6I=; b=btFp8qDsEwWCdhJ6AJFIRYqG427V7O1r7cl71CkH5+KgrhqcXiyoF5D1DGVyuUqaWQ Jmac9ANFVf15zAN59sAn9ANjpbl4e9P2Nfi0IBEWTsReTr9bfamuqtH1oFP2K1AH/Uku KjLeqH/Zso9GKP+xm2KxA/iqzD/CicDguGHdxeZOb//WgRv4Y8qlP2sU7T1ddByW+TeX K22I9QGdVU/mErWkX4dYOoEEMwoUWtb+u7Emc6BIae4SFu8C3217NjEkY8piEdWwR8+n wBg1tb0wtYc0Z8v1puh9R2MCpq/68GrbgPO5SXgzA48WYawFhN4Z8M2O93JUIQ4FBiPt Vq+A== 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 f2si188202pgr.306.2017.11.15.04.46.28; Wed, 15 Nov 2017 04:46:41 -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 S1757960AbdKOMkf (ORCPT + 90 others); Wed, 15 Nov 2017 07:40:35 -0500 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:48151 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757223AbdKOMkN (ORCPT ); Wed, 15 Nov 2017 07:40:13 -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 1eEwzA-0000iT-GG; Wed, 15 Nov 2017 13:40:08 +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 EBD4A28BF7E; Wed, 15 Nov 2017 12:40:06 +0000 (UTC) Subject: Re: MCP251x SPI CAN controller on Cavium ThunderX To: Jan Glauber Cc: Mark Brown , Tim Harvey , linux-spi@vger.kernel.org, "linux-kernel@vger.kernel.org" , Wolfgang Grandegger , linux-can References: <20171114120207.xbee2cgsai4qka46@sirena.org.uk> <20171115120754.GC3011@hc> From: Marc Kleine-Budde Message-ID: <36b04940-83a6-93a7-f7e1-d0acc8c135d9@pengutronix.de> Date: Wed, 15 Nov 2017 13:40:04 +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: <20171115120754.GC3011@hc> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="AMX8lbbd4OF9hdNSiI0Fd2FvcTHoD4XaT" 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) --AMX8lbbd4OF9hdNSiI0Fd2FvcTHoD4XaT Content-Type: multipart/mixed; boundary="lE7HdI0HX7WvOOc1Eefx06uA2ve3uWLOX"; protected-headers="v1" From: Marc Kleine-Budde To: Jan Glauber Cc: Mark Brown , Tim Harvey , linux-spi@vger.kernel.org, "linux-kernel@vger.kernel.org" , Wolfgang Grandegger , linux-can Message-ID: <36b04940-83a6-93a7-f7e1-d0acc8c135d9@pengutronix.de> Subject: Re: MCP251x SPI CAN controller on Cavium ThunderX References: <20171114120207.xbee2cgsai4qka46@sirena.org.uk> <20171115120754.GC3011@hc> In-Reply-To: <20171115120754.GC3011@hc> --lE7HdI0HX7WvOOc1Eefx06uA2ve3uWLOX Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: quoted-printable On 11/15/2017 01:07 PM, Jan Glauber wrote: > On Wed, Nov 15, 2017 at 11:54:20AM +0100, Marc Kleine-Budde wrote: >> On 11/14/2017 01:02 PM, Mark Brown wrote: >>> On Mon, Nov 13, 2017 at 01:17:42PM -0800, Tim Harvey wrote: >>> >>>> When a register is read from the mcp251x driver the >>>> octeon_spi_do_transfer() gets a spi_message with a single spi_xfer o= f >>>> len=3D3, a tx_buf, and an rx_buf which I believe is supposed to shif= t >>>> out 3 bytes out MOSI and shift in 3 bytes from MISO where the last >>>> byte shifted in would be the response. >>> >>> No, that will simultaneously transmit and recieve three bytes. >> >> That's what the driver supposed to do. >> >>> If you want to transmit two bytes and then recieve one byte you need >>> two xfers, one with a len of 2 and a tx_buf, the other with a len of >>> 1 and a rx_buf. >> To read a register (mcp251x_read_reg()) the mcp251x does a 3 byte full= >> duplex transfer. The first byte send is the command (read register) th= e >> second byte the register number the third byte is a dummy. The first 2= >> bytes received are ignored the 3rd byte is the register contents. >=20 > To support this full duplex transfer the Cavium SPI controller needs > to know the receive lenght before setting up the transaction. >=20 > spi_transfer only includes the total length, so I don't see how this > should work. It's a standard 3 byte full duplex transfer. Three bytes are send while three bytes are received. > static int mcp251x_spi_trans(struct spi_device *spi, int len) > { > struct mcp251x_priv *priv =3D spi_get_drvdata(spi); > struct spi_transfer t =3D { > .tx_buf =3D priv->spi_tx_buf, > .rx_buf =3D priv->spi_rx_buf, > .len =3D len, > .cs_change =3D 0, > }; > struct spi_message m; > int ret; >=20 > spi_message_init(&m); >=20 > if (mcp251x_enable_dma) { > t.tx_dma =3D priv->spi_tx_dma; > t.rx_dma =3D priv->spi_rx_dma; > m.is_dma_mapped =3D 1; > } >=20 > spi_message_add_tail(&t, &m); >=20 > ret =3D spi_sync(spi, &m); > if (ret) > dev_err(&spi->dev, "spi transfer failed: ret =3D %d\n", ret); > return ret; > } mcp251x_spi_trans() is called with len=3D3, priv->spi_tx_buf and priv->spi_rx_buf point to previously allocared memor= y priv->spi_tx_buf has been filled before calling mcp251x_spi_trans(). 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 | --lE7HdI0HX7WvOOc1Eefx06uA2ve3uWLOX-- --AMX8lbbd4OF9hdNSiI0Fd2FvcTHoD4XaT Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEE4bay/IylYqM/npjQHv7KIOw4HPYFAloMNaQACgkQHv7KIOw4 HPZp1wgAy1lWg5+Rtc3I4QBni0Yx08CSOwFdKeiN+7UpX6e1jRVsRuXjlKfMIqII hgUBowUrd9pUXH3lsL3zHwa//k5eyx1c5EwZgWcL+JlwrOe3i6HGBLn+GnWuGjZI eAEe0Qq2QKgWL/8KYITp9vhRBE8MwTJo4DwD00ZOWbNjYhGaI9DKnNY/pTIy1WFg 4b84/u0EXszV8gG3ETjSXfTG4MIhUd4ulSXGk4cpCCVrlxrkgSY054Al8/OAEHGe xqdYGfTay1D7sqW7iSMY4ZWBIar1ACp1S7WTICH/kQEoEM2yQKzcHqkICpbpOJtc Kx+sz9sXSlQC9qOT5ldX8MsIk6oAnQ== =N8k2 -----END PGP SIGNATURE----- --AMX8lbbd4OF9hdNSiI0Fd2FvcTHoD4XaT-- From 1584129279111039693@xxx Wed Nov 15 10:56:47 +0000 2017 X-GM-THRID: 1583987213767022680 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread