-
Notifications
You must be signed in to change notification settings - Fork 2
/
utilite-uboot.patch
209 lines (196 loc) · 5.09 KB
/
utilite-uboot.patch
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c
index fdb8ebf..40381a2 100644
--- a/board/compulab/cm_fx6/cm_fx6.c
+++ b/board/compulab/cm_fx6/cm_fx6.c
@@ -316,12 +316,36 @@ static int handle_mac_address(void)
return eth_setenv_enetaddr("ethaddr", enetaddr);
}
+static int handle_igb_mac_address(void)
+{
+ unsigned char enetaddr[6];
+ int rc;
+
+ rc = eth_getenv_enetaddr("eth1addr", enetaddr);
+ if (rc)
+ return 0;
+
+ rc = cl_igb_eeprom_read_mac_addr(enetaddr);
+ if (rc)
+ return rc;
+
+ if (!is_valid_ether_addr(enetaddr))
+ return -1;
+
+ return eth_setenv_enetaddr("eth1addr", enetaddr);
+}
+
+
int board_eth_init(bd_t *bis)
{
int res = handle_mac_address();
if (res)
puts("No MAC address found\n");
+ res = handle_igb_mac_address();
+ if (res)
+ puts("No MAC address found\n");
+
SETUP_IOMUX_PADS(enet_pads);
/* phy reset */
gpio_direction_output(CM_FX6_ENET_NRST, 0);
@@ -404,6 +428,14 @@ void ft_board_setup(void *blob, bd_t *bd)
fdt_find_and_setprop(blob, "/fec", "local-mac-address",
enetaddr, 6, 1);
}
+
+
+ /* MAC addr */
+ if (eth_getenv_enetaddr("eth1addr", enetaddr)) {
+ fdt_find_and_setprop(blob, "/eth@pcie", "local-mac-address",
+ enetaddr, 6, 1);
+ }
+
}
#endif
diff --git a/board/compulab/common/eeprom.c b/board/compulab/common/eeprom.c
index 2df3ada..f063448 100644
--- a/board/compulab/common/eeprom.c
+++ b/board/compulab/common/eeprom.c
@@ -50,6 +50,20 @@ static int cl_eeprom_read(uint offset, uchar *buf, int len)
return res;
}
+static int cl_igb_eeprom_read(uint offset, uchar *buf, int len)
+{
+ int res;
+ unsigned int current_i2c_bus = i2c_get_bus_num();
+
+ i2c_set_bus_num(CONFIG_SYS_I2C_IGB_EEPROM_BUS);
+ res = i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, offset,
+ CONFIG_SYS_I2C_EEPROM_ADDR_LEN, buf, len);
+
+ i2c_set_bus_num(current_i2c_bus);
+
+ return res;
+}
+
static int cl_eeprom_setup_layout(void)
{
int res;
@@ -109,6 +123,19 @@ int cl_eeprom_read_mac_addr(uchar *buf)
return cl_eeprom_read(offset, buf, 6);
}
+int cl_igb_eeprom_read_mac_addr(uchar *buf)
+{
+ uint offset;
+
+ if (cl_eeprom_setup_layout())
+ return 0;
+
+ offset = (cl_eeprom_layout != LAYOUT_LEGACY) ?
+ MAC_ADDR_OFFSET : MAC_ADDR_OFFSET_LEGACY;
+
+ return cl_igb_eeprom_read(offset, buf, 6);
+}
+
/*
* Routine: cl_eeprom_get_board_rev
* Description: read system revision from eeprom
diff --git a/board/compulab/common/eeprom.h b/board/compulab/common/eeprom.h
index 85d5bf0..3f16218 100644
--- a/board/compulab/common/eeprom.h
+++ b/board/compulab/common/eeprom.h
@@ -12,6 +12,7 @@
#ifdef CONFIG_SYS_I2C
int cl_eeprom_read_mac_addr(uchar *buf);
+int cl_igb_eeprom_read_mac_addr(uchar *buf);
u32 cl_eeprom_get_board_rev(void);
#else
static inline int cl_eeprom_read_mac_addr(uchar *buf)
diff --git a/common/spl/spl.c b/common/spl/spl.c
index b16664f..193fee3 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -163,8 +163,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
case BOOT_DEVICE_MMC1:
case BOOT_DEVICE_MMC2:
case BOOT_DEVICE_MMC2_2:
- spl_mmc_load_image();
- break;
+ if(!spl_mmc_load_image())
+ break;
+ else
+ puts("MMC boot failed, booting from SPI flash\n");
#endif
#ifdef CONFIG_SPL_NAND_SUPPORT
case BOOT_DEVICE_NAND:
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index fa6f891..9899d29 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -68,7 +68,7 @@ static int mmc_load_image_raw_os(struct mmc *mmc)
}
#endif
-void spl_mmc_load_image(void)
+int spl_mmc_load_image(void)
{
struct mmc *mmc;
int err;
@@ -81,7 +81,7 @@ void spl_mmc_load_image(void)
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
puts("spl: mmc device not found!!\n");
#endif
- hang();
+ return -1;
}
err = mmc_init(mmc);
@@ -89,7 +89,7 @@ void spl_mmc_load_image(void)
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("spl: mmc init failed: err - %d\n", err);
#endif
- hang();
+ return -1;
}
boot_mode = spl_boot_mode();
@@ -127,7 +127,7 @@ void spl_mmc_load_image(void)
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
puts("MMC partition switch failed\n");
#endif
- hang();
+ return -1;
}
#ifdef CONFIG_SPL_OS_BOOT
if (spl_start_uboot() || mmc_load_image_raw_os(mmc))
@@ -139,9 +139,11 @@ void spl_mmc_load_image(void)
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
puts("spl: wrong MMC boot mode\n");
#endif
- hang();
+ return -1;
}
if (err)
- hang();
+ return -1;
+
+ return 0;
}
diff --git a/include/configs/cm_fx6.h b/include/configs/cm_fx6.h
index 7cf241e..2b9643d 100644
--- a/include/configs/cm_fx6.h
+++ b/include/configs/cm_fx6.h
@@ -244,6 +244,7 @@
#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50
#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
#define CONFIG_SYS_I2C_EEPROM_BUS 2
+#define CONFIG_SYS_I2C_IGB_EEPROM_BUS 0
/* SATA */
#define CONFIG_CMD_SATA
diff --git a/include/spl.h b/include/spl.h
index a7e41da..ce6a8ad 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -51,7 +51,7 @@ void spl_onenand_load_image(void);
void spl_nor_load_image(void);
/* MMC SPL functions */
-void spl_mmc_load_image(void);
+int spl_mmc_load_image(void);
/* YMODEM SPL functions */
void spl_ymodem_load_image(void);