From patchwork Wed May 16 10:53:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Longchamp X-Patchwork-Id: 159584 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 79B07B6FB4 for ; Wed, 16 May 2012 20:54:46 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1717D280CF; Wed, 16 May 2012 12:54:40 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id REy54VrDLXua; Wed, 16 May 2012 12:54:39 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 87F5D280B6; Wed, 16 May 2012 12:54:31 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5B2BA2809B for ; Wed, 16 May 2012 12:54:29 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yX+lFKGkDBYA for ; Wed, 16 May 2012 12:54:29 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail.ch.keymile.com (mail.ch.keymile.com [193.17.201.103]) by theia.denx.de (Postfix) with SMTP id 75BA2280A7 for ; Wed, 16 May 2012 12:54:28 +0200 (CEST) Received: from SRVCHBER1212.ch.keymile.net ([172.31.32.9]) by eSafe SMTP Relay 1334159602; Wed, 16 May 2012 12:54:28 +0200 Received: from chber1-10533x.ch.keymile.net ([172.31.40.3]) by SRVCHBER1212.ch.keymile.net with Microsoft SMTPSVC(6.0.3790.4675); Wed, 16 May 2012 12:54:27 +0200 From: Valentin Longchamp To: To: prafulla@marvell.com, holger.brunck@keymile.com Date: Wed, 16 May 2012 12:53:42 +0200 Message-Id: <1337165623-7118-3-git-send-email-valentin.longchamp@keymile.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1337165623-7118-1-git-send-email-valentin.longchamp@keymile.com> References: <1337165623-7118-1-git-send-email-valentin.longchamp@keymile.com> X-OriginalArrivalTime: 16 May 2012 10:54:27.0532 (UTC) FILETIME=[436F60C0:01CD3352] X-ESAFE-STATUS: [srvchber1306.keymile.net] Mail allowed Cc: Valentin Longchamp , Holger Brunck , Prafulla@theia.denx.de, u-boot@lists.denx.de Subject: [U-Boot] [PATCH 2/3] spi/kirkwood: support spi_claim/release_bus functions X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de These two function nows ensure that the MPP is configured correctly for the SPI controller before any SPI access, and restore the initial configuration when the access is over. Since the used pins for the SPI controller can differ (2 possibilities for each signal), the used pins are configured with CONFIG_SYS_KW_SPI_MPP. Signed-off-by: Valentin Longchamp cc: Holger Brunck cc: Prafulla Wadaskar --- arch/arm/include/asm/arch-kirkwood/spi.h | 9 ++++++++ drivers/spi/kirkwood_spi.c | 34 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 0 deletions(-) diff --git a/arch/arm/include/asm/arch-kirkwood/spi.h b/arch/arm/include/asm/arch-kirkwood/spi.h index 1d5043f..305c573 100644 --- a/arch/arm/include/asm/arch-kirkwood/spi.h +++ b/arch/arm/include/asm/arch-kirkwood/spi.h @@ -37,6 +37,15 @@ struct kwspi_registers { u32 irq_mask; /* 0x10614 */ }; +#define CSn_MPP7 0x1 +#define MOSI_MPP6 0x2 +#define SCK_MPP10 0x4 +#define MISO_MPP11 0x8 + +#ifndef CONFIG_SYS_KW_SPI_MPP +#define CONFIG_SYS_KW_SPI_MPP 0x0 +#endif + #define KWSPI_CLKPRESCL_MASK 0x1f #define KWSPI_CSN_ACT 1 /* Activates serial memory interface */ #define KWSPI_SMEMRDY (1 << 1) /* SerMem Data xfer ready */ diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c index db8ba8b..0877915 100644 --- a/drivers/spi/kirkwood_spi.c +++ b/drivers/spi/kirkwood_spi.c @@ -88,11 +88,45 @@ void spi_free_slave(struct spi_slave *slave) int spi_claim_bus(struct spi_slave *slave) { + u32 config; + u32 spi_mpp_config[5]; + + config = CONFIG_SYS_KW_SPI_MPP; + + if (config & CSn_MPP7) + spi_mpp_config[0] = MPP7_SPI_SCn; + else + spi_mpp_config[0] = MPP0_SPI_SCn; + + if (config & MOSI_MPP6) + spi_mpp_config[1] = MPP6_SPI_MOSI; + else + spi_mpp_config[1] = MPP1_SPI_MOSI; + + if (config & SCK_MPP10) + spi_mpp_config[2] = MPP10_SPI_SCK; + else + spi_mpp_config[2] = MPP2_SPI_SCK; + + if (config & MISO_MPP11) + spi_mpp_config[3] = MPP11_SPI_MISO; + else + spi_mpp_config[3] = MPP3_SPI_MISO; + + spi_mpp_config[4] = 0; + + /* save current mpp configuration */ + kirkwood_mpp_save(); + + /* finally set chosen mpp spi configuration */ + kirkwood_mpp_conf(spi_mpp_config); + return 0; } void spi_release_bus(struct spi_slave *slave) { + kirkwood_mpp_restore(); } #ifndef CONFIG_SPI_CS_IS_VALID