]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/armv7/am33xx/sys_info.c
TX6 Release 2013-04-22
[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  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License as
14  * published by the Free Software Foundation; either version 2 of
15  * the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE.  See the
20  * GNU General Public License for more details.
21  */
22
23 #include <common.h>
24 #include <asm/io.h>
25 #include <asm/arch/sys_proto.h>
26 #include <asm/arch/cpu.h>
27 #include <asm/arch/clock.h>
28
29 struct ctrl_stat *cstat = (struct ctrl_stat *)CTRL_BASE;
30
31 /**
32  * get_cpu_rev(void) - extract rev info
33  */
34 u32 get_cpu_rev(void)
35 {
36         u32 id;
37         u32 rev;
38
39         id = readl(DEVICE_ID);
40         rev = (id >> 28) & 0xff;
41
42         return rev;
43 }
44
45 /**
46  * get_cpu_type(void) - extract cpu info
47  */
48 u32 get_cpu_type(void)
49 {
50         u32 id = 0;
51         u32 partnum;
52
53         id = readl(DEVICE_ID);
54         partnum = (id >> 12) & 0xffff;
55
56         return partnum;
57 }
58
59 /**
60  * get_board_rev() - setup to pass kernel board revision information
61  * returns:(bit[0-3] sub version, higher bit[7-4] is higher version)
62  */
63 u32 get_board_rev(void)
64 {
65         return BOARD_REV_ID;
66 }
67
68 /**
69  * get_device_type(): tell if GP/HS/EMU/TST
70  */
71 u32 get_device_type(void)
72 {
73         int mode;
74         mode = readl(&cstat->statusreg) & DEVICE_MASK;
75         return mode >>= 8;
76 }
77
78 /**
79  * get_sysboot_value(void) - return SYS_BOOT[4:0]
80  */
81 u32 get_sysboot_value(void)
82 {
83         int mode;
84         mode = readl(&cstat->statusreg) & SYSBOOT_MASK;
85         return mode;
86 }
87
88 #ifdef CONFIG_DISPLAY_CPUINFO
89 #define SYSBOOT_FREQ_SHIFT      22
90 #define SYSBOOT_FREQ_MASK       (3 << SYSBOOT_FREQ_SHIFT)
91
92 static unsigned long bootfreqs[] = {
93         19200000,
94         24000000,
95         25000000,
96         26000000,
97 };
98
99 static u32 get_sysboot_freq(void)
100 {
101         int mode;
102         mode = readl(&cstat->statusreg) & SYSBOOT_FREQ_MASK;
103         return bootfreqs[mode >> SYSBOOT_FREQ_SHIFT];
104 }
105
106 /**
107  * Print CPU information
108  */
109 int print_cpuinfo(void)
110 {
111         char *cpu_s, *sec_s;
112         unsigned long clk;
113         const struct cm_wkuppll *cmwkup = (struct cm_wkuppll *)CM_WKUP;
114
115         switch (get_cpu_type()) {
116         case AM335X_ID:
117                 cpu_s = "AM335X";
118                 break;
119         default:
120                 cpu_s = "Unknown cpu type";
121         }
122
123         switch (get_device_type()) {
124         case TST_DEVICE:
125                 sec_s = "TST";
126                 break;
127         case EMU_DEVICE:
128                 sec_s = "EMU";
129                 break;
130         case HS_DEVICE:
131                 sec_s = "HS";
132                 break;
133         case GP_DEVICE:
134                 sec_s = "GP";
135                 break;
136         default:
137                 sec_s = "?";
138         }
139
140         printf("%s-%s rev %d\n",
141                         cpu_s, sec_s, get_cpu_rev());
142
143         clk = get_sysboot_freq();
144         printf("OSC clk: %4lu.%03lu MHz\n",
145                 clk / 1000000, clk / 1000 % 1000);
146         clk = clk_get_rate(cmwkup, mpu);
147         printf("MPU clk: %4lu.%03lu MHz\n",
148                 clk / 1000000, clk / 1000 % 1000);
149         clk = clk_get_rate(cmwkup, ddr);
150         printf("DDR clk: %4lu.%03lu MHz\n",
151                 clk / 1000000, clk / 1000 % 1000);
152         clk = clk_get_rate(cmwkup, per);
153         printf("PER clk: %4lu.%03lu MHz\n",
154                 clk / 1000000, clk / 1000 % 1000);
155 #ifdef CONFIG_LCD
156         clk = clk_get_rate(cmwkup, disp);
157         printf("LCD clk: %4lu.%03lu MHz\n",
158                 clk / 1000000, clk / 1000 % 1000);
159 #endif
160
161         return 0;
162 }
163 #endif  /* CONFIG_DISPLAY_CPUINFO */