From patchwork Tue Feb 9 18:10:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Olbrich X-Patchwork-Id: 8264661 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 903099F88A for ; Tue, 9 Feb 2016 18:11:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFAA320218 for ; Tue, 9 Feb 2016 18:11:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D49DD20220 for ; Tue, 9 Feb 2016 18:11:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756803AbcBISLT (ORCPT ); Tue, 9 Feb 2016 13:11:19 -0500 Received: from mout.gmx.net ([212.227.15.15]:60214 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756828AbcBISLS (ORCPT ); Tue, 9 Feb 2016 13:11:18 -0500 Received: from chaos-desktop.fritz.box ([92.217.39.22]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0M2t0Q-1aCMcR1VcU-00sg0m; Tue, 09 Feb 2016 19:10:41 +0100 From: stephanolbrich@gmx.de To: Mark Brown , Stephen Warren , Lee Jones , Eric Anholt , linux-spi@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Stephan Olbrich Subject: [PATCH 4/4] spi: bcm2835aux: fix CPOL/CPHA setting Date: Tue, 9 Feb 2016 19:10:35 +0100 Message-Id: <1455041435-8015-5-git-send-email-stephanolbrich@gmx.de> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455041435-8015-1-git-send-email-stephanolbrich@gmx.de> References: <1455041435-8015-1-git-send-email-stephanolbrich@gmx.de> X-Provags-ID: V03:K0:Ea1dSU9c5AmApfFis38Jn1FHVtO6fGzRiTLZp3Sm65/lLJAzZtu eiW88n+Dl5/0ocxttKSlcesDBwUag65WKYrRQsShv9aCEhHLnUs5NFeuijdVgLEqSYHL6o+ xKAMpq+9mYB0PRf2A9wT4IX+N33NFs2D596vxYawmE6nCitpDloRKpYLyYd2X78P5UzxI4w FuvRLTlzuhIO1Ho8bahCw== X-UI-Out-Filterresults: notjunk:1; V01:K0:30bmLnhMN78=:XW7YuFIbO45BlaVjiaSPMt DluyGP9Usf25+6xOhoB4FVxRt37VX1nHZZ7EqMB3g5U2Z25a5K/7KjQSmaL7W0B95LuhITBbl 3uPC2/gCQNw1fggKrHgLGUq8P3mofWef+MVXYkPSq2ZXKlpCPtdRnytSdeHBncKaAPwtB4cX1 2EbRiOuDZ+0oPaG8orm7Ux+WjYf8g5+JhUNtvWimat0pvfrkDUBiIq0PgNUYodiwY6aj5sN8o Zuqyn7CtCyPiBBF5Jw59/Ck/5WNiYJ9ESFaeDmafjSfl6TDBhG8Fu3tipE14PivRIv1dVN/i/ 5Ta9jgsYhSxjKptbNR5LP0iGtMVGa4sJglVjwixzpX6/0NvW8V2AsVmUvNVaiKSuDMb5mYtzt sLFlzvrhZXrp8V4JiIzDAkTl3Tgre4AhXan7sXD0wxW9M0/74RMa3CriZ5zWgQA/NoSsfpPNp xXAG2JxfYhP8roKkJMO7duQzx9t6jjxyOJbalYhCg4h123RHDv+yI63k8aCaXtB03TlK/O+3Y WjpX0Is5Pjg4695T/5FBW9WBx1U+zuujROlhM4mdWY7H4s+aRm9WrXdTzKz15Irzmu4luY5Ye euAXVwwIuku7lNgowZP0XUFAjimvtouDpBjmYnmpEttsU4wg1uCrtIZDk6DQLZMm3g86Dg/DS mUFBYoLmeYTxA2ihgvXhP5GYuzUSYfp786EBISJtKhLS4DljMDzwGAnZ22azibVU0rfpFXHPa gTUeNeoVn8FCTnYP70kGw5+gjhMw5FBMI/U6bKpLRTgJUkJkv5X4vQl1fjQ= Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Stephan Olbrich The auxiliary spi supports only CPHA=0 modes as the first bit is always output to the pin before the first clock cycle. In CPHA=1 modes the first clock edge outputs the second bit hence the slave can never read the first bit. Also the CPHA registers switch between clocking data in/out on rising/falling edge hence depend on the CPOL setting. Signed-off-by: Stephan Olbrich --- drivers/spi/spi-bcm2835aux.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-bcm2835aux.c b/drivers/spi/spi-bcm2835aux.c index b90aa34..169f521 100644 --- a/drivers/spi/spi-bcm2835aux.c +++ b/drivers/spi/spi-bcm2835aux.c @@ -386,12 +386,12 @@ static int bcm2835aux_spi_prepare_message(struct spi_master *master, bs->cntl[1] = BCM2835_AUX_SPI_CNTL1_MSBF_IN; /* handle all the modes */ - if (spi->mode & SPI_CPOL) + if (spi->mode & SPI_CPOL) { bs->cntl[0] |= BCM2835_AUX_SPI_CNTL0_CPOL; - if (spi->mode & SPI_CPHA) - bs->cntl[0] |= BCM2835_AUX_SPI_CNTL0_CPHA_OUT | - BCM2835_AUX_SPI_CNTL0_CPHA_IN; - + bs->cntl[0] |= BCM2835_AUX_SPI_CNTL0_CPHA_OUT; + } else { + bs->cntl[0] |= BCM2835_AUX_SPI_CNTL0_CPHA_IN; + } bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1]); bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL0, bs->cntl[0]);