From: Mark A. Greer <[email protected]>

The Davinci cpu_is_davinci_*() macros use the platform part number
and variant retrieved from the JTAG ID register to ultimately determine
the cpu type that the kernel is running on.  Unfortunately, some newer
Davinci-like platforms have the JTAG ID register at a different address
than where the true Davincis have it.  So, in order to know the address
of the JTAG ID register, we have to know the cpu type...but that's why
we're reading the JTAG ID register in the first place (i.e., chicken & egg).

Instead, use the SoC info infrastructure that's already there to set
the cpu id and reference that id with the 'is_davinci_*()' macro.

Signed-off-by: Mark A. Greer <[email protected]>
---
 arch/arm/mach-davinci/Makefile              |    2 +-
 arch/arm/mach-davinci/dm355.c               |    2 +
 arch/arm/mach-davinci/dm644x.c              |    2 +
 arch/arm/mach-davinci/dm646x.c              |    2 +
 arch/arm/mach-davinci/id.c                  |  116 ---------------------------
 arch/arm/mach-davinci/include/mach/common.h |    1 +
 arch/arm/mach-davinci/include/mach/cpu.h    |   16 +++--
 arch/arm/mach-davinci/io.c                  |    7 --
 8 files changed, 18 insertions(+), 130 deletions(-)
 delete mode 100644 arch/arm/mach-davinci/id.c

diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile
index 9822a78..79c7285 100644
--- a/arch/arm/mach-davinci/Makefile
+++ b/arch/arm/mach-davinci/Makefile
@@ -4,7 +4,7 @@
 #
 
 # Common objects
-obj-y                  := time.o irq.o clock.o serial.o io.o id.o psc.o \
+obj-y                  := time.o irq.o clock.o serial.o io.o psc.o \
                           gpio.o devices.o usb.o dma.o iram.o common.o
 
 obj-$(CONFIG_DAVINCI_MUX)              += mux.o
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index 4f72cfe..d6086d5 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -21,6 +21,7 @@
 #include <mach/psc.h>
 #include <mach/mux.h>
 #include <mach/irqs.h>
+#include <mach/cpu.h>
 
 #include "clock.h"
 #include "mux.h"
@@ -466,6 +467,7 @@ EVT_CFG(DM355,  EVT26_MMC0_RX,            2,    1,    0,    
 false)
 };
 
 DAVINCI_SOC_START(dm355)
+       .cpu_id         = DAVINCI_CPU_ID_DM355,
        .cpu_clks       = dm355_clks,
        .mux_pins       = dm355_pins,
        .mux_pins_num   = ARRAY_SIZE(dm355_pins),
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index db22c20..889c675 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -16,6 +16,7 @@
 #include <mach/clock.h>
 #include <mach/psc.h>
 #include <mach/mux.h>
+#include <mach/cpu.h>
 
 #include "clock.h"
 #include "mux.h"
@@ -358,6 +359,7 @@ MUX_CFG(DM644X, LFLDEN,             0,   25,    1,    1,    
 false)
 };
 
 DAVINCI_SOC_START(dm644x)
+       .cpu_id         = DAVINCI_CPU_ID_DM6446,
        .cpu_clks       = dm644x_clks,
        .mux_pins       = dm644x_pins,
        .mux_pins_num   = ARRAY_SIZE(dm644x_pins),
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index b84a3f2..b840128 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -16,6 +16,7 @@
 #include <mach/clock.h>
 #include <mach/psc.h>
 #include <mach/mux.h>
+#include <mach/cpu.h>
 
 #include "clock.h"
 #include "mux.h"
@@ -269,6 +270,7 @@ MUX_CFG(DM646X, AUDCK0,             0,   28,    1,    0,    
 false)
 };
 
 DAVINCI_SOC_START(dm646x)
+       .cpu_id         = DAVINCI_CPU_ID_DM6467,
        .cpu_clks       = dm646x_clks,
        .mux_pins       = dm646x_pins,
        .mux_pins_num   = ARRAY_SIZE(dm646x_pins),
diff --git a/arch/arm/mach-davinci/id.c b/arch/arm/mach-davinci/id.c
deleted file mode 100644
index 018b994..0000000
--- a/arch/arm/mach-davinci/id.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Davinci CPU identification code
- *
- * Copyright (C) 2006 Komal Shah <[email protected]>
- *
- * Derived from OMAP1 CPU identification code.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/io.h>
-
-#define JTAG_ID_BASE           IO_ADDRESS(0x01c40028)
-
-static unsigned int davinci_revision;
-
-struct davinci_id {
-       u8      variant;        /* JTAG ID bits 31:28 */
-       u16     part_no;        /* JTAG ID bits 27:12 */
-       u32     manufacturer;   /* JTAG ID bits 11:1 */
-       u32     type;           /* Cpu id bits [31:8], cpu class bits [7:0] */
-};
-
-/* Register values to detect the DaVinci version */
-static struct davinci_id davinci_ids[] __initdata = {
-       {
-               /* DM6446 */
-               .part_no      = 0xb700,
-               .variant      = 0x0,
-               .manufacturer = 0x017,
-               .type         = 0x64460000,
-       },
-       {
-               /* DM646X */
-               .part_no      = 0xb770,
-               .variant      = 0x0,
-               .manufacturer = 0x017,
-               .type         = 0x64670000,
-       },
-       {
-               /* DM355 */
-               .part_no        = 0xb73b,
-               .variant        = 0x0,
-               .manufacturer   = 0x00f,
-               .type           = 0x03550000,
-       },
-};
-
-/*
- * Get Device Part No. from JTAG ID register
- */
-static u16 __init davinci_get_part_no(void)
-{
-       u32 dev_id, part_no;
-
-       dev_id = __raw_readl(JTAG_ID_BASE);
-
-       part_no = ((dev_id >> 12) & 0xffff);
-
-       return part_no;
-}
-
-/*
- * Get Device Revision from JTAG ID register
- */
-static u8 __init davinci_get_variant(void)
-{
-       u32 variant;
-
-       variant = __raw_readl(JTAG_ID_BASE);
-
-       variant = (variant >> 28) & 0xf;
-
-       return variant;
-}
-
-unsigned int davinci_rev(void)
-{
-       return davinci_revision >> 16;
-}
-EXPORT_SYMBOL(davinci_rev);
-
-void __init davinci_check_revision(void)
-{
-       int i;
-       u16 part_no;
-       u8 variant;
-
-       part_no = davinci_get_part_no();
-       variant = davinci_get_variant();
-
-       /* First check only the major version in a safe way */
-       for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) {
-               if (part_no == (davinci_ids[i].part_no)) {
-                       davinci_revision = davinci_ids[i].type;
-                       break;
-               }
-       }
-
-       /* Check if we can find the dev revision */
-       for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) {
-               if (part_no == davinci_ids[i].part_no &&
-                   variant == davinci_ids[i].variant) {
-                       davinci_revision = davinci_ids[i].type;
-                       break;
-               }
-       }
-
-       printk(KERN_INFO "DaVinci DM%04x variant 0x%x\n",
-              davinci_rev(), variant);
-}
diff --git a/arch/arm/mach-davinci/include/mach/common.h 
b/arch/arm/mach-davinci/include/mach/common.h
index 4d9eb11..7bdf526 100644
--- a/arch/arm/mach-davinci/include/mach/common.h
+++ b/arch/arm/mach-davinci/include/mach/common.h
@@ -27,6 +27,7 @@ extern void setup_usb(unsigned mA, unsigned potpgt_msec);
 
 /* SoC specific init support */
 struct davinci_soc_info {
+       u16 cpu_id;
        struct clk **cpu_clks;
        const struct mux_config *mux_pins;
        unsigned long mux_pins_num;
diff --git a/arch/arm/mach-davinci/include/mach/cpu.h 
b/arch/arm/mach-davinci/include/mach/cpu.h
index 99c73da..c27c706 100644
--- a/arch/arm/mach-davinci/include/mach/cpu.h
+++ b/arch/arm/mach-davinci/include/mach/cpu.h
@@ -16,17 +16,21 @@
 #ifndef _ASM_ARCH_CPU_H
 #define _ASM_ARCH_CPU_H
 
-extern unsigned int davinci_rev(void);
+#include <mach/common.h>
+
+#define        DAVINCI_CPU_ID_DM6446           0x6446
+#define        DAVINCI_CPU_ID_DM6467           0x6467
+#define        DAVINCI_CPU_ID_DM355            0x0355
 
 #define IS_DAVINCI_CPU(type, id)                       \
-static inline int is_davinci_dm ##type(void)           \
+static inline int is_davinci_ ##type(void)             \
 {                                                      \
-       return (davinci_rev() == (id)) ? 1 : 0;         \
+       return (davinci_soc_info->cpu_id == (id));      \
 }
 
-IS_DAVINCI_CPU(644x, 0x6446)
-IS_DAVINCI_CPU(646x, 0x6467)
-IS_DAVINCI_CPU(355, 0x355)
+IS_DAVINCI_CPU(dm644x, DAVINCI_CPU_ID_DM6446)
+IS_DAVINCI_CPU(dm646x, DAVINCI_CPU_ID_DM6467)
+IS_DAVINCI_CPU(dm355, DAVINCI_CPU_ID_DM355)
 
 #ifdef CONFIG_ARCH_DAVINCI_DM644x
 #define cpu_is_davinci_dm644x() is_davinci_dm644x()
diff --git a/arch/arm/mach-davinci/io.c b/arch/arm/mach-davinci/io.c
index 5f77af7..41a394c 100644
--- a/arch/arm/mach-davinci/io.c
+++ b/arch/arm/mach-davinci/io.c
@@ -20,8 +20,6 @@
 #include <mach/clock.h>
 #include <mach/mux.h>
 
-extern void davinci_check_revision(void);
-
 /*
  * The machine specific code may provide the extra mapping besides the
  * default mapping provided here.
@@ -45,11 +43,6 @@ void __init davinci_map_common_io(void)
         */
        local_flush_tlb_all();
        flush_cache_all();
-
-       /* We want to check CPU revision early for cpu_is_xxxx() macros.
-        * IO space mapping must be initialized before we can do that.
-        */
-       davinci_check_revision();
 }
 
 #define BETWEEN(p, st, sz)     ((p) >= (st) && (p) < ((st) + (sz)))
-- 
1.6.0.3


_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to