From patchwork Sun Jan 12 10:27:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 3471051 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 821BCC02DC for ; Sun, 12 Jan 2014 10:28:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C15A820149 for ; Sun, 12 Jan 2014 10:28:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E947A2015E for ; Sun, 12 Jan 2014 10:28:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751227AbaALK2A (ORCPT ); Sun, 12 Jan 2014 05:28:00 -0500 Received: from gerard.telenet-ops.be ([195.130.132.48]:45086 "EHLO gerard.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751175AbaALK1z (ORCPT ); Sun, 12 Jan 2014 05:27:55 -0500 Received: from ayla.of.borg ([84.193.72.141]) by gerard.telenet-ops.be with bizsmtp id CyTs1n01032ts5g0HyTsnz; Sun, 12 Jan 2014 11:27:52 +0100 Received: from geert by ayla.of.borg with local (Exim 4.76) (envelope-from ) id 1W2IGm-0000QU-Db; Sun, 12 Jan 2014 11:27:52 +0100 From: Geert Uytterhoeven To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH V2 7/8] spi: rspi: Add support for specifying CPHA/CPOL Date: Sun, 12 Jan 2014 11:27:43 +0100 Message-Id: <1389522464-1569-8-git-send-email-geert@linux-m68k.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1389522464-1569-1-git-send-email-geert@linux-m68k.org> References: <1389522464-1569-1-git-send-email-geert@linux-m68k.org> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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: Geert Uytterhoeven Add support for specifying the SPI clock phase and polarity, based on the SDK reference code. Signed-off-by: Geert Uytterhoeven Acked-by: Laurent Pinchart --- V2: - Add Acked-by drivers/spi/spi-rspi.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c index 18c56d1feb8e..4b25c8617b02 100644 --- a/drivers/spi/spi-rspi.c +++ b/drivers/spi/spi-rspi.c @@ -190,6 +190,7 @@ struct rspi_data { u8 spsr; u8 spdcr; u8 data_width; + u16 spcmd; int irqs[MAX_NUM_IRQ]; unsigned int num_irqs; const struct spi_ops *ops; @@ -336,7 +337,7 @@ static int rspi_set_config_register(const struct rspi_data *rspi, rspi_write8(rspi, 0x00, RSPI_SPCR2); /* Sets SPCMD */ - rspi_write16(rspi, SPCMD_SPB_8_TO_16(access_size) | SPCMD_SSLKP, + rspi_write16(rspi, SPCMD_SPB_8_TO_16(access_size) | rspi->spcmd, RSPI_SPCMD0); /* Sets RSPI mode */ @@ -391,7 +392,7 @@ static int qspi_set_config_register(const struct rspi_data *rspi, else spcmd = SPCMD_SPB_32BIT; - spcmd |= SPCMD_SCKDEN | SPCMD_SLNDEN | SPCMD_SSLKP | SPCMD_SPNDEN; + spcmd |= SPCMD_SCKDEN | SPCMD_SLNDEN | rspi->spcmd | SPCMD_SPNDEN; /* Resets transfer data length */ rspi_write32(rspi, 0, QSPI_SPBMUL0); @@ -911,6 +912,12 @@ static int rspi_setup(struct spi_device *spi) spi->bits_per_word = 8; rspi->max_speed_hz = spi->max_speed_hz; + rspi->spcmd = SPCMD_SSLKP; + if (spi->mode & SPI_CPOL) + rspi->spcmd |= SPCMD_CPOL; + if (spi->mode & SPI_CPHA) + rspi->spcmd |= SPCMD_CPHA; + set_config_register(rspi, 8); return 0; @@ -1088,6 +1095,7 @@ static int rspi_probe(struct platform_device *pdev) master->setup = rspi_setup; master->transfer = rspi_transfer; master->cleanup = rspi_cleanup; + master->mode_bits = SPI_CPHA | SPI_CPOL; ret = ops->parse_platform_data(rspi, rspi_pd); if (ret < 0) {