3 * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 #include <asm/arch/hardware.h>
30 #include <asm/arch/spr_xloader_table.h>
31 #include <asm/arch/spr_defs.h>
35 #define SRAM_REL 0xD2801000
37 DECLARE_GLOBAL_DATA_PTR;
38 static struct chip_data chip_data;
42 struct xloader_table *xloader_tb =
43 (struct xloader_table *)XLOADER_TABLE_ADDRESS;
44 struct xloader_table_1_1 *table_1_1;
45 struct xloader_table_1_2 *table_1_2;
46 struct chip_data *chip = &chip_data;
48 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
49 gd->bd->bi_dram[0].size = get_ram_size(PHYS_SDRAM_1,
50 PHYS_SDRAM_1_MAXSIZE);
52 if (XLOADER_TABLE_VERSION_1_1 == xloader_tb->table_version) {
53 table_1_1 = &xloader_tb->table.table_1_1;
54 chip->dramfreq = table_1_1->ddrfreq;
55 chip->dramtype = table_1_1->ddrtype;
57 } else if (XLOADER_TABLE_VERSION_1_2 == xloader_tb->table_version) {
58 table_1_2 = &xloader_tb->table.table_1_2;
59 chip->dramfreq = table_1_2->ddrfreq;
60 chip->dramtype = table_1_2->ddrtype;
70 setenv("verify", "n");
72 #if defined(CONFIG_SPEAR_USBTTY)
73 setenv("stdin", "usbtty");
74 setenv("stdout", "usbtty");
75 setenv("stderr", "usbtty");
80 int spear_board_init(ulong mach_type)
82 struct xloader_table *xloader_tb =
83 (struct xloader_table *)XLOADER_TABLE_ADDRESS;
84 struct xloader_table_1_2 *table_1_2;
85 struct chip_data *chip = &chip_data;
87 gd->bd->bi_arch_number = mach_type;
89 /* adress of boot parameters */
90 gd->bd->bi_boot_params = CONFIG_BOOT_PARAMS_ADDR;
92 /* CPU is initialized to work at 333MHz in Xloader */
95 if (XLOADER_TABLE_VERSION_1_2 == xloader_tb->table_version) {
96 table_1_2 = &xloader_tb->table.table_1_2;
97 memcpy(chip->version, table_1_2->version,
98 sizeof(chip->version));
104 int do_chip_config(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
106 void (*sram_setfreq) (unsigned int, unsigned int);
107 struct chip_data *chip = &chip_data;
108 unsigned char mac[6];
109 unsigned int frequency;
111 if ((argc > 3) || (argc < 2)) {
116 if ((!strcmp(argv[1], "cpufreq")) || (!strcmp(argv[1], "ddrfreq"))) {
118 frequency = simple_strtoul(argv[2], NULL, 0);
120 if (frequency > 333) {
121 printf("Frequency is limited to 333MHz\n");
125 sram_setfreq = memcpy((void *)SRAM_REL, setfreq, setfreq_sz);
127 if (!strcmp(argv[1], "cpufreq")) {
128 sram_setfreq(CPU, frequency);
129 printf("CPU frequency changed to %u\n", frequency);
131 chip->cpufreq = frequency;
133 sram_setfreq(DDR, frequency);
134 printf("DDR frequency changed to %u\n", frequency);
136 chip->dramfreq = frequency;
140 } else if (!strcmp(argv[1], "print")) {
142 if (chip->cpufreq == -1)
143 printf("CPU Freq = Not Known\n");
145 printf("CPU Freq = %d MHz\n", chip->cpufreq);
147 if (chip->dramfreq == -1)
148 printf("DDR Freq = Not Known\n");
150 printf("DDR Freq = %d MHz\n", chip->dramfreq);
152 if (chip->dramtype == DDRMOBILE)
153 printf("DDR Type = MOBILE\n");
154 else if (chip->dramtype == DDR2)
155 printf("DDR Type = DDR2\n");
157 printf("DDR Type = Not Known\n");
159 printf("Xloader Rev = %s\n", chip->version);
168 U_BOOT_CMD(chip_config, 3, 1, do_chip_config,
170 "chip_config cpufreq/ddrfreq frequency\n"
171 "chip_config print");