blob: 6936e5104020b78fa785a1d60d5cbf0413977b16 [file] [log] [blame]
Stefan Roese23d8d342007-06-06 11:42:13 +02001/*
2 * (C) Copyright 2007
3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
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.
12 *
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.
17 *
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,
21 * MA 02111-1307 USA
22 *
23 */
24
25#include <common.h>
26#include <command.h>
27#include <i2c.h>
28
29static u8 boot_267_nor[] = {
30 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8e, 0x00,
31 0x14, 0xc0, 0x36, 0xcc, 0x00, 0x0c, 0x00, 0x00,
32 0x00, 0x00, 0x00, 0x00
33};
34
35static u8 boot_267_nand[] = {
36 0xd0, 0x38, 0xc3, 0x50, 0x13, 0x88, 0x8e, 0x00,
37 0x14, 0xc0, 0x36, 0xcc, 0x00, 0x0c, 0x00, 0x00,
38 0x00, 0x00, 0x00, 0x00
39};
40
Wolfgang Denk6262d0212010-06-28 22:00:46 +020041static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Stefan Roese23d8d342007-06-06 11:42:13 +020042{
43 u8 chip;
44 u8 *buf;
45 int cpu_freq;
46
Wolfgang Denk3b683112010-07-17 01:06:04 +020047 if (argc < 3)
48 return cmd_usage(cmdtp);
Stefan Roese23d8d342007-06-06 11:42:13 +020049
50 cpu_freq = simple_strtol(argv[1], NULL, 10);
51 if (cpu_freq != 267) {
52 printf("Unsupported cpu-frequency - only 267 supported\n");
53 return 1;
54 }
55
56 /* use 0x50 as I2C EEPROM address for now */
57 chip = 0x50;
58
59 if ((strcmp(argv[2], "nor") != 0) &&
60 (strcmp(argv[2], "nand") != 0)) {
61 printf("Unsupported boot-device - only nor|nand support\n");
62 return 1;
63 }
64
65 if (strcmp(argv[2], "nand") == 0) {
66 switch (cpu_freq) {
67 case 267:
68 buf = boot_267_nand;
69 break;
70 default:
71 break;
72 }
73 } else {
74 switch (cpu_freq) {
75 case 267:
76 buf = boot_267_nor;
77 break;
78 default:
79 break;
80 }
81 }
82
83 if (i2c_write(chip, 0, 1, buf, 16) != 0)
84 printf("Error writing to EEPROM at address 0x%x\n", chip);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020085 udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
Stefan Roese23d8d342007-06-06 11:42:13 +020086 if (i2c_write(chip, 0x10, 1, buf+16, 4) != 0)
87 printf("Error2 writing to EEPROM at address 0x%x\n", chip);
88
89 printf("Done\n");
90 printf("Please power-cycle the board for the changes to take effect\n");
91
92 return 0;
93}
94
95U_BOOT_CMD(
96 bootstrap, 3, 0, do_bootstrap,
Peter Tyserdfb72b82009-01-27 18:03:12 -060097 "program the I2C bootstrap EEPROM",
Wolfgang Denkc54781c2009-05-24 17:06:54 +020098 "<cpu-freq> <nor|nand> - program the I2C bootstrap EEPROM"
99);