diff options
Diffstat (limited to 'arch/arm/mach-davinci/id.c')
| -rw-r--r-- | arch/arm/mach-davinci/id.c | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/arch/arm/mach-davinci/id.c b/arch/arm/mach-davinci/id.c new file mode 100644 index 000000000000..70608f76aed8 --- /dev/null +++ b/arch/arm/mach-davinci/id.c | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | /* | ||
| 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> | ||
| 16 | |||
| 17 | #include <asm/io.h> | ||
| 18 | |||
| 19 | #define JTAG_ID_BASE 0x01c40028 | ||
| 20 | |||
| 21 | struct davinci_id { | ||
| 22 | u8 variant; /* JTAG ID bits 31:28 */ | ||
| 23 | u16 part_no; /* JTAG ID bits 27:12 */ | ||
| 24 | u32 manufacturer; /* JTAG ID bits 11:1 */ | ||
| 25 | u32 type; /* Cpu id bits [31:8], cpu class bits [7:0] */ | ||
| 26 | }; | ||
| 27 | |||
| 28 | /* Register values to detect the DaVinci version */ | ||
| 29 | static struct davinci_id davinci_ids[] __initdata = { | ||
| 30 | { | ||
| 31 | /* DM6446 */ | ||
| 32 | .part_no = 0xb700, | ||
| 33 | .variant = 0x0, | ||
| 34 | .manufacturer = 0x017, | ||
| 35 | .type = 0x64460000, | ||
| 36 | }, | ||
| 37 | }; | ||
| 38 | |||
| 39 | /* | ||
| 40 | * Get Device Part No. from JTAG ID register | ||
| 41 | */ | ||
| 42 | static u16 __init davinci_get_part_no(void) | ||
| 43 | { | ||
| 44 | u32 dev_id, part_no; | ||
| 45 | |||
| 46 | dev_id = davinci_readl(JTAG_ID_BASE); | ||
| 47 | |||
| 48 | part_no = ((dev_id >> 12) & 0xffff); | ||
| 49 | |||
| 50 | return part_no; | ||
| 51 | } | ||
| 52 | |||
| 53 | /* | ||
| 54 | * Get Device Revision from JTAG ID register | ||
| 55 | */ | ||
| 56 | static u8 __init davinci_get_variant(void) | ||
| 57 | { | ||
| 58 | u32 variant; | ||
| 59 | |||
| 60 | variant = davinci_readl(JTAG_ID_BASE); | ||
| 61 | |||
| 62 | variant = (variant >> 28) & 0xf; | ||
| 63 | |||
| 64 | return variant; | ||
| 65 | } | ||
| 66 | |||
| 67 | void __init davinci_check_revision(void) | ||
| 68 | { | ||
| 69 | int i; | ||
| 70 | u16 part_no; | ||
| 71 | u8 variant; | ||
| 72 | |||
| 73 | part_no = davinci_get_part_no(); | ||
| 74 | variant = davinci_get_variant(); | ||
| 75 | |||
| 76 | /* First check only the major version in a safe way */ | ||
| 77 | for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) { | ||
| 78 | if (part_no == (davinci_ids[i].part_no)) { | ||
| 79 | system_rev = davinci_ids[i].type; | ||
| 80 | break; | ||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | /* Check if we can find the dev revision */ | ||
| 85 | for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) { | ||
| 86 | if (part_no == davinci_ids[i].part_no && | ||
| 87 | variant == davinci_ids[i].variant) { | ||
| 88 | system_rev = davinci_ids[i].type; | ||
| 89 | break; | ||
| 90 | } | ||
| 91 | } | ||
| 92 | |||
| 93 | printk("DaVinci DM%04x variant 0x%x\n", system_rev >> 16, variant); | ||
| 94 | } | ||
