From patchwork Mon Nov 12 08:52:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenyou Yang X-Patchwork-Id: 1727071 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id CA852DFE80 for ; Mon, 12 Nov 2012 09:04:09 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TXpsy-0006G1-QO; Mon, 12 Nov 2012 09:00:53 +0000 Received: from newsmtp5.atmel.com ([204.2.163.5] helo=sjogate2.atmel.com) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TXpot-0003hv-Un for linux-arm-kernel@lists.infradead.org; Mon, 12 Nov 2012 08:56:41 +0000 Received: from penbh01.corp.atmel.com ([10.168.5.31]) by sjogate2.atmel.com (8.13.6/8.13.6) with ESMTP id qAC8pRWn029566; Mon, 12 Nov 2012 00:51:29 -0800 (PST) Received: from penmb01.corp.atmel.com ([10.168.5.33]) by penbh01.corp.atmel.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 12 Nov 2012 16:56:32 +0800 Received: from shaarm01.corp.atmel.com ([10.217.6.34]) by penmb01.corp.atmel.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 12 Nov 2012 16:56:31 +0800 From: Wenyou Yang To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 12/17] spi/atmel_spi: add version propety as the spi data Date: Mon, 12 Nov 2012 16:52:32 +0800 Message-Id: <1352710357-3265-13-git-send-email-wenyou.yang@atmel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1352710357-3265-1-git-send-email-wenyou.yang@atmel.com> References: <1352710357-3265-1-git-send-email-wenyou.yang@atmel.com> X-OriginalArrivalTime: 12 Nov 2012 08:56:31.0785 (UTC) FILETIME=[9C511190:01CDC0B3] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121112_035640_315017_999126E6 X-CRM114-Status: GOOD ( 13.65 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: grant.likely@secretlab.ca, spi-devel-general@lists.sourceforge.net, JM.Lin@atmel.com, nicolas.ferre@atmel.com, wenyou.yang@atmel.com 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 To remove the function atmel_spi_is_v2() which depends on the SOC, for future using DTS section to decide the IP version of SOC. Signed-off-by: Wenyou Yang Cc: grant.likely@secretlab.ca Cc: spi-devel-general@lists.sourceforge.net --- drivers/spi/spi-atmel.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 0cc347c..568df5b 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -187,6 +187,7 @@ */ struct atmel_spi_data { u8 dma_type; + u8 version; struct at_dma_slave dma_slave; }; @@ -264,9 +265,20 @@ static struct dma_slave_config slave_config; * register, but I haven't checked that it exists on all chips, and * this is cheaper anyway. */ -static bool atmel_spi_is_v2(void) +static bool atmel_spi_is_v1(struct atmel_spi *as) { - return !cpu_is_at91rm9200(); + if (as->data.version == 1) + return true; + else + return false; +} + +static bool atmel_spi_is_v2(struct atmel_spi *as) +{ + if (as->data.version == 2) + return true; + else + return false; } /* @@ -300,7 +312,7 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi) unsigned active = spi->mode & SPI_CS_HIGH; u32 mr; - if (atmel_spi_is_v2()) { + if (atmel_spi_is_v2(as)) { /* * Always use CSR0. This ensures that the clock * switches to the correct idle polarity before we @@ -355,7 +367,7 @@ static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi) asd->npcs_pin, active ? " (low)" : "", mr); - if (atmel_spi_is_v2() || spi->chip_select != 0) + if (atmel_spi_is_v2(as) || spi->chip_select != 0) gpio_set_value(asd->npcs_pin, !active); } @@ -1266,7 +1278,7 @@ static int atmel_spi_setup(struct spi_device *spi) } /* see notes above re chipselect */ - if (!atmel_spi_is_v2() + if (atmel_spi_is_v1(as) && spi->chip_select == 0 && (spi->mode & SPI_CS_HIGH)) { dev_dbg(&spi->dev, "setup: can't be active-high\n"); @@ -1275,7 +1287,7 @@ static int atmel_spi_setup(struct spi_device *spi) /* v1 chips start out at half the peripheral bus speed. */ bus_hz = clk_get_rate(as->clk); - if (!atmel_spi_is_v2()) + if (atmel_spi_is_v1(as)) bus_hz /= 2; if (spi->max_speed_hz) { @@ -1347,7 +1359,7 @@ static int atmel_spi_setup(struct spi_device *spi) "setup: %lu Hz bpw %u mode 0x%x -> csr%d %08x\n", bus_hz / scbr, bits, spi->mode, spi->chip_select, csr); - if (!atmel_spi_is_v2()) + if (atmel_spi_is_v1(as)) spi_writel(as, CSR0 + 4 * spi->chip_select, csr); return 0;