summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-davinci/id.c
blob: 70608f76aed85c519b9ffa8d9a6f98b730300b3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
 * Davinci CPU identification code
 *
 * Copyright (C) 2006 Komal Shah <komal_shah802003@yahoo.com>
 *
 * Derived from OMAP1 CPU identification code.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>

#include <asm/io.h>

#define JTAG_ID_BASE		0x01c40028

struct davinci_id {
	u8	variant;	/* JTAG ID bits 31:28 */
	u16	part_no;	/* JTAG ID bits 27:12 */
	u32	manufacturer;	/* JTAG ID bits 11:1 */
	u32	type;		/* Cpu id bits [31:8], cpu class bits [7:0] */
};

/* Register values to detect the DaVinci version */
static struct davinci_id davinci_ids[] __initdata = {
	{
		/* DM6446 */
		.part_no      = 0xb700,
		.variant      = 0x0,
		.manufacturer = 0x017,
		.type	      = 0x64460000,
	},
};

/*
 * Get Device Part No. from JTAG ID register
 */
static u16 __init davinci_get_part_no(void)
{
	u32 dev_id, part_no;

	dev_id = davinci_readl(JTAG_ID_BASE);

	part_no = ((dev_id >> 12) & 0xffff);

	return part_no;
}

/*
 * Get Device Revision from JTAG ID register
 */
static u8 __init davinci_get_variant(void)
{
	u32 variant;

	variant = davinci_readl(JTAG_ID_BASE);

	variant = (variant >> 28) & 0xf;

	return variant;
}

void __init davinci_check_revision(void)
{
	int i;
	u16 part_no;
	u8 variant;

	part_no = davinci_get_part_no();
	variant = davinci_get_variant();

	/* First check only the major version in a safe way */
	for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) {
		if (part_no == (davinci_ids[i].part_no)) {
			system_rev = davinci_ids[i].type;
			break;
		}
	}

	/* Check if we can find the dev revision */
	for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) {
		if (part_no == davinci_ids[i].part_no &&
		    variant == davinci_ids[i].variant) {
			system_rev = davinci_ids[i].type;
			break;
		}
	}

	printk("DaVinci DM%04x variant 0x%x\n", system_rev >> 16, variant);
}
OpenPOWER on IntegriCloud