From patchwork Fri Mar 12 15:21:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Ellis X-Patchwork-Id: 85305 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2CFMEOU024730 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 12 Mar 2010 15:22:51 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Nq6gk-0003dT-5F; Fri, 12 Mar 2010 15:22:10 +0000 Received: from sfi-mx-3.v28.ch3.sourceforge.com ([172.29.28.123] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Nq6gh-0003dI-Le for spi-devel-general@lists.sourceforge.net; Fri, 12 Mar 2010 15:22:07 +0000 X-ACL-Warn: Received: from pan.gwi.net ([207.5.128.165]) by sfi-mx-3.v28.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1Nq6gg-0000w4-Mx for spi-devel-general@lists.sourceforge.net; Fri, 12 Mar 2010 15:22:07 +0000 Received: from [192.168.10.4] (66-63-88-74.static.suscom-maine.net [66.63.88.74]) by pan.gwi.net (8.13.1/8.13.1) with ESMTP id o2CFLuI6033525; Fri, 12 Mar 2010 10:21:56 -0500 (EST) (envelope-from scott@jumpnowtek.com) From: Scott Ellis To: spi-devel-general@lists.sourceforge.net Date: Fri, 12 Mar 2010 10:21:55 -0500 Message-ID: <1268407315.14445.52.camel@quad> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 X-Spam-Score: 0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. _SUMMARY_ X-Headers-End: 1Nq6gg-0000w4-Mx Cc: David Brownell , Tony Lindgren , Aaro Koskinen , Kevin Hilman , Andrew Morton , linux-omap@vger.kernel.org, Roman Tereshonkov Subject: [spi-devel-general] [PATCH 3/6] SPI omap2_mcspi.c: Use appropriate clock divider value X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 12 Mar 2010 15:22:51 +0000 (UTC) diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c index fe1b56d..37e6d73 100644 --- a/drivers/spi/omap2_mcspi.c +++ b/drivers/spi/omap2_mcspi.c @@ -37,6 +37,7 @@ #include #include +#include #define OMAP2_MCSPI_MAX_FREQ 48000000 @@ -128,6 +129,7 @@ struct omap2_mcspi { unsigned long phys; /* SPI1 has 4 channels, while SPI2 has 2 */ struct omap2_mcspi_dma *dma_channels; + int max_clk_div; }; struct omap2_mcspi_cs { @@ -588,11 +590,12 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi, cs->word_len = word_len; if (spi->max_speed_hz) { - while (div <= 15 && (OMAP2_MCSPI_MAX_FREQ / (1 << div)) - > spi->max_speed_hz) + while (div <= mcspi->max_clk_div && + (OMAP2_MCSPI_MAX_FREQ/(1 << div)) > spi->max_speed_hz) div++; - } else - div = 15; + } else { + div = mcspi->max_clk_div; + } l = mcspi_cached_chconf0(spi); @@ -893,6 +896,8 @@ static int omap2_mcspi_transfer(struct spi_device *spi, struct spi_message *m) unsigned long flags; struct spi_transfer *t; + mcspi = spi_master_get_devdata(spi->master); + m->actual_length = 0; m->status = 0; @@ -917,10 +922,13 @@ static int omap2_mcspi_transfer(struct spi_device *spi, struct spi_message *m) t->bits_per_word); return -EINVAL; } - if (t->speed_hz && t->speed_hz < OMAP2_MCSPI_MAX_FREQ/(1<<16)) { + if (t->speed_hz && + t->speed_hz < OMAP2_MCSPI_MAX_FREQ + /(1 << mcspi->max_clk_div)) { dev_dbg(&spi->dev, "%d Hz max exceeds %d\n", - t->speed_hz, - OMAP2_MCSPI_MAX_FREQ/(1<<16)); + t->speed_hz, + OMAP2_MCSPI_MAX_FREQ + /(1 << mcspi->max_clk_div)); return -EINVAL; } @@ -955,8 +963,6 @@ static int omap2_mcspi_transfer(struct spi_device *spi, struct spi_message *m) } } - mcspi = spi_master_get_devdata(spi->master); - spin_lock_irqsave(&mcspi->lock, flags); list_add_tail(&m->queue, &mcspi->msg_queue); queue_work(omap2_mcspi_wq, &mcspi->work); @@ -1049,6 +1055,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) int status = 0, i; const u8 *rxdma_id, *txdma_id; unsigned num_chipselect; + struct omap2_mcspi_platform_config *pdata; switch (pdev->id) { case 1: @@ -1101,6 +1108,8 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) mcspi = spi_master_get_devdata(master); mcspi->master = master; + pdata = (struct omap2_mcspi_platform_config *)pdev->dev.platform_data; + mcspi->max_clk_div = pdata->max_clk_div; r = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (r == NULL) {