Commit 8026b1e42f533f14115bb629efeaaedec6eaf23b

Authored by Vipin KUMAR
Committed by Albert ARIBAUD
1 parent 70fdbefc6c

SPEAr: Place ethaddr write and read within CONFIG_CMD_NET

ethaddr can be optionally read from i2c memory. So, chip_config command supports
reading/writing hw mac id into i2c memory. Placing this code within
CONFIG_CMD_NET as this would only be needed when network interface is configured

Signed-off-by: Vipin Kumar <vipin.kumar@st.com>
Signed-off-by: Amit Virdi <amit.virdi@st.com>
Signed-off-by: Stefan Roese <sr@denx.de>

Showing 2 changed files with 29 additions and 8 deletions Side-by-side Diff

board/spear/common/spr_misc.c
... ... @@ -36,6 +36,10 @@
36 36  
37 37 DECLARE_GLOBAL_DATA_PTR;
38 38  
  39 +#if defined(CONFIG_CMD_NET)
  40 +static int i2c_read_mac(uchar *buffer);
  41 +#endif
  42 +
39 43 int dram_init(void)
40 44 {
41 45 /* Store complete RAM size and return */
... ... @@ -136,6 +140,7 @@
136 140 return 0;
137 141 }
138 142  
  143 +#if defined(CONFIG_CMD_NET)
139 144 static int i2c_read_mac(uchar *buffer)
140 145 {
141 146 u8 buf[2];
142 147  
143 148  
144 149  
... ... @@ -172,17 +177,18 @@
172 177 return 0;
173 178 }
174 179  
175   - puts("I2C EEPROM writing failed \n");
  180 + puts("I2C EEPROM writing failed\n");
176 181 return -1;
177 182 }
  183 +#endif
178 184  
179 185 int do_chip_config(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
180 186 {
181 187 void (*sram_setfreq) (unsigned int, unsigned int);
  188 + unsigned int frequency;
  189 +#if defined(CONFIG_CMD_NET)
182 190 unsigned char mac[6];
183   - unsigned int reg, frequency;
184   - char *s, *e;
185   - char i2c_mac[20];
  191 +#endif
186 192  
187 193 if ((argc > 3) || (argc < 2))
188 194 return cmd_usage(cmdtp);
189 195  
... ... @@ -207,9 +213,12 @@
207 213 }
208 214  
209 215 return 0;
  216 +
  217 +#if defined(CONFIG_CMD_NET)
210 218 } else if (!strcmp(argv[1], "ethaddr")) {
211 219  
212   - s = argv[2];
  220 + u32 reg;
  221 + char *e, *s = argv[2];
213 222 for (reg = 0; reg < 6; ++reg) {
214 223 mac[reg] = s ? simple_strtoul(s, &e, 16) : 0;
215 224 if (s)
216 225  
217 226  
218 227  
... ... @@ -218,14 +227,15 @@
218 227 write_mac(mac);
219 228  
220 229 return 0;
  230 +#endif
221 231 } else if (!strcmp(argv[1], "print")) {
  232 +#if defined(CONFIG_CMD_NET)
222 233 if (!i2c_read_mac(mac)) {
223   - sprintf(i2c_mac, "%pM", mac);
224   - printf("Ethaddr (from i2c mem) = %s\n", i2c_mac);
  234 + printf("Ethaddr (from i2c mem) = %pM\n", mac);
225 235 } else {
226 236 printf("Ethaddr (from i2c mem) = Not set\n");
227 237 }
228   -
  238 +#endif
229 239 return 0;
230 240 }
231 241  
... ... @@ -235,5 +245,8 @@
235 245 U_BOOT_CMD(chip_config, 3, 1, do_chip_config,
236 246 "configure chip",
237 247 "chip_config cpufreq/ddrfreq frequency\n"
  248 +#if defined(CONFIG_CMD_NET)
  249 + "chip_config ethaddr XX:XX:XX:XX:XX:XX\n"
  250 +#endif
238 251 "chip_config print");
... ... @@ -46,4 +46,12 @@
46 46 make FLASH=PNOR (supported by SPEAr310 and SPEAr320)
47 47 - This option generates a uboot image that supports emi controller for
48 48 CFI compliant parallel NOR flash
  49 +
  50 +Mac id storage and retrieval in spear platforms
  51 +
  52 +Please read doc/README.enetaddr for the implementation guidelines for mac id
  53 +usage. Basically, environment has precedence over board specific storage. The
  54 +ethaddr beeing used for the network interface is always taken only from
  55 +environment variables. Although, we can check the mac id programmed in i2c
  56 +memory by using chip_config command