Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/khorben-n900]: src/sys/arch/arm/omap Rewrote the computation of the cloc...



details:   https://anonhg.NetBSD.org/src/rev/dc7959186495
branches:  khorben-n900
changeset: 786715:dc7959186495
user:      khorben <khorben%NetBSD.org@localhost>
date:      Thu May 16 18:24:26 2013 +0000

description:
Rewrote the computation of the clock frequency divider when configuring an
SPI channel.

diffstat:

 sys/arch/arm/omap/omap2_spi.c |  28 +++++++---------------------
 1 files changed, 7 insertions(+), 21 deletions(-)

diffs (56 lines):

diff -r 236166a026da -r dc7959186495 sys/arch/arm/omap/omap2_spi.c
--- a/sys/arch/arm/omap/omap2_spi.c     Thu May 16 15:53:05 2013 +0000
+++ b/sys/arch/arm/omap/omap2_spi.c     Thu May 16 18:24:26 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: omap2_spi.c,v 1.1.2.5 2013/05/15 23:27:49 khorben Exp $ */
+/* $NetBSD: omap2_spi.c,v 1.1.2.6 2013/05/16 18:24:26 khorben Exp $ */
 
 /*
  * Texas Instruments OMAP2/3 Multichannel SPI driver.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap2_spi.c,v 1.1.2.5 2013/05/15 23:27:49 khorben Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap2_spi.c,v 1.1.2.6 2013/05/16 18:24:26 khorben Exp $");
 
 #include "opt_omap.h"
 
@@ -186,6 +186,7 @@
 omap2_spi_configure(void *cookie, int slave, int mode, int speed)
 {
        struct omap2_spi_softc *sc = cookie;
+       const int freq = 48000000; /* XXX hardcoded */
        uint32_t conf = 0;
        uint32_t div;
 
@@ -196,25 +197,10 @@
                return EINVAL;
 
        /* set the speed */
-       /* XXX implement lower speeds */
-       if (speed <= 187500)
-               div = 0x8;
-       else if (speed <= 375000)
-               div = 0x7;
-       else if (speed <= 750000)
-               div = 0x6;
-       else if (speed <= 1500000)
-               div = 0x5;
-       else if (speed <= 3000000)
-               div = 0x4;
-       else if (speed <= 6000000)
-               div = 0x3;
-       else if (speed <= 12000000)
-               div = 0x2;
-       else if (speed <= 24000000)
-               div = 0x1;
-       else
-               div = 0;
+       for (div = 0; div < 0xf; div++) {
+               if (speed >= freq / (1 << div))
+                       break;
+       }
        conf |= (div << OMAP2_MCSPI_CHXCONF_CLKD_SHIFT);
 
        /* set the word size to 8 bits */



Home | Main Index | Thread Index | Old Index