blob: 018b994cd794e7dc3dcabe832e3bf5650e2d9449 [file] [log] [blame]
Kevin Hilman7c6337e2007-04-30 19:37:19 +01001/*
2 * Davinci CPU identification code
3 *
4 * Copyright (C) 2006 Komal Shah <komal_shah802003@yahoo.com>
5 *
6 * Derived from OMAP1 CPU identification code.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
Russell Kingfced80c2008-09-06 12:10:45 +010016#include <linux/io.h>
Kevin Hilman7c6337e2007-04-30 19:37:19 +010017
Kevin Hilmanf5c122d2009-04-14 07:04:16 -050018#define JTAG_ID_BASE IO_ADDRESS(0x01c40028)
Kevin Hilman7c6337e2007-04-30 19:37:19 +010019
Kevin Hilmane6530342009-03-20 17:37:21 -070020static unsigned int davinci_revision;
21
Kevin Hilman7c6337e2007-04-30 19:37:19 +010022struct davinci_id {
23 u8 variant; /* JTAG ID bits 31:28 */
24 u16 part_no; /* JTAG ID bits 27:12 */
25 u32 manufacturer; /* JTAG ID bits 11:1 */
26 u32 type; /* Cpu id bits [31:8], cpu class bits [7:0] */
27};
28
29/* Register values to detect the DaVinci version */
30static struct davinci_id davinci_ids[] __initdata = {
31 {
32 /* DM6446 */
33 .part_no = 0xb700,
34 .variant = 0x0,
35 .manufacturer = 0x017,
36 .type = 0x64460000,
37 },
Kevin Hilmane6530342009-03-20 17:37:21 -070038 {
39 /* DM646X */
40 .part_no = 0xb770,
41 .variant = 0x0,
42 .manufacturer = 0x017,
43 .type = 0x64670000,
44 },
45 {
46 /* DM355 */
47 .part_no = 0xb73b,
48 .variant = 0x0,
49 .manufacturer = 0x00f,
50 .type = 0x03550000,
51 },
Kevin Hilman7c6337e2007-04-30 19:37:19 +010052};
53
54/*
55 * Get Device Part No. from JTAG ID register
56 */
57static u16 __init davinci_get_part_no(void)
58{
59 u32 dev_id, part_no;
60
Kevin Hilmanf5c122d2009-04-14 07:04:16 -050061 dev_id = __raw_readl(JTAG_ID_BASE);
Kevin Hilman7c6337e2007-04-30 19:37:19 +010062
63 part_no = ((dev_id >> 12) & 0xffff);
64
65 return part_no;
66}
67
68/*
69 * Get Device Revision from JTAG ID register
70 */
71static u8 __init davinci_get_variant(void)
72{
73 u32 variant;
74
Kevin Hilmanf5c122d2009-04-14 07:04:16 -050075 variant = __raw_readl(JTAG_ID_BASE);
Kevin Hilman7c6337e2007-04-30 19:37:19 +010076
77 variant = (variant >> 28) & 0xf;
78
79 return variant;
80}
81
Kevin Hilmane6530342009-03-20 17:37:21 -070082unsigned int davinci_rev(void)
83{
84 return davinci_revision >> 16;
85}
86EXPORT_SYMBOL(davinci_rev);
87
Kevin Hilman7c6337e2007-04-30 19:37:19 +010088void __init davinci_check_revision(void)
89{
90 int i;
91 u16 part_no;
92 u8 variant;
93
94 part_no = davinci_get_part_no();
95 variant = davinci_get_variant();
96
97 /* First check only the major version in a safe way */
98 for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) {
99 if (part_no == (davinci_ids[i].part_no)) {
Kevin Hilmane6530342009-03-20 17:37:21 -0700100 davinci_revision = davinci_ids[i].type;
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100101 break;
102 }
103 }
104
105 /* Check if we can find the dev revision */
106 for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) {
107 if (part_no == davinci_ids[i].part_no &&
108 variant == davinci_ids[i].variant) {
Kevin Hilmane6530342009-03-20 17:37:21 -0700109 davinci_revision = davinci_ids[i].type;
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100110 break;
111 }
112 }
113
Kevin Hilmane6530342009-03-20 17:37:21 -0700114 printk(KERN_INFO "DaVinci DM%04x variant 0x%x\n",
115 davinci_rev(), variant);
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100116}