]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/armv7/am33xx/sys_info.c
ab327c86566653194f42ea9c2c33d95e8d7e67ac
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / am33xx / sys_info.c
1 /*
2  * sys_info.c
3  *
4  * System information functions
5  *
6  * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
7  *
8  * Derived from Beagle Board and 3430 SDP code by
9  *      Richard Woodruff <r-woodruff2@ti.com>
10  *      Syed Mohammed Khasim <khasim@ti.com>
11  *
12  * SPDX-License-Identifier:     GPL-2.0+
13  */
14
15 #include <common.h>
16 #include <asm/io.h>
17 #include <asm/arch/sys_proto.h>
18 #include <asm/arch/cpu.h>
19 #include <asm/arch/clock.h>
20
21 struct ctrl_stat *cstat = (struct ctrl_stat *)CTRL_BASE;
22
23 /**
24  * get_cpu_rev(void) - extract rev info
25  */
26 u32 get_cpu_rev(void)
27 {
28         u32 id;
29         u32 rev;
30
31         id = readl(DEVICE_ID);
32         rev = (id >> 28) & 0xff;
33
34         return rev;
35 }
36
37 /**
38  * get_cpu_type(void) - extract cpu info
39  */
40 u32 get_cpu_type(void)
41 {
42         u32 id = 0;
43         u32 partnum;
44
45         id = readl(DEVICE_ID);
46         partnum = (id >> 12) & 0xffff;
47
48         return partnum;
49 }
50
51 /**
52  * get_board_rev() - setup to pass kernel board revision information
53  * returns:(bit[0-3] sub version, higher bit[7-4] is higher version)
54  */
55 u32 get_board_rev(void)
56 {
57         return BOARD_REV_ID;
58 }
59
60 /**
61  * get_device_type(): tell if GP/HS/EMU/TST
62  */
63 u32 get_device_type(void)
64 {
65         int mode;
66         mode = readl(&cstat->statusreg) & DEVICE_MASK;
67         return mode >>= 8;
68 }
69
70 /**
71  * get_sysboot_value(void) - return SYS_BOOT[4:0]
72  */
73 u32 get_sysboot_value(void)
74 {
75         int mode;
76         mode = readl(&cstat->statusreg) & SYSBOOT_MASK;
77         return mode;
78 }
79
80 #ifdef CONFIG_DISPLAY_CPUINFO
81 static char *cpu_revs[] = {
82         "1.0",
83         "2.0",
84         "2.1",
85 };
86
87 static char *dev_types[] = {
88         "TST",
89         "EMU",
90         "HS",
91         "GP",
92 };
93
94 /**
95  * Print CPU information
96  */
97 int print_cpuinfo(void)
98 {
99         char *cpu_s, *sec_s, *rev_s;
100
101         switch (get_cpu_type()) {
102         case AM335X:
103                 cpu_s = "AM335X";
104                 break;
105         case TI81XX:
106                 cpu_s = "TI81XX";
107                 break;
108         default:
109                 cpu_s = "Unknown CPU type";
110         }
111
112         if (get_cpu_rev() < ARRAY_SIZE(cpu_revs))
113                 rev_s = cpu_revs[get_cpu_rev()];
114         else
115                 rev_s = "?";
116
117         if (get_device_type() < ARRAY_SIZE(dev_types))
118                 sec_s = dev_types[get_device_type()];
119         else
120                 sec_s = "?";
121
122         printf("%s-%s rev %s\n", cpu_s, sec_s, rev_s);
123
124         return 0;
125 }
126 #endif  /* CONFIG_DISPLAY_CPUINFO */