From patchwork Mon Mar 8 11:56:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Ellis X-Patchwork-Id: 84044 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o28Busqu003168 for ; Mon, 8 Mar 2010 11:56:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753945Ab0CHL4x (ORCPT ); Mon, 8 Mar 2010 06:56:53 -0500 Received: from pan.gwi.net ([207.5.128.165]:1209 "EHLO pan.gwi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752253Ab0CHL4x (ORCPT ); Mon, 8 Mar 2010 06:56:53 -0500 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 08 Mar 2010 11:56:54 +0000 (UTC) X-Greylist: delayed 373 seconds by postgrey-1.27 at vger.kernel.org; Mon, 08 Mar 2010 06:56:52 EST 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 o28BuqCK098762 for ; Mon, 8 Mar 2010 06:56:52 -0500 (EST) (envelope-from scott@jumpnowtek.com) Subject: [PATCH] omap2_mcspi.c: Clock divider range check wrong for OMAP3 From: Scott Ellis To: linux-omap@vger.kernel.org Date: Mon, 08 Mar 2010 06:56:51 -0500 Message-ID: <1268049411.2558.76.camel@quad> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c index fe1b56d..a73127b 100644 --- a/drivers/spi/omap2_mcspi.c +++ b/drivers/spi/omap2_mcspi.c @@ -38,8 +38,17 @@ #include #include +#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) +#define OMAP2_MCSPI_MAX_CLK_DIV 12 +#else +/* could be 12 for OMAP24xxx also, no docs to check */ +#define OMAP2_MCSPI_MAX_CLK_DIV 15 +#endif #define OMAP2_MCSPI_MAX_FREQ 48000000 +#define OMAP2_MCSPI_MIN_FREQ (OMAP2_MCSPI_MAX_FREQ \ + / (1 << OMAP2_MCSPI_MAX_CLK_DIV)) + /* OMAP2 has 3 SPI controllers, while OMAP3 has 4 */ #define OMAP2_MCSPI_MAX_CTRL 4 @@ -588,11 +597,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 <= OMAP2_MCSPI_MAX_CLK_DIV && + (OMAP2_MCSPI_MAX_FREQ / (1 << div)) > spi->max_speed_hz) div++; - } else - div = 15; + } else { + div = OMAP2_MCSPI_MAX_CLK_DIV; + } l = mcspi_cached_chconf0(spi); @@ -917,10 +927,10 @@ 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)) { - dev_dbg(&spi->dev, "%d Hz max exceeds %d\n", + if (t->speed_hz && t->speed_hz < OMAP2_MCSPI_MIN_FREQ) { + dev_dbg(&spi->dev, "%d Hz slower then hardware minimum %d\n", t->speed_hz, - OMAP2_MCSPI_MAX_FREQ/(1<<16)); + OMAP2_MCSPI_MIN_FREQ); return -EINVAL; }