]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/id.c
Merge current mainline tree into linux-omap tree
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / id.c
1 /*
2  * linux/arch/arm/mach-omap2/id.c
3  *
4  * OMAP2 CPU identification code
5  *
6  * Copyright (C) 2005 Nokia Corporation
7  * Written by Tony Lindgren <tony@atomide.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  */
13
14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/io.h>
18
19 #include <asm/cputype.h>
20
21 #include <mach/common.h>
22 #include <mach/control.h>
23 #include <mach/cpu.h>
24
25 static struct omap_chip_id omap_chip;
26
27 /**
28  * omap_chip_is - test whether currently running OMAP matches a chip type
29  * @oc: omap_chip_t to test against
30  *
31  * Test whether the currently-running OMAP chip matches the supplied
32  * chip type 'oc'.  Returns 1 upon a match; 0 upon failure.
33  */
34 int omap_chip_is(struct omap_chip_id oci)
35 {
36         return (oci.oc & omap_chip.oc) ? 1 : 0;
37 }
38 EXPORT_SYMBOL(omap_chip_is);
39
40 int omap_type(void)
41 {
42         u32 val = 0;
43
44         if (cpu_is_omap24xx()) {
45                 val = omap_ctrl_readl(OMAP24XX_CONTROL_STATUS);
46         } else if (cpu_is_omap34xx()) {
47                 val = omap_ctrl_readl(OMAP343X_CONTROL_STATUS);
48         } else {
49                 pr_err("Cannot detect omap type!\n");
50                 goto out;
51         }
52
53         val &= OMAP2_DEVICETYPE_MASK;
54         val >>= 8;
55
56 out:
57         return val;
58 }
59 EXPORT_SYMBOL(omap_type);
60
61
62 /*----------------------------------------------------------------------------*/
63
64 #define OMAP_TAP_IDCODE         0x0204
65 #define OMAP_TAP_DIE_ID_0       0x0218
66 #define OMAP_TAP_DIE_ID_1       0x021C
67 #define OMAP_TAP_DIE_ID_2       0x0220
68 #define OMAP_TAP_DIE_ID_3       0x0224
69
70 #define read_tap_reg(reg)       __raw_readl(tap_base  + (reg))
71
72 struct omap_id {
73         u16     hawkeye;        /* Silicon type (Hawkeye id) */
74         u8      dev;            /* Device type from production_id reg */
75         u32     type;           /* Combined type id copied to system_rev */
76 };
77
78 /* Register values to detect the OMAP version */
79 static struct omap_id omap_ids[] __initdata = {
80         { .hawkeye = 0xb5d9, .dev = 0x0, .type = 0x24200024 },
81         { .hawkeye = 0xb5d9, .dev = 0x1, .type = 0x24201024 },
82         { .hawkeye = 0xb5d9, .dev = 0x2, .type = 0x24202024 },
83         { .hawkeye = 0xb5d9, .dev = 0x4, .type = 0x24220024 },
84         { .hawkeye = 0xb5d9, .dev = 0x8, .type = 0x24230024 },
85         { .hawkeye = 0xb68a, .dev = 0x0, .type = 0x24300024 },
86 };
87
88 static void __iomem *tap_base;
89 static u16 tap_prod_id;
90
91 void __init omap24xx_check_revision(void)
92 {
93         int i, j;
94         u32 idcode, prod_id;
95         u16 hawkeye;
96         u8  dev_type, rev;
97
98         idcode = read_tap_reg(OMAP_TAP_IDCODE);
99         prod_id = read_tap_reg(tap_prod_id);
100         hawkeye = (idcode >> 12) & 0xffff;
101         rev = (idcode >> 28) & 0x0f;
102         dev_type = (prod_id >> 16) & 0x0f;
103
104         pr_debug("OMAP_TAP_IDCODE 0x%08x REV %i HAWKEYE 0x%04x MANF %03x\n",
105                  idcode, rev, hawkeye, (idcode >> 1) & 0x7ff);
106         pr_debug("OMAP_TAP_DIE_ID_0: 0x%08x\n",
107                  read_tap_reg(OMAP_TAP_DIE_ID_0));
108         pr_debug("OMAP_TAP_DIE_ID_1: 0x%08x DEV_REV: %i\n",
109                  read_tap_reg(OMAP_TAP_DIE_ID_1),
110                  (read_tap_reg(OMAP_TAP_DIE_ID_1) >> 28) & 0xf);
111         pr_debug("OMAP_TAP_DIE_ID_2: 0x%08x\n",
112                  read_tap_reg(OMAP_TAP_DIE_ID_2));
113         pr_debug("OMAP_TAP_DIE_ID_3: 0x%08x\n",
114                  read_tap_reg(OMAP_TAP_DIE_ID_3));
115         pr_debug("OMAP_TAP_PROD_ID_0: 0x%08x DEV_TYPE: %i\n",
116                  prod_id, dev_type);
117
118         /* Check hawkeye ids */
119         for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
120                 if (hawkeye == omap_ids[i].hawkeye)
121                         break;
122         }
123
124         if (i == ARRAY_SIZE(omap_ids)) {
125                 printk(KERN_ERR "Unknown OMAP CPU id\n");
126                 return;
127         }
128
129         for (j = i; j < ARRAY_SIZE(omap_ids); j++) {
130                 if (dev_type == omap_ids[j].dev)
131                         break;
132         }
133
134         if (j == ARRAY_SIZE(omap_ids)) {
135                 printk(KERN_ERR "Unknown OMAP device type. "
136                                 "Handling it as OMAP%04x\n",
137                                 omap_ids[i].type >> 16);
138                 j = i;
139         }
140
141         pr_info("OMAP%04x", system_rev >> 16);
142         if ((system_rev >> 8) & 0x0f)
143                 pr_info("ES%x", (system_rev >> 12) & 0xf);
144         pr_info("\n");
145 }
146
147 void __init omap34xx_check_revision(void)
148 {
149         u32 cpuid, idcode;
150         u16 hawkeye;
151         u8 rev;
152         char *rev_name = "ES1.0";
153
154         /*
155          * We cannot access revision registers on ES1.0.
156          * If the processor type is Cortex-A8 and the revision is 0x0
157          * it means its Cortex r0p0 which is 3430 ES1.0.
158          */
159         cpuid = read_cpuid(CPUID_ID);
160         if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) {
161                 system_rev = OMAP3430_REV_ES1_0;
162                 goto out;
163         }
164
165         /*
166          * Detection for 34xx ES2.0 and above can be done with just
167          * hawkeye and rev. See TRM 1.5.2 Device Identification.
168          * Note that rev does not map directly to our defined processor
169          * revision numbers as ES1.0 uses value 0.
170          */
171         idcode = read_tap_reg(OMAP_TAP_IDCODE);
172         hawkeye = (idcode >> 12) & 0xffff;
173         rev = (idcode >> 28) & 0xff;
174
175         if (hawkeye == 0xb7ae) {
176                 switch (rev) {
177                 case 0:
178                         system_rev = OMAP3430_REV_ES2_0;
179                         rev_name = "ES2.0";
180                         break;
181                 case 2:
182                         system_rev = OMAP3430_REV_ES2_1;
183                         rev_name = "ES2.1";
184                         break;
185                 case 3:
186                         system_rev = OMAP3430_REV_ES3_0;
187                         rev_name = "ES3.0";
188                         break;
189                 default:
190                         /* Use the latest known revision as default */
191                         system_rev = OMAP3430_REV_ES3_0;
192                         rev_name = "Unknown revision\n";
193                 }
194         }
195
196 out:
197         pr_info("OMAP%04x %s\n", system_rev >> 16, rev_name);
198 }
199
200 /*
201  * Try to detect the exact revision of the omap we're running on
202  */
203 void __init omap2_check_revision(void)
204 {
205         /*
206          * At this point we have an idea about the processor revision set
207          * earlier with omap2_set_globals_tap().
208          */
209         if (cpu_is_omap24xx())
210                 omap24xx_check_revision();
211         else if (cpu_is_omap34xx())
212                 omap34xx_check_revision();
213         else
214                 pr_err("OMAP revision unknown, please fix!\n");
215
216         /*
217          * OK, now we know the exact revision. Initialize omap_chip bits
218          * for powerdowmain and clockdomain code.
219          */
220         if (cpu_is_omap243x()) {
221                 /* Currently only supports 2430ES2.1 and 2430-all */
222                 omap_chip.oc |= CHIP_IS_OMAP2430;
223         } else if (cpu_is_omap242x()) {
224                 /* Currently only supports 2420ES2.1.1 and 2420-all */
225                 omap_chip.oc |= CHIP_IS_OMAP2420;
226         } else if (cpu_is_omap343x()) {
227                 omap_chip.oc = CHIP_IS_OMAP3430;
228                 if (system_rev == OMAP3430_REV_ES1_0)
229                         omap_chip.oc |= CHIP_IS_OMAP3430ES1;
230                 else if (system_rev > OMAP3430_REV_ES1_0)
231                         omap_chip.oc |= CHIP_IS_OMAP3430ES2;
232         } else {
233                 pr_err("Uninitialized omap_chip, please fix!\n");
234         }
235 }
236
237 /*
238  * Set up things for map_io and processor detection later on. Gets called
239  * pretty much first thing from board init. For multi-omap, this gets
240  * cpu_is_omapxxxx() working accurately enough for map_io. Then we'll try to
241  * detect the exact revision later on in omap2_detect_revision() once map_io
242  * is done.
243  */
244 void __init omap2_set_globals_tap(struct omap_globals *omap2_globals)
245 {
246         system_rev = omap2_globals->class;
247         tap_base = omap2_globals->tap;
248
249         if (cpu_is_omap34xx())
250                 tap_prod_id = 0x0210;
251         else
252                 tap_prod_id = 0x0208;
253 }