2 * See file CREDITS for list of people who contributed to this
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 #include <asm/arch/bits.h>
24 #include <asm/arch/clocks.h>
25 #include <asm/arch/sys_proto.h>
26 #include <asm/arch/sys_info.h>
28 static char *rev_s[CPU_3XX_MAX_REV] = {
39 * sr32: clear & set a value in a bit range for a 32 bit address
41 void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
46 tmp = __raw_readl(addr) & ~(msk << start_bit);
47 tmp |= value << start_bit;
48 __raw_writel(tmp, addr);
52 * wait_on_value(): common routine to allow waiting for changes in
55 u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
60 val = __raw_readl(read_addr) & read_bit_mask;
61 if (val == match_value)
69 * get_device_type(): tell if GP/HS/EMU/TST
71 u32 get_device_type(void)
74 mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK);
79 * get_cpu_type(): extract cpu info
81 u32 get_cpu_type(void)
83 return __raw_readl(CONTROL_OMAP_STATUS);
87 * get_cpu_id(): extract cpu id
88 * returns 0 for ES1.0, cpuid otherwise
95 * On ES1.0 the IDCODE register is not exposed on L4
96 * so using CPU ID to differentiate between ES1.0 and > ES1.0.
98 __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid));
99 if ((cpuid & 0xf) == 0x0) {
102 /* Decode the IDs on > ES1.0 */
103 cpuid = __raw_readl(CONTROL_IDCODE);
110 * get_cpu_family(void): extract cpu info
112 u32 get_cpu_family(void)
116 u32 cpuid = get_cpu_id();
121 hawkeye = (cpuid >> HAWKEYE_SHIFT) & 0xffff;
123 case HAWKEYE_OMAP34XX:
124 cpu_family = CPU_OMAP34XX;
127 cpu_family = CPU_AM35XX;
129 case HAWKEYE_OMAP36XX:
130 cpu_family = CPU_OMAP36XX;
133 cpu_family = CPU_OMAP34XX;
140 * get_cpu_rev(void): extract version info
142 u32 get_cpu_rev(void)
144 u32 cpuid = get_cpu_id();
149 return (cpuid >> CPU_3XX_ID_SHIFT) & 0xf;
153 * print_cpuinfo(void): print CPU information
155 int print_cpuinfo(void)
157 char *cpu_family_s, *cpu_s, *sec_s;
159 switch (get_cpu_family()) {
161 cpu_family_s = "OMAP";
162 switch (get_cpu_type()) {
182 switch (get_cpu_type()) {
195 cpu_family_s = "OMAP";
196 switch (get_cpu_type()) {
206 cpu_family_s = "OMAP";
210 switch (get_device_type()) {
227 printf("%s%s-%s ES%s\n",
228 cpu_family_s, cpu_s, sec_s, rev_s[get_cpu_rev()]);
234 * get_sysboot_value(void): return SYS_BOOT[4:0]
236 u32 get_sysboot_value(void)
239 mode = __raw_readl(CONTROL_STATUS) & (SYSBOOT_MASK);
244 * get_sys_clkin_sel(): returns the sys_clkin_sel field value based on
245 * input oscillator clock frequency.
247 void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
249 if (osc_clk == S38_4M)
251 else if (osc_clk == S26M)
253 else if (osc_clk == S19_2M)
255 else if (osc_clk == S13M)
257 else if (osc_clk == S12M)
262 * secure_unlock(void): setup security registers for access
265 void secure_unlock(void)
267 /* Permission values for registers -Full fledged permissions to all */
268 #define UNLOCK_1 0xFFFFFFFF
269 #define UNLOCK_2 0x00000000
270 #define UNLOCK_3 0x0000FFFF
271 /* Protection Module Register Target APE (PM_RT)*/
272 __raw_writel(UNLOCK_1, RT_REQ_INFO_PERMISSION_1);
273 __raw_writel(UNLOCK_1, RT_READ_PERMISSION_0);
274 __raw_writel(UNLOCK_1, RT_WRITE_PERMISSION_0);
275 __raw_writel(UNLOCK_2, RT_ADDR_MATCH_1);
277 __raw_writel(UNLOCK_3, GPMC_REQ_INFO_PERMISSION_0);
278 __raw_writel(UNLOCK_3, GPMC_READ_PERMISSION_0);
279 __raw_writel(UNLOCK_3, GPMC_WRITE_PERMISSION_0);
281 __raw_writel(UNLOCK_3, OCM_REQ_INFO_PERMISSION_0);
282 __raw_writel(UNLOCK_3, OCM_READ_PERMISSION_0);
283 __raw_writel(UNLOCK_3, OCM_WRITE_PERMISSION_0);
284 __raw_writel(UNLOCK_2, OCM_ADDR_MATCH_2);
287 __raw_writel(UNLOCK_3, IVA2_REQ_INFO_PERMISSION_0);
288 __raw_writel(UNLOCK_3, IVA2_READ_PERMISSION_0);
289 __raw_writel(UNLOCK_3, IVA2_WRITE_PERMISSION_0);
291 __raw_writel(UNLOCK_1, SMS_RG_ATT0); /* SDRC region 0 public */
295 * try_unlock_memory(void): If chip is GP type, unlock the SRAM for
298 void try_unlock_memory(void)
302 /* if GP device unlock device SRAM for general use */
303 /* secure code breaks for Secure/Emulation device - HS/E/T*/
304 mode = get_device_type();
305 if (mode == GP_DEVICE) {