Fix race between proc_get_inode() and remove_proc_entry()
[linux-2.6/libata-dev.git] / arch / arm / mach-omap2 / id.c
blob871ace4fccb879a186cf135f87a0dcbfaafa4343
1 /*
2 * linux/arch/arm/mach-omap2/id.c
4 * OMAP2 CPU identification code
6 * Copyright (C) 2005 Nokia Corporation
7 * Written by Tony Lindgren <tony@atomide.com>
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.
14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
18 #include <asm/io.h>
20 #define OMAP24XX_TAP_BASE io_p2v(0x48014000)
22 #define OMAP_TAP_IDCODE 0x0204
23 #define OMAP_TAP_PROD_ID 0x0208
25 #define OMAP_TAP_DIE_ID_0 0x0218
26 #define OMAP_TAP_DIE_ID_1 0x021C
27 #define OMAP_TAP_DIE_ID_2 0x0220
28 #define OMAP_TAP_DIE_ID_3 0x0224
30 /* system_rev fields for OMAP2 processors:
31 * CPU id bits [31:16],
32 * CPU device type [15:12], (unprg,normal,POP)
33 * CPU revision [11:08]
34 * CPU class bits [07:00]
37 struct omap_id {
38 u16 hawkeye; /* Silicon type (Hawkeye id) */
39 u8 dev; /* Device type from production_id reg */
40 u32 type; /* combined type id copied to system_rev */
43 /* Register values to detect the OMAP version */
44 static struct omap_id omap_ids[] __initdata = {
45 { .hawkeye = 0xb5d9, .dev = 0x0, .type = 0x24200000 },
46 { .hawkeye = 0xb5d9, .dev = 0x1, .type = 0x24201000 },
47 { .hawkeye = 0xb5d9, .dev = 0x2, .type = 0x24202000 },
48 { .hawkeye = 0xb5d9, .dev = 0x4, .type = 0x24220000 },
49 { .hawkeye = 0xb5d9, .dev = 0x8, .type = 0x24230000 },
50 { .hawkeye = 0xb68a, .dev = 0x0, .type = 0x24300000 },
53 static u32 __init read_tap_reg(int reg)
55 return __raw_readl(OMAP24XX_TAP_BASE + reg);
58 void __init omap2_check_revision(void)
60 int i, j;
61 u32 idcode;
62 u32 prod_id;
63 u16 hawkeye;
64 u8 dev_type;
65 u8 rev;
67 idcode = read_tap_reg(OMAP_TAP_IDCODE);
68 prod_id = read_tap_reg(OMAP_TAP_PROD_ID);
69 hawkeye = (idcode >> 12) & 0xffff;
70 rev = (idcode >> 28) & 0x0f;
71 dev_type = (prod_id >> 16) & 0x0f;
73 #ifdef DEBUG
74 printk(KERN_DEBUG "OMAP_TAP_IDCODE 0x%08x REV %i HAWKEYE 0x%04x MANF %03x\n",
75 idcode, rev, hawkeye, (idcode >> 1) & 0x7ff);
76 printk(KERN_DEBUG "OMAP_TAP_DIE_ID_0: 0x%08x\n",
77 read_tap_reg(OMAP_TAP_DIE_ID_0));
78 printk(KERN_DEBUG "OMAP_TAP_DIE_ID_1: 0x%08x DEV_REV: %i\n",
79 read_tap_reg(OMAP_TAP_DIE_ID_1),
80 (read_tap_reg(OMAP_TAP_DIE_ID_1) >> 28) & 0xf);
81 printk(KERN_DEBUG "OMAP_TAP_DIE_ID_2: 0x%08x\n",
82 read_tap_reg(OMAP_TAP_DIE_ID_2));
83 printk(KERN_DEBUG "OMAP_TAP_DIE_ID_3: 0x%08x\n",
84 read_tap_reg(OMAP_TAP_DIE_ID_3));
85 printk(KERN_DEBUG "OMAP_TAP_PROD_ID_0: 0x%08x DEV_TYPE: %i\n",
86 prod_id, dev_type);
87 #endif
89 /* Check hawkeye ids */
90 for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
91 if (hawkeye == omap_ids[i].hawkeye)
92 break;
95 if (i == ARRAY_SIZE(omap_ids)) {
96 printk(KERN_ERR "Unknown OMAP CPU id\n");
97 return;
100 for (j = i; j < ARRAY_SIZE(omap_ids); j++) {
101 if (dev_type == omap_ids[j].dev)
102 break;
105 if (j == ARRAY_SIZE(omap_ids)) {
106 printk(KERN_ERR "Unknown OMAP device type. "
107 "Handling it as OMAP%04x\n",
108 omap_ids[i].type >> 16);
109 j = i;
111 system_rev = omap_ids[j].type;
113 system_rev |= rev << 8;
115 /* Add the cpu class info (24xx) */
116 system_rev |= 0x24;
118 pr_info("OMAP%04x", system_rev >> 16);
119 if ((system_rev >> 8) & 0x0f)
120 printk("%x", (system_rev >> 8) & 0x0f);
121 printk("\n");