2003-03-06 21:55:29 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2002
|
|
|
|
* Denis Peter, MPL AG Switzerland, d.peter@mpl.ch
|
|
|
|
*
|
|
|
|
* adapted for VCMA9
|
|
|
|
* David Mueller, ELSOFT AG, d.mueller@elsoft.ch
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2003-03-06 21:55:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
2009-03-28 23:58:16 +00:00
|
|
|
#include <net.h>
|
2003-03-06 21:55:29 +00:00
|
|
|
#include "vcma9.h"
|
|
|
|
#include "../common/common_util.h"
|
|
|
|
|
2009-08-25 20:09:37 +00:00
|
|
|
#if defined(CONFIG_CS8900)
|
2007-11-21 20:19:24 +00:00
|
|
|
#include <../drivers/net/cs8900.h>
|
2003-03-06 21:55:29 +00:00
|
|
|
|
|
|
|
static uchar cs8900_chksum(ushort data)
|
|
|
|
{
|
|
|
|
return((data >> 8) & 0x00FF) + (data & 0x00FF);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2007-09-15 18:48:41 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2003-03-06 21:55:29 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2010-06-28 20:00:46 +00:00
|
|
|
int do_vcma9(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
2003-03-06 21:55:29 +00:00
|
|
|
{
|
2009-08-25 20:09:37 +00:00
|
|
|
struct eth_device *dev;
|
|
|
|
char cs8900_name[10];
|
2003-03-06 21:55:29 +00:00
|
|
|
if (strcmp(argv[1], "info") == 0)
|
|
|
|
{
|
2011-05-01 21:52:51 +00:00
|
|
|
vcma9_print_info();
|
2008-05-20 14:00:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2009-08-25 20:09:37 +00:00
|
|
|
#if defined(CONFIG_CS8900)
|
2003-12-07 18:32:37 +00:00
|
|
|
if (strcmp(argv[1], "cs8900") == 0) {
|
2009-08-25 20:09:37 +00:00
|
|
|
sprintf(cs8900_name, "%s-0", CS8900_DRIVERNAME);
|
|
|
|
dev = eth_get_dev_by_name(cs8900_name);
|
|
|
|
if (!dev) {
|
|
|
|
printf("Couldn't find CS8900 driver");
|
|
|
|
return 0;
|
|
|
|
}
|
2003-03-06 21:55:29 +00:00
|
|
|
if (strcmp(argv[2], "read") == 0) {
|
|
|
|
uchar addr; ushort data;
|
|
|
|
|
|
|
|
addr = simple_strtoul(argv[3], NULL, 16);
|
2009-08-25 20:09:37 +00:00
|
|
|
cs8900_e2prom_read(dev, addr, &data);
|
2003-03-06 21:55:29 +00:00
|
|
|
printf("0x%2.2X: 0x%4.4X\n", addr, data);
|
|
|
|
} else if (strcmp(argv[2], "write") == 0) {
|
|
|
|
uchar addr; ushort data;
|
|
|
|
|
|
|
|
addr = simple_strtoul(argv[3], NULL, 16);
|
|
|
|
data = simple_strtoul(argv[4], NULL, 16);
|
2009-08-25 20:09:37 +00:00
|
|
|
cs8900_e2prom_write(dev, addr, data);
|
2003-03-06 21:55:29 +00:00
|
|
|
} else if (strcmp(argv[2], "setaddr") == 0) {
|
|
|
|
uchar addr, i, csum; ushort data;
|
2009-02-11 23:38:38 +00:00
|
|
|
uchar ethaddr[6];
|
2003-03-06 21:55:29 +00:00
|
|
|
|
|
|
|
/* check for valid ethaddr */
|
2009-02-11 23:38:38 +00:00
|
|
|
if (eth_getenv_enetaddr("ethaddr", ethaddr)) {
|
2003-03-06 21:55:29 +00:00
|
|
|
addr = 1;
|
|
|
|
data = 0x2158;
|
2009-08-25 20:09:37 +00:00
|
|
|
cs8900_e2prom_write(dev, addr, data);
|
2003-03-06 21:55:29 +00:00
|
|
|
csum = cs8900_chksum(data);
|
|
|
|
addr++;
|
|
|
|
for (i = 0; i < 6; i+=2) {
|
2009-03-28 23:58:16 +00:00
|
|
|
data = ethaddr[i+1] << 8 |
|
|
|
|
ethaddr[i];
|
2009-08-25 20:09:37 +00:00
|
|
|
cs8900_e2prom_write(dev, addr, data);
|
2003-03-06 21:55:29 +00:00
|
|
|
csum += cs8900_chksum(data);
|
|
|
|
addr++;
|
|
|
|
}
|
|
|
|
/* calculate header link byte */
|
|
|
|
data = 0xA100 | (addr * 2);
|
2009-08-25 20:09:37 +00:00
|
|
|
cs8900_e2prom_write(dev, 0, data);
|
2003-03-06 21:55:29 +00:00
|
|
|
csum += cs8900_chksum(data);
|
|
|
|
/* write checksum word */
|
2009-08-25 20:09:37 +00:00
|
|
|
cs8900_e2prom_write(dev, addr, (0 - csum) << 8);
|
2003-03-06 21:55:29 +00:00
|
|
|
} else {
|
2003-12-07 18:32:37 +00:00
|
|
|
puts("\nplease defined 'ethaddr'\n");
|
2003-03-06 21:55:29 +00:00
|
|
|
}
|
|
|
|
} else if (strcmp(argv[2], "dump") == 0) {
|
2003-03-14 20:47:52 +00:00
|
|
|
uchar addr = 0, endaddr, csum; ushort data;
|
2003-03-06 21:55:29 +00:00
|
|
|
|
2003-12-07 18:32:37 +00:00
|
|
|
puts("Dump of CS8900 config device: ");
|
2009-08-25 20:09:37 +00:00
|
|
|
cs8900_e2prom_read(dev, addr, &data);
|
2003-03-06 21:55:29 +00:00
|
|
|
if ((data & 0xE000) == 0xA000) {
|
|
|
|
endaddr = (data & 0x00FF) / 2;
|
|
|
|
csum = cs8900_chksum(data);
|
|
|
|
for (addr = 1; addr <= endaddr; addr++) {
|
2009-08-25 20:09:37 +00:00
|
|
|
cs8900_e2prom_read(dev, addr, &data);
|
2003-03-06 21:55:29 +00:00
|
|
|
printf("\n0x%2.2X: 0x%4.4X", addr, data);
|
|
|
|
csum += cs8900_chksum(data);
|
|
|
|
}
|
|
|
|
printf("\nChecksum: %s", (csum == 0) ? "ok" : "wrong");
|
|
|
|
} else {
|
2003-12-07 18:32:37 +00:00
|
|
|
puts("no valid config found");
|
2003-03-06 21:55:29 +00:00
|
|
|
}
|
2003-12-07 18:32:37 +00:00
|
|
|
puts("\n");
|
2003-03-06 21:55:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return (do_mplcommon(cmdtp, flag, argc, argv));
|
|
|
|
}
|
2003-09-13 19:01:12 +00:00
|
|
|
|
|
|
|
U_BOOT_CMD(
|
|
|
|
vcma9, 6, 1, do_vcma9,
|
2009-01-28 00:03:12 +00:00
|
|
|
"VCMA9 specific commands",
|
2011-05-01 21:52:51 +00:00
|
|
|
"flash mem [SrcAddr] - updates U-Boot with image in memory\n"
|
|
|
|
"vcma9 info - displays board information"
|
2003-09-13 19:01:12 +00:00
|
|
|
);
|