From patchwork Wed Aug 15 06:38:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Lv X-Patchwork-Id: 177550 X-Patchwork-Delegate: sbabic@denx.de 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 51C082C0093 for ; Wed, 15 Aug 2012 16:57:01 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A8A5A280C3; Wed, 15 Aug 2012 08:56:59 +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 R7liUwvkyamw; Wed, 15 Aug 2012 08:56:59 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 62F9A280B3; Wed, 15 Aug 2012 08:56:57 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B647E280B3 for ; Wed, 15 Aug 2012 08:56:54 +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 UoZZZS6EiqIE for ; Wed, 15 Aug 2012 08:56:54 +0200 (CEST) X-Greylist: delayed 905 seconds by postgrey-1.27 at theia; Wed, 15 Aug 2012 08:56:53 CEST Received: from TX2EHSNDR002.bigfish.com (tx2outboundsmtppool2.messaging.microsoft.com [65.55.83.132]) by theia.denx.de (Postfix) with ESMTPS id A39B9280AF for ; Wed, 15 Aug 2012 08:56:53 +0200 (CEST) Received: from tx2outboundpool.messaging.microsoft.com (10.9.14.246) by TX2EHSNDR002.bigfish.com (10.9.40.51) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 15 Aug 2012 06:41:46 +0000 Received: from mail57-tx2-R.bigfish.com (10.9.14.236) by TX2EHSOBE004.bigfish.com (10.9.40.24) with Microsoft SMTP Server id 14.1.225.23; Wed, 15 Aug 2012 06:41:46 +0000 Received: from mail57-tx2 (localhost [127.0.0.1]) by mail57-tx2-R.bigfish.com (Postfix) with ESMTP id 97C803E01D7 for ; Wed, 15 Aug 2012 06:41:46 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-FB-OUTBOUND-SPAM: yes X-SpamScore: 2 X-BigFish: VS2(zzzz1202h10c0jzz8275bhz2dh87h2a8h668h839hd24he5bhe96hf0ah41h42h) X-FB-DOMAIN-IP-MATCH: fail Received: from mail57-tx2 (localhost.localdomain [127.0.0.1]) by mail57-tx2 (MessageSwitch) id 1345012904629564_30034; Wed, 15 Aug 2012 06:41:44 +0000 (UTC) Received: from TX2EHSMHS010.bigfish.com (unknown [10.9.14.245]) by mail57-tx2.bigfish.com (Postfix) with ESMTP id 96DEA8021C for ; Wed, 15 Aug 2012 06:41:44 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS010.bigfish.com (10.9.99.110) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 15 Aug 2012 06:41:44 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.2.298.5; Wed, 15 Aug 2012 01:41:43 -0500 Received: from shlinux3.ap.freescale.net ([10.213.130.145]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id q7F6fb3r020343 for ; Tue, 14 Aug 2012 23:41:39 -0700 Received: by shlinux3.ap.freescale.net (Postfix, from userid 1001) id E839F232955; Wed, 15 Aug 2012 14:38:09 +0800 (CST) From: Terry Lv To: Date: Wed, 15 Aug 2012 14:38:04 +0800 Message-ID: <1345012685-24932-2-git-send-email-r65388@freescale.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1345012685-24932-1-git-send-email-r65388@freescale.com> References: <1345012685-24932-1-git-send-email-r65388@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com Subject: [U-Boot] [PATCH 2/3] mxc_spi: change to use version config instead of soc config in mxc_spi X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list Reply-To: r65388@shlinux3.net List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de In mxc_spi, we used to use soc config, e.g. CONFIG_MX35, CONFIG_MX51. In this way, we can't exlain the difference of spi in each soc and we need to modify the driver for each new soc. Thus, now it use spi version config which can be found in reference manual to diff. And new soc just need to add spi version config in config files to enable it. it would be eaiser than before. Signed-off-by: Terry Lv --- README | 4 ++- drivers/spi/mxc_spi.c | 59 ++++++++++++++++++++++++------------------------- 2 files changed, 32 insertions(+), 31 deletions(-) mode change 100644 => 100755 drivers/spi/mxc_spi.c diff --git a/README b/README index 07f1d11..19268d9 100644 --- a/README +++ b/README @@ -1910,7 +1910,9 @@ The following options need to be configured: CONFIG_MXC_SPI Enables the driver for the SPI controllers on i.MX and MXC - SoCs. Currently i.MX31/35/51 are supported. + SoCs. The board must also define the version of SPI controller + and SPI base addresses that will be used. + Currently i.MX31/35/51/53 are supported. - FPGA Support: CONFIG_FPGA diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c old mode 100644 new mode 100755 index 2fa7486..2f48483 --- a/drivers/spi/mxc_spi.c +++ b/drivers/spi/mxc_spi.c @@ -27,14 +27,12 @@ #include #include -#ifdef CONFIG_MX27 -/* i.MX27 has a completely wrong register layout and register definitions in the - * datasheet, the correct one is in the Freescale's Linux driver */ +#if defined(CONFIG_SPI_VER_0_4) || defined(CONFIG_SPI_VER_0_0) -#error "i.MX27 CSPI not supported due to drastic differences in register definitions" \ +#error "CSPI version not supported due to drastic differences in register definitions" \ "See linux mxc_spi driver from Freescale for details." -#elif defined(CONFIG_MX31) +#elif defined(CONFIG_SPI_VER_0_5) #define MXC_CSPICTRL_EN (1 << 0) #define MXC_CSPICTRL_MODE (1 << 1) @@ -54,13 +52,7 @@ #define MXC_CSPIPERIOD_32KHZ (1 << 15) #define MAX_SPI_BYTES 4 -static unsigned long spi_bases[] = { - 0x43fa4000, - 0x50010000, - 0x53f84000, -}; - -#elif defined(CONFIG_MX51) +#elif defined(CONFIG_SPI_VER_2_3) #define MXC_CSPICTRL_EN (1 << 0) #define MXC_CSPICTRL_MODE (1 << 1) @@ -85,13 +77,7 @@ static unsigned long spi_bases[] = { #define MXC_CSPICON_PHA 0 #define MXC_CSPICON_SSPOL 12 -static unsigned long spi_bases[] = { - CSPI1_BASE_ADDR, - CSPI2_BASE_ADDR, - CSPI3_BASE_ADDR, -}; - -#elif defined(CONFIG_MX35) +#elif defined(CONFIG_SPI_VER_0_7) #define MXC_CSPICTRL_EN (1 << 0) #define MXC_CSPICTRL_MODE (1 << 1) @@ -111,15 +97,28 @@ static unsigned long spi_bases[] = { #define MXC_CSPIPERIOD_32KHZ (1 << 15) #define MAX_SPI_BYTES 4 -static unsigned long spi_bases[] = { - 0x43fa4000, - 0x50010000, -}; - #else -#error "Unsupported architecture" +#error "Unsupported cspi version" #endif +static unsigned long spi_bases[] = { +#ifdef CONFIG_CSPI1_BASE_ADDR + CONFIG_CSPI1_BASE_ADDR, +#endif +#ifdef CONFIG_CSPI2_BASE_ADDR + CONFIG_CSPI2_BASE_ADDR, +#endif +#ifdef CONFIG_CSPI3_BASE_ADDR + CONFIG_CSPI3_BASE_ADDR, +#endif +#ifdef CONFIG_CSPI4_BASE_ADDR + CONFIG_CSPI4_BASE_ADDR, +#endif +#ifdef CONFIG_CSPI5_BASE_ADDR + CONFIG_CSPI5_BASE_ADDR, +#endif +}; + #define OUT MXC_GPIO_DIRECTION_OUT #define reg_read readl @@ -129,7 +128,7 @@ struct mxc_spi_slave { struct spi_slave slave; unsigned long base; u32 ctrl_reg; -#if defined(CONFIG_MX51) +#if defined(CONFIG_SPI_VER_2_3) u32 cfg_reg; #endif int gpio; @@ -167,7 +166,7 @@ u32 get_cspi_div(u32 div) return i; } -#if defined(CONFIG_MX31) || defined(CONFIG_MX35) +#if defined(CONFIG_SPI_VER_0_5) || defined(CONFIG_SPI_VER_0_7) static s32 spi_cfg_mxc(struct mxc_spi_slave *mxcs, unsigned int cs, unsigned int max_hz, unsigned int mode) { @@ -187,7 +186,7 @@ static s32 spi_cfg_mxc(struct mxc_spi_slave *mxcs, unsigned int cs, MXC_CSPICTRL_BITCOUNT(MXC_CSPICTRL_MAXBITS) | MXC_CSPICTRL_DATARATE(div) | MXC_CSPICTRL_EN | -#ifdef CONFIG_MX35 +#ifdef CONFIG_SPI_VER_0_7 MXC_CSPICTRL_SSCTL | #endif MXC_CSPICTRL_MODE; @@ -204,7 +203,7 @@ static s32 spi_cfg_mxc(struct mxc_spi_slave *mxcs, unsigned int cs, } #endif -#if defined(CONFIG_MX51) +#if defined(CONFIG_SPI_VER_2_3) static s32 spi_cfg_mxc(struct mxc_spi_slave *mxcs, unsigned int cs, unsigned int max_hz, unsigned int mode) { @@ -316,7 +315,7 @@ int spi_xchg_single(struct spi_slave *slave, unsigned int bitlen, MXC_CSPICTRL_BITCOUNT(bitlen - 1); reg_write(®s->ctrl, mxcs->ctrl_reg | MXC_CSPICTRL_EN); -#ifdef CONFIG_MX51 +#ifdef CONFIG_SPI_VER_2_3 reg_write(®s->cfg, mxcs->cfg_reg); #endif