From patchwork Wed Sep 26 18:34:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stan Hu X-Patchwork-Id: 1510771 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id CBA14DF238 for ; Wed, 26 Sep 2012 18:34:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758194Ab2IZSep (ORCPT ); Wed, 26 Sep 2012 14:34:45 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:39705 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757436Ab2IZSeo (ORCPT ); Wed, 26 Sep 2012 14:34:44 -0400 Received: by ieak13 with SMTP id k13so2273657iea.19 for ; Wed, 26 Sep 2012 11:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=7QsRpU0J/svWw27I9yY0CAln884p19DmYmOW95n0eFE=; b=czFM771hiNhG6aopaBBYVs1ltPjJS/WKdHXXiOoMJSxBgOqfTVZeuWhfKEmLFmLq4G yzg9WZKatQx8OcWZ4jJRpohgp/O/SNTiyZ86zPdQTmSpbOvsN9025VV5cL4fL6fSHX+o pb9PF/ySHuIy6cVICrkhCwMgvyhgs0MMRN2xcQlZLeoHXHOhuHdSXYzwtpfFQUpEXsmU 5+3Q4pXbIJZDWjIP+xlS9C0hJrujbZ93mnqUqy2ONTKVdTJpt2oYtfA/zX4wJ+Vf+Uwr XjhXahQDHK4emu2m4Rw3J3cfpnCjQ2qfoGw2OMo8uRrJIWAiuQxycyfXz3plZCsKZtJQ D1Ug== Received: by 10.43.45.200 with SMTP id ul8mr1116649icb.36.1348684484055; Wed, 26 Sep 2012 11:34:44 -0700 (PDT) Received: from owl.aclimalabs.com (108-94-24-230.lightspeed.sntcca.sbcglobal.net. [108.94.24.230]) by mx.google.com with ESMTPS id ng5sm10886321igc.0.2012.09.26.11.34.42 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Sep 2012 11:34:43 -0700 (PDT) From: Stan Hu To: Tony Lindgren , Russell King , Grant Likely , Jarkko Nikula , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Stan Hu Subject: [PATCH 1/1] ARM: Add option to configure output line for McSPI driver Date: Wed, 26 Sep 2012 11:34:27 -0700 Message-Id: <1348684467-5707-1-git-send-email-stanhu@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org McSPI driver previously assumed that D0 was input (MISO) and D1 was output (MOSI). This forces the hardware designer to wire all SPI peripherals in this way when it should be a software configuration option. Signed-off-by: Stan Hu --- arch/arm/plat-omap/include/plat/mcspi.h | 2 ++ drivers/spi/spi-omap2-mcspi.c | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/arm/plat-omap/include/plat/mcspi.h b/arch/arm/plat-omap/include/plat/mcspi.h index a357eb2..0a6b790 100644 --- a/arch/arm/plat-omap/include/plat/mcspi.h +++ b/arch/arm/plat-omap/include/plat/mcspi.h @@ -18,6 +18,8 @@ struct omap2_mcspi_dev_attr { struct omap2_mcspi_device_config { unsigned turbo_mode:1; + /* 1 -> [D0 = MOSI, D1 = MISO], otherwise vice versa */ + unsigned d0_is_output:1; }; #endif diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index b2fb141..1853527 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -717,6 +717,7 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) { struct omap2_mcspi_cs *cs = spi->controller_state; + struct omap2_mcspi_device_config *cd = spi->controller_data; struct omap2_mcspi *mcspi; struct spi_master *spi_cntrl; u32 l = 0, div = 0; @@ -742,8 +743,14 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi, /* standard 4-wire master mode: SCK, MOSI/out, MISO/in, nCS * REVISIT: this controller could support SPI_3WIRE mode. */ - l &= ~(OMAP2_MCSPI_CHCONF_IS|OMAP2_MCSPI_CHCONF_DPE1); - l |= OMAP2_MCSPI_CHCONF_DPE0; + l &= ~(OMAP2_MCSPI_CHCONF_IS| + OMAP2_MCSPI_CHCONF_DPE0|OMAP2_MCSPI_CHCONF_DPE1); + + /* set input selection for D0 and D1 */ + if (cd->d0_is_output) + l |= OMAP2_MCSPI_CHCONF_IS|OMAP2_MCSPI_CHCONF_DPE1; + else + l |= OMAP2_MCSPI_CHCONF_DPE0; /* wordlength */ l &= ~OMAP2_MCSPI_CHCONF_WL_MASK;