Chandan Nath | 1c95969 | 2011-10-14 02:58:22 +0000 | [diff] [blame] | 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 | /** |
| 90 | * Print CPU information |
| 91 | */ |
| 92 | int print_cpuinfo(void) |
| 93 | { |
| 94 | char *cpu_s, *sec_s; |
| 95 | int arm_freq, ddr_freq; |
| 96 | |
| 97 | switch (get_cpu_type()) { |
| 98 | case AM335X: |
| 99 | cpu_s = "AM335X"; |
| 100 | break; |
| 101 | default: |
| 102 | cpu_s = "Unknown cpu type"; |
| 103 | break; |
| 104 | } |
| 105 | |
| 106 | switch (get_device_type()) { |
| 107 | case TST_DEVICE: |
| 108 | sec_s = "TST"; |
| 109 | break; |
| 110 | case EMU_DEVICE: |
| 111 | sec_s = "EMU"; |
| 112 | break; |
| 113 | case HS_DEVICE: |
| 114 | sec_s = "HS"; |
| 115 | break; |
| 116 | case GP_DEVICE: |
| 117 | sec_s = "GP"; |
| 118 | break; |
| 119 | default: |
| 120 | sec_s = "?"; |
| 121 | } |
| 122 | |
| 123 | printf("AM%s-%s rev %d\n", |
| 124 | cpu_s, sec_s, get_cpu_rev()); |
| 125 | |
| 126 | /* TODO: Print ARM and DDR frequencies */ |
| 127 | |
| 128 | return 0; |
| 129 | } |
| 130 | #endif /* CONFIG_DISPLAY_CPUINFO */ |