1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
41static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
42{
43 u8 chip;
44 u8 *buf;
45 int cpu_freq;
46
47 if (argc < 3) {
48 cmd_usage(cmdtp);
49 return 1;
50 }
51
52 cpu_freq = simple_strtol(argv[1], NULL, 10);
53 if (cpu_freq != 267) {
54 printf("Unsupported cpu-frequency - only 267 supported\n");
55 return 1;
56 }
57
58
59 chip = 0x50;
60
61 if ((strcmp(argv[2], "nor") != 0) &&
62 (strcmp(argv[2], "nand") != 0)) {
63 printf("Unsupported boot-device - only nor|nand support\n");
64 return 1;
65 }
66
67 if (strcmp(argv[2], "nand") == 0) {
68 switch (cpu_freq) {
69 case 267:
70 buf = boot_267_nand;
71 break;
72 default:
73 break;
74 }
75 } else {
76 switch (cpu_freq) {
77 case 267:
78 buf = boot_267_nor;
79 break;
80 default:
81 break;
82 }
83 }
84
85 if (i2c_write(chip, 0, 1, buf, 16) != 0)
86 printf("Error writing to EEPROM at address 0x%x\n", chip);
87 udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
88 if (i2c_write(chip, 0x10, 1, buf+16, 4) != 0)
89 printf("Error2 writing to EEPROM at address 0x%x\n", chip);
90
91 printf("Done\n");
92 printf("Please power-cycle the board for the changes to take effect\n");
93
94 return 0;
95}
96
97U_BOOT_CMD(
98 bootstrap, 3, 0, do_bootstrap,
99 "program the I2C bootstrap EEPROM",
100 "<cpu-freq> <nor|nand> - program the I2C bootstrap EEPROM"
101);
102