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/config.h> 15 #include <linux/module.h> 16 #include <linux/kernel.h> 17 #include <linux/init.h> 18 19 #include <asm/io.h> 20 21 #define OMAP24XX_TAP_BASE io_p2v(0x48014000) 22 23 #define OMAP_TAP_IDCODE 0x0204 24 #define OMAP_TAP_PROD_ID 0x0208 25 26 #define OMAP_TAP_DIE_ID_0 0x0218 27 #define OMAP_TAP_DIE_ID_1 0x021C 28 #define OMAP_TAP_DIE_ID_2 0x0220 29 #define OMAP_TAP_DIE_ID_3 0x0224 30 31 /* system_rev fields for OMAP2 processors: 32 * CPU id bits [31:16], 33 * CPU device type [15:12], (unprg,normal,POP) 34 * CPU revision [11:08] 35 * CPU class bits [07:00] 36 */ 37 38 struct omap_id { 39 u16 hawkeye; /* Silicon type (Hawkeye id) */ 40 u8 dev; /* Device type from production_id reg */ 41 u32 type; /* combined type id copied to system_rev */ 42 }; 43 44 /* Register values to detect the OMAP version */ 45 static struct omap_id omap_ids[] __initdata = { 46 { .hawkeye = 0xb5d9, .dev = 0x0, .type = 0x24200000 }, 47 { .hawkeye = 0xb5d9, .dev = 0x1, .type = 0x24201000 }, 48 { .hawkeye = 0xb5d9, .dev = 0x2, .type = 0x24202000 }, 49 { .hawkeye = 0xb5d9, .dev = 0x4, .type = 0x24220000 }, 50 { .hawkeye = 0xb5d9, .dev = 0x8, .type = 0x24230000 }, 51 { .hawkeye = 0xb68a, .dev = 0x0, .type = 0x24300000 }, 52 }; 53 54 static u32 __init read_tap_reg(int reg) 55 { 56 return __raw_readl(OMAP24XX_TAP_BASE + reg); 57 } 58 59 void __init omap2_check_revision(void) 60 { 61 int i, j; 62 u32 idcode; 63 u32 prod_id; 64 u16 hawkeye; 65 u8 dev_type; 66 u8 rev; 67 68 idcode = read_tap_reg(OMAP_TAP_IDCODE); 69 prod_id = read_tap_reg(OMAP_TAP_PROD_ID); 70 hawkeye = (idcode >> 12) & 0xffff; 71 rev = (idcode >> 28) & 0x0f; 72 dev_type = (prod_id >> 16) & 0x0f; 73 74 #ifdef DEBUG 75 printk(KERN_DEBUG "OMAP_TAP_IDCODE 0x%08x REV %i HAWKEYE 0x%04x MANF %03x\n", 76 idcode, rev, hawkeye, (idcode >> 1) & 0x7ff); 77 printk(KERN_DEBUG "OMAP_TAP_DIE_ID_0: 0x%08x\n", 78 read_tap_reg(OMAP_TAP_DIE_ID_0)); 79 printk(KERN_DEBUG "OMAP_TAP_DIE_ID_1: 0x%08x DEV_REV: %i\n", 80 read_tap_reg(OMAP_TAP_DIE_ID_1), 81 (read_tap_reg(OMAP_TAP_DIE_ID_1) >> 28) & 0xf); 82 printk(KERN_DEBUG "OMAP_TAP_DIE_ID_2: 0x%08x\n", 83 read_tap_reg(OMAP_TAP_DIE_ID_2)); 84 printk(KERN_DEBUG "OMAP_TAP_DIE_ID_3: 0x%08x\n", 85 read_tap_reg(OMAP_TAP_DIE_ID_3)); 86 printk(KERN_DEBUG "OMAP_TAP_PROD_ID_0: 0x%08x DEV_TYPE: %i\n", 87 prod_id, dev_type); 88 #endif 89 90 /* Check hawkeye ids */ 91 for (i = 0; i < ARRAY_SIZE(omap_ids); i++) { 92 if (hawkeye == omap_ids[i].hawkeye) 93 break; 94 } 95 96 if (i == ARRAY_SIZE(omap_ids)) { 97 printk(KERN_ERR "Unknown OMAP CPU id\n"); 98 return; 99 } 100 101 for (j = i; j < ARRAY_SIZE(omap_ids); j++) { 102 if (dev_type == omap_ids[j].dev) 103 break; 104 } 105 106 if (j == ARRAY_SIZE(omap_ids)) { 107 printk(KERN_ERR "Unknown OMAP device type. " 108 "Handling it as OMAP%04x\n", 109 omap_ids[i].type >> 16); 110 j = i; 111 } 112 system_rev = omap_ids[j].type; 113 114 system_rev |= rev << 8; 115 116 /* Add the cpu class info (24xx) */ 117 system_rev |= 0x24; 118 119 pr_info("OMAP%04x", system_rev >> 16); 120 if ((system_rev >> 8) & 0x0f) 121 printk("%x", (system_rev >> 8) & 0x0f); 122 printk("\n"); 123 } 124 125