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: 1510791 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id C84063FDAE for ; Wed, 26 Sep 2012 18:36:23 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TGwRc-0006KX-Fu; Wed, 26 Sep 2012 18:34:48 +0000 Received: from mail-ie0-f177.google.com ([209.85.223.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TGwRZ-0006Jz-Tg for linux-arm-kernel@lists.infradead.org; Wed, 26 Sep 2012 18:34:46 +0000 Received: by ieje14 with SMTP id e14so2390167iej.36 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 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: X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.223.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (stanhu[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Stan Hu X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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;