From patchwork Thu Jan 24 12:40:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Brugger X-Patchwork-Id: 2031641 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 5E7893FDBC for ; Thu, 24 Jan 2013 12:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754098Ab3AXMk5 (ORCPT ); Thu, 24 Jan 2013 07:40:57 -0500 Received: from mail-wg0-f45.google.com ([74.125.82.45]:44540 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753065Ab3AXMk5 (ORCPT ); Thu, 24 Jan 2013 07:40:57 -0500 Received: by mail-wg0-f45.google.com with SMTP id dq12so1409908wgb.12 for ; Thu, 24 Jan 2013 04:40:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=oQ7ScQmgN619hSdPnYtDpYdqAtXoDdLzE8RxsNimkCg=; b=SItQebM932LY03khY6U6noUBOTZkMqIxSQlqZIov2n3MZj1Bi6c0C66wh1yxYymyTv GHKDgasIS9zbibNRODc21VBAfRXpdJqnhLyj87+hfJoFPQtopsDa5w3oNQqw9jHlvxQE E8O3JPrswemk22wa3hcc/g1KgFZ4eEGOaQaJOcKMt74jc9rK1rSBllALJ5/4LTt44690 XFnmPTLGVw++2n/G1unLuYal/sQGG88DrDGOlipIge5Qpk6fjY/8+HsihMqIorMdAcou Uc3Ag4QgkHODSB6euKPRxqDqENEZuuXGWc9LPcEMkAcC73B5BpdIZy9/LQoeywjsWQMm swBg== X-Received: by 10.180.14.2 with SMTP id l2mr2942555wic.2.1359031255589; Thu, 24 Jan 2013 04:40:55 -0800 (PST) Received: from ubi.home ([161.116.246.142]) by mx.google.com with ESMTPS id i2sm2132381wiw.3.2013.01.24.04.40.53 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 24 Jan 2013 04:40:54 -0800 (PST) From: Matthias Brugger To: Grant Likely , Mark Brown , Tony Lindgren , Daniel Mack , Jarkko Nikula , Greg Kroah-Hartman , eballetbo@gmail.com, javier.martinez@collabora.co.uk, ezequiel.garcia@free-electrons.com, spi-devel-general@lists.sourceforge.net, linux-omap@vger.kernel.org Cc: Matthias Brugger Subject: [PATCH v2] spi: spi-omap2-mcspi.c: Toggle CS after each word Date: Thu, 24 Jan 2013 13:40:41 +0100 Message-Id: <1359031241-3234-1-git-send-email-matthias.bgg@gmail.com> X-Mailer: git-send-email 1.7.11.7 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org This patch allows the board code to define SPI devices which needs to toggle the chip select after every word send. This is needed to get a better resolution reading e.g. an ADC data stream. Apart from that, as in the normal code CS is controlled by software, a transfer is done much faster. Signed-off-by: Matthias Brugger --- drivers/spi/spi-omap2-mcspi.c | 18 ++++++++++++++++++ include/linux/platform_data/spi-omap2-mcspi.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 31f6e84..12789fc 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -927,6 +927,7 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m) struct spi_device *spi; struct spi_transfer *t = NULL; + struct spi_master *master; int cs_active = 0; struct omap2_mcspi_cs *cs; struct omap2_mcspi_device_config *cd; @@ -935,6 +936,7 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m) u32 chconf; spi = m->spi; + master = spi->master; cs = spi->controller_state; cd = spi->controller_data; @@ -952,6 +954,14 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m) if (!t->speed_hz && !t->bits_per_word) par_override = 0; } + if (cd && cd->cs_per_word) { + chconf = mcspi->ctx.modulctrl; + chconf &= ~OMAP2_MCSPI_MODULCTRL_SINGLE; + mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, chconf); + mcspi->ctx.modulctrl = + mcspi_read_cs_reg(spi, OMAP2_MCSPI_MODULCTRL); + } + if (!cs_active) { omap2_mcspi_force_cs(spi, 1); @@ -1013,6 +1023,14 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m) if (cs_active) omap2_mcspi_force_cs(spi, 0); + if (cd && cd->cs_per_word) { + chconf = mcspi->ctx.modulctrl; + chconf |= OMAP2_MCSPI_MODULCTRL_SINGLE; + mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, chconf); + mcspi->ctx.modulctrl = + mcspi_read_cs_reg(spi, OMAP2_MCSPI_MODULCTRL); + } + omap2_mcspi_set_enable(spi, 0); m->status = status; diff --git a/include/linux/platform_data/spi-omap2-mcspi.h b/include/linux/platform_data/spi-omap2-mcspi.h index a65572d..c100456 100644 --- a/include/linux/platform_data/spi-omap2-mcspi.h +++ b/include/linux/platform_data/spi-omap2-mcspi.h @@ -22,6 +22,9 @@ struct omap2_mcspi_dev_attr { struct omap2_mcspi_device_config { unsigned turbo_mode:1; + + /* toggle chip select after every word */ + unsigned cs_per_word:1; }; #endif